Merge pull request #259 from bellingcat/fix_youtube_generic

Small fix for generic_extractor.py for general/ youtube extraction.
pull/263/head
Erin Clark 2025-03-19 11:52:56 +00:00 zatwierdzone przez GitHub
commit 90932a7bc8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -203,7 +203,7 @@ class GenericExtractor(Extractor):
if not result.get("url"):
result.set_url(url)
if "description" in video_data and not result.get_content():
if "description" in video_data and not result.get("content"):
result.set_content(video_data["description"])
# extract comments if enabled
if self.comments:
@ -220,10 +220,13 @@ class GenericExtractor(Extractor):
)
# then add the common metadata
if timestamp := video_data.pop("timestamp", None) and not result.get("timestamp"):
timestamp = video_data.pop("timestamp", None)
if timestamp and not result.get("timestamp"):
timestamp = datetime.datetime.fromtimestamp(timestamp, tz=datetime.timezone.utc).isoformat()
result.set_timestamp(timestamp)
if upload_date := video_data.pop("upload_date", None) and not result.get("upload_date"):
upload_date = video_data.pop("upload_date", None)
if upload_date and not result.get("upload_date"):
upload_date = get_datetime_from_str(upload_date, "%Y%m%d").replace(tzinfo=datetime.timezone.utc)
result.set("upload_date", upload_date)