Skip to main content

Merge pull request #8 from alexwlchan/include-upload-date

ID
4b36185
date
2025-10-05 20:17:04+00:00
author
Alex Chan <alex@alexwlchan.net>
parents
24f47f7, 8a6f48c
message
Merge pull request #8 from alexwlchan/include-upload-date

yt-dlp: include upload date in the output
changed files
3 files, 8 additions

Changed files

README.md (2963) → README.md (3006)

diff --git a/README.md b/README.md
index 85ab330..65eb6d7 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ $ yt-dlp_alexwlchan.py "https://www.youtube.com/watch?v=TUQaGhPdlxs"
   "url": "https://www.youtube.com/watch?v=TUQaGhPdlxs",
   "title": "\"new york city, manhattan, people\" - Free Public Domain Video",
   "description": "All videos uploaded to this channel are in the Public Domain: Free for use by anyone for any purpose without restriction. #PublicDomain",
+  "date_uploaded": "2022-03-25T01:10:38Z",
   "video_path": "\uff02new york city, manhattan, people\uff02 - Free Public Domain Video [TUQaGhPdlxs].mp4",
   "thumbnail_path": "\uff02new york city, manhattan, people\uff02 - Free Public Domain Video [TUQaGhPdlxs].jpg",
   "subtitle_path": null,

tests/test_yt-dlp_alexwlchan.py (1375) → tests/test_yt-dlp_alexwlchan.py (1505)

diff --git a/tests/test_yt-dlp_alexwlchan.py b/tests/test_yt-dlp_alexwlchan.py
index 8a2985d..9e5c234 100644
--- a/tests/test_yt-dlp_alexwlchan.py
+++ b/tests/test_yt-dlp_alexwlchan.py
@@ -25,6 +25,7 @@ def test_youtube_video() -> None:
     assert video_info["subtitle_path"] is None
 
     assert video_info["id"] == "TUQaGhPdlxs"
+    assert video_info["date_uploaded"] == "2008-04-19T03:51:21Z"
 
 
 def test_instagram_video() -> None:
@@ -45,3 +46,4 @@ def test_instagram_video() -> None:
     )
 
     assert video_info["id"] == "DMWY8KkOS0n"
+    assert video_info["date_uploaded"] == "2008-04-19T03:51:21Z"

yt-dlp_alexwlchan.py (4668) → yt-dlp_alexwlchan.py (4890)

diff --git a/yt-dlp_alexwlchan.py b/yt-dlp_alexwlchan.py
index 97b4406..b7b485b 100755
--- a/yt-dlp_alexwlchan.py
+++ b/yt-dlp_alexwlchan.py
@@ -1,5 +1,6 @@
 #!/usr/bin/env python3
 
+from datetime import datetime, timezone
 import json
 from pathlib import Path
 import subprocess
@@ -87,6 +88,7 @@ class VideoInfo(TypedDict):
     url: str
     title: str
     description: str
+    date_posted: str
     video_path: Path
     thumbnail_path: Path
     subtitle_path: Path
@@ -131,11 +133,14 @@ def download_video(url: str) -> VideoInfo:
     else:
         sys.exit(f"Unsupported extractor: {video_info['extractor']}")
 
+    date_uploaded = datetime.fromtimestamp(video_info["timestamp"], tz=timezone.utc)
+
     return {
         "id": video_info["id"],
         "url": url,
         "title": video_info["title"],
         "description": video_info["description"],
+        "date_uploaded": date_uploaded.isoformat().replace("+00:00", "Z"),
         "video_path": video_path,
         "thumbnail_path": thumbnail_path,
         "subtitle_path": subtitle_path,