diff --git a/files/0001-Replace-youtube-dl-with-yt-dlp.patch b/files/0001-Replace-youtube-dl-with-yt-dlp.patch new file mode 100644 --- /dev/null +++ b/files/0001-Replace-youtube-dl-with-yt-dlp.patch @@ -0,0 +1,147 @@ +From a28b3c5f1451802a76e49af822ad4f552416859d Mon Sep 17 00:00:00 2001 +From: Thomas Staudinger +Date: Tue, 9 Nov 2021 19:15:44 +0100 +Subject: [PATCH] Replace youtube-dl with yt-dlp + +--- + README.rst | 2 +- + pafy/backend_internal.py | 2 +- + pafy/{backend_youtube_dl.py => backend_yt_dlp.py} | 8 ++++---- + pafy/jsinterp.py | 4 ++-- + pafy/pafy.py | 10 +++++----- + setup.py | 2 +- + 6 files changed, 14 insertions(+), 14 deletions(-) + rename pafy/{backend_youtube_dl.py => backend_yt_dlp.py} (97%) + +diff --git a/README.rst b/README.rst +index 452fd8b..8b1377d 100644 +--- a/README.rst ++++ b/README.rst +@@ -27,7 +27,7 @@ Features + - Download audio only (no video) in ogg or m4a format + - Retreive playlists and playlist metadata + - Works with Python 2.6+ and 3.3+ +-- Optionally depends on youtube-dl (recommended; more stable) ++- Optionally depends on yt-dlp (recommended; more stable) + + + Documentation +diff --git a/pafy/backend_internal.py b/pafy/backend_internal.py +index 9ccdc28..efc61a4 100644 +--- a/pafy/backend_internal.py ++++ b/pafy/backend_internal.py +@@ -266,7 +266,7 @@ def get_video_info(video_id, callback, newurl=None): + """ Return info for video_id. Returns dict. """ + # TODO: see if there is a way to avoid retrieving the embed page + # just for this, or to use it for more. This was coppied from +- # youtube-dl. ++ # yt-dlp. + embed_webpage = fetch_decode(g.urls['embed']) + sts = re.search(r'sts"\s*:\s*(\d+)', embed_webpage).group(1) + +diff --git a/pafy/backend_youtube_dl.py b/pafy/backend_yt_dlp.py +similarity index 97% +rename from pafy/backend_youtube_dl.py +rename to pafy/backend_yt_dlp.py +index 4b38f12..c5f4ace 100644 +--- a/pafy/backend_youtube_dl.py ++++ b/pafy/backend_yt_dlp.py +@@ -10,7 +10,7 @@ if sys.version_info[:2] >= (3, 0): + else: + uni = unicode + +-import youtube_dl ++import yt_dlp + + from . import g + from .backend_shared import BasePafy, BaseStream, remux, get_status_string, get_size_done +@@ -35,11 +35,11 @@ class YtdlPafy(BasePafy): + if self._have_basic: + return + +- with youtube_dl.YoutubeDL(self._ydl_opts) as ydl: ++ with yt_dlp.YoutubeDL(self._ydl_opts) as ydl: + try: + self._ydl_info = ydl.extract_info(self.videoid, download=False) + # Turn into an IOError since that is what pafy previously raised +- except youtube_dl.utils.DownloadError as e: ++ except yt_dlp.utils.DownloadError as e: + raise IOError(str(e).replace('YouTube said', 'Youtube says')) + + if self.callback: +@@ -132,7 +132,7 @@ class YtdlStream(BaseStream): + def download(self, filepath="", quiet=False, progress="Bytes", + callback=None, meta=False, remux_audio=False): + +- downloader = youtube_dl.downloader.http.HttpFD(ydl(), ++ downloader = yt_dlp.downloader.http.HttpFD(ydl(), + {'http_chunk_size': 10485760}) + + progress_available = ["KB", "MB", "GB"] +diff --git a/pafy/jsinterp.py b/pafy/jsinterp.py +index 3b0b889..b83339b 100644 +--- a/pafy/jsinterp.py ++++ b/pafy/jsinterp.py +@@ -1,4 +1,4 @@ +-# Copied from youtube_dl ++# Copied from yt_dlp + + from __future__ import unicode_literals + +@@ -14,7 +14,7 @@ class ExtractorError(Exception): + + def __init__(self, msg, tb=None, expected=False, cause=None, video_id=None): + """ tb, if given, is the original traceback (so that it can be printed out). +- If expected is set, this is a normal error message and most likely not a bug in youtube-dl. ++ If expected is set, this is a normal error message and most likely not a bug in yt-dlp. + """ + + if video_id is not None: +diff --git a/pafy/pafy.py b/pafy/pafy.py +index 62bde9a..08b7f75 100644 +--- a/pafy/pafy.py ++++ b/pafy/pafy.py +@@ -45,14 +45,14 @@ Pafy = None + backend = "internal" + if os.environ.get("PAFY_BACKEND") != "internal": + try: +- import youtube_dl +- backend = "youtube-dl" ++ import yt_dlp ++ backend = "yt-dlp" + except ImportError: + raise ImportError( +- "pafy: youtube-dl not found; you can use the internal backend by " ++ "pafy: yt-dlp not found; you can use the internal backend by " + "setting the environmental variable PAFY_BACKEND to \"internal\". " + "It is not enabled by default because it is not as well maintained " +- "as the youtube-dl backend.") ++ "as the yt-dlp backend.") + + if os.environ.get("pafydebug") == "1": + logging.basicConfig(level=logging.DEBUG) +@@ -119,7 +119,7 @@ def new(url, basic=True, gdata=False, size=False, + if backend == "internal": + from .backend_internal import InternPafy as Pafy + else: +- from .backend_youtube_dl import YtdlPafy as Pafy ++ from .backend_yt_dlp import YtdlPafy as Pafy + + return Pafy(url, basic, gdata, size, callback, ydl_opts=ydl_opts) + +diff --git a/setup.py b/setup.py +index 99a9a0d..9f820ac 100755 +--- a/setup.py ++++ b/setup.py +@@ -24,7 +24,7 @@ setup( + url="http://np1.github.io/pafy/", + download_url="https://github.com/np1/pafy/tarball/master", + extras_require={ +- 'youtube-dl-backend': ["youtube-dl"], ++ 'yt-dlp-backend': ["yt-dlp"], + }, + package_data={"": ["LICENSE", "README.rst", "CHANGELOG", "AUTHORS"]}, + include_package_data=True, +-- +2.33.1 + diff --git a/package.yml b/package.yml --- a/package.yml +++ b/package.yml @@ -1,6 +1,6 @@ name : python-pafy version : 0.5.5 -release : 6 +release : 7 source : - https://github.com/mps-youtube/pafy/releases/download/v0.5.5/pafy-0.5.5.tar.gz : 364f1d1312c89582d97dc7225cf6858cde27cb11dfd64a9c2bab1a2f32133b1e homepage : https://github.com/mps-youtube/pafy @@ -10,9 +10,11 @@ description: | Python library to download YouTube content and retrieve metadata. builddeps : - - youtube-dl + - yt-dlp rundeps : - - youtube-dl + - yt-dlp +setup : | + %patch -p1 < $pkgfiles/0001-Replace-youtube-dl-with-yt-dlp.patch build : | %python3_setup install : | diff --git a/pspec_x86_64.xml b/pspec_x86_64.xml --- a/pspec_x86_64.xml +++ b/pspec_x86_64.xml @@ -3,8 +3,8 @@ python-pafy https://github.com/mps-youtube/pafy - Joey Riches - josephriches@gmail.com + Thomas Staudinger + Staudi.Kaos@gmail.com LGPL-3.0-or-later programming.python @@ -30,7 +30,7 @@ /usr/lib/python3.9/site-packages/pafy/__pycache__/__init__.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/__pycache__/backend_internal.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/__pycache__/backend_shared.cpython-39.pyc - /usr/lib/python3.9/site-packages/pafy/__pycache__/backend_youtube_dl.cpython-39.pyc + /usr/lib/python3.9/site-packages/pafy/__pycache__/backend_yt_dlp.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/__pycache__/channel.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/__pycache__/g.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/__pycache__/jsinterp.cpython-39.pyc @@ -39,7 +39,7 @@ /usr/lib/python3.9/site-packages/pafy/__pycache__/util.cpython-39.pyc /usr/lib/python3.9/site-packages/pafy/backend_internal.py /usr/lib/python3.9/site-packages/pafy/backend_shared.py - /usr/lib/python3.9/site-packages/pafy/backend_youtube_dl.py + /usr/lib/python3.9/site-packages/pafy/backend_yt_dlp.py /usr/lib/python3.9/site-packages/pafy/channel.py /usr/lib/python3.9/site-packages/pafy/g.py /usr/lib/python3.9/site-packages/pafy/jsinterp.py @@ -49,12 +49,12 @@ - - 2021-07-28 + + 2021-11-09 0.5.5 Packaging update - Joey Riches - josephriches@gmail.com + Thomas Staudinger + Staudi.Kaos@gmail.com \ No newline at end of file