all: include the video ID in the downloaded filenames
- ID
3393777- date
2025-10-19 06:55:18+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
6d926af- message
all: include the video ID in the downloaded filenames Fixes #15- changed files
2 files, 5 additions, 1 deletion
Changed files
test_yt-dlp_alexwlchan.py (1657) → test_yt-dlp_alexwlchan.py (1793)
diff --git a/test_yt-dlp_alexwlchan.py b/test_yt-dlp_alexwlchan.py
index 0a11d22..0194045 100644
--- a/test_yt-dlp_alexwlchan.py
+++ b/test_yt-dlp_alexwlchan.py
@@ -29,6 +29,8 @@ def test_youtube_video() -> None:
assert video_info["id"] == "TUQaGhPdlxs"
assert video_info["date_uploaded"] == "2022-03-25T01:10:38Z"
+ assert video_info["video_path"].endswith(" [TUQaGhPdlxs].mp4")
+
def test_instagram_video() -> None:
"""
@@ -49,3 +51,5 @@ def test_instagram_video() -> None:
assert video_info["id"] == "DMWY8KkOS0n"
assert video_info["date_uploaded"] == "2025-07-21T00:34:41Z"
+
+ assert video_info["video_path"].endswith(" [DMWY8KkOS0n].mp4")
yt-dlp_alexwlchan.py (6237) → yt-dlp_alexwlchan.py (6246)
diff --git a/yt-dlp_alexwlchan.py b/yt-dlp_alexwlchan.py
index 419bcc8..1d0912d 100755
--- a/yt-dlp_alexwlchan.py
+++ b/yt-dlp_alexwlchan.py
@@ -145,7 +145,7 @@ def download_video(url: str) -> VideoInfo:
# Download all the videos to a temp directory; this allows the caller
# to decide exactly where they want the video later.
tmp_dir = Path(tempfile.mkdtemp())
- ydl_opts["outtmpl"] = str(tmp_dir / "%(title)s.%(ext)s")
+ ydl_opts["outtmpl"] = str(tmp_dir / "%(title)s [%(id)s].%(ext)s")
with YoutubeDL(ydl_opts) as ydl:
video_info: Any = ydl.extract_info(url)