Skip to main content

Don’t download AI upscaled videos from YouTube

ID
cc7d9bc
date
2025-12-24 18:16:40+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
472817c
message
Don't download AI upscaled videos from YouTube
changed files
4 files, 24 additions, 1 deletion

Changed files

dev_requirements.in (64) → dev_requirements.in (76)

diff --git a/dev_requirements.in b/dev_requirements.in
index 1569f1a..a3a9eed 100644
--- a/dev_requirements.in
+++ b/dev_requirements.in
@@ -1,6 +1,7 @@
 -r requirements.txt
 
 mypy
+pymediainfo
 pytest
 pytest-xdist
 ruff

dev_requirements.txt (1836) → dev_requirements.txt (1888)

diff --git a/dev_requirements.txt b/dev_requirements.txt
index 3291c46..012f15a 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -59,6 +59,8 @@ pycryptodomex==3.23.0
     # via -r requirements.txt
 pygments==2.19.2
     # via pytest
+pymediainfo==7.0.1
+    # via -r dev_requirements.in
 pytest==9.0.2
     # via
     #   -r dev_requirements.in

requirements.txt (931) → requirements.txt (922)

diff --git a/requirements.txt b/requirements.txt
index 0c8388a..d98bc59 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -42,7 +42,7 @@ urllib3==2.6.2
     #   yt-dlp
 websockets==15.0.1
     # via yt-dlp
-yt-dlp[default]==2025.12.8
+yt-dlp==2025.12.8
     # via -r requirements.in
 yt-dlp-ejs==0.3.2
     # via yt-dlp

test_yt-dlp_alexwlchan.py (2814) → test_yt-dlp_alexwlchan.py (3483)

diff --git a/test_yt-dlp_alexwlchan.py b/test_yt-dlp_alexwlchan.py
index d1d1f7c..7e05a17 100644
--- a/test_yt-dlp_alexwlchan.py
+++ b/test_yt-dlp_alexwlchan.py
@@ -3,6 +3,8 @@ import os
 import subprocess
 from typing import Any
 
+from pymediainfo import MediaInfo
+
 
 def download_video(url: str) -> Any:
     output = subprocess.check_output(["python3", "yt-dlp_alexwlchan.py", url])
@@ -63,6 +65,24 @@ def test_youtube_video_with_automatic_subtitles() -> None:
     assert video["subtitle_path"] is not None
 
 
+def test_youtube_ignores_ai_upscaling() -> None:
+    """
+    Downloaded a YouTube video ignores AI upscaled versions.
+    """
+    # This is a video uploaded in 2009, and the highest resolution is
+    # 640x480, but as of October 2025, YouTube have started offering
+    # AI upscaled versions.
+    video = download_video("https://www.youtube.com/watch?v=0N1_0SUGlDQ")
+
+    media_info = MediaInfo.parse(video["video_path"])
+    video_track = next(
+                tr
+                for tr in media_info.tracks
+                if tr.track_type == "Video"
+            )
+    assert (video_track.width, video_track.height) == (640, 480)
+
+
 def test_instagram_video() -> None:
     """
     Download an Instagram video and check we get the expected output.