Update generic_extractor.py for general/ youtube extraction.

pull/259/head
erinhmclark 2025-03-18 21:10:06 +00:00
rodzic 7d972ee9b8
commit a577228465
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)