Skip to content
Snippets Groups Projects
Commit a97bb08f authored by VALLET Nathan's avatar VALLET Nathan
Browse files

add guid retrieval and use properties instead of dictionary key lookup

parent 10234043
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,6 @@ import feedparser ...@@ -2,7 +2,6 @@ import feedparser
from urllib.parse import urlparse from urllib.parse import urlparse
from datetime import datetime from datetime import datetime
def charge_urls(liste_url: list[str]) -> list[dict[str, any] | None]: def charge_urls(liste_url: list[str]) -> list[dict[str, any] | None]:
# if the key 'bozo' is true, then the feed had an error during processing, so we set it to None # if the key 'bozo' is true, then the feed had an error during processing, so we set it to None
return [ return [
...@@ -14,13 +13,14 @@ def charge_urls(liste_url: list[str]) -> list[dict[str, any] | None]: ...@@ -14,13 +13,14 @@ def charge_urls(liste_url: list[str]) -> list[dict[str, any] | None]:
def fusion_flux(liste_url: list[str], liste_flux: list[dict[str, any] | None], def fusion_flux(liste_url: list[str], liste_flux: list[dict[str, any] | None],
tri_chrono: bool) -> list[dict[str, str]]: tri_chrono: bool) -> list[dict[str, str]]:
feeds = [{ feeds = [{
'titre': entry['title'], 'titre': entry.title,
'categorie': entry['category'], 'categorie': entry.category,
'serveur': urlparse(entry['title_detail']['base']).netloc, 'serveur': urlparse(entry.title_detail.base).netloc,
'date_publi': entry['published'], 'date_publi': entry.published,
'lien': entry['link'], 'lien': entry.link,
'description': entry['description'] 'description': entry.description,
} for feed in liste_flux for entry in feed['entries']] 'guid': entry.guid
} for feed in liste_flux if feed is not None for entry in feed['entries']]
if tri_chrono: if tri_chrono:
feeds.sort(key=lambda e: datetime.strptime(e['date_publi'], feeds.sort(key=lambda e: datetime.strptime(e['date_publi'],
"%a, %d %b %Y %H:%M"), "%a, %d %b %Y %H:%M"),
...@@ -32,3 +32,6 @@ def fusion_flux(liste_url: list[str], liste_flux: list[dict[str, any] | None], ...@@ -32,3 +32,6 @@ def fusion_flux(liste_url: list[str], liste_flux: list[dict[str, any] | None],
def main(): def main():
raise NotImplementedError
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment