1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

use yt-dlp by default (#1850, #2028)

This commit is contained in:
Mike Fährmann 2021-11-29 04:36:43 +01:00
parent f1b142e993
commit f4e3cee6ac
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
8 changed files with 29 additions and 13 deletions

View File

@ -21,7 +21,7 @@ jobs:
- name: Build executable - name: Build executable
run: | run: |
pip install requests requests[socks] urllib3==1.25.11 youtube-dl pyinstaller pip install requests requests[socks] urllib3==1.25.11 yt-dlp pyinstaller
python scripts/pyinstaller.py python scripts/pyinstaller.py
- name: Upload executable - name: Upload executable

View File

@ -23,7 +23,7 @@ Optional
-------- --------
- FFmpeg_: Pixiv Ugoira to WebM conversion - FFmpeg_: Pixiv Ugoira to WebM conversion
- youtube-dl_: Video downloads - yt-dlp_ or youtube-dl_: Video downloads
Installation Installation
@ -328,6 +328,7 @@ To authenticate with a ``mastodon`` instance, run *gallery-dl* with
.. _pip: https://pip.pypa.io/en/stable/ .. _pip: https://pip.pypa.io/en/stable/
.. _Requests: https://requests.readthedocs.io/en/master/ .. _Requests: https://requests.readthedocs.io/en/master/
.. _FFmpeg: https://www.ffmpeg.org/ .. _FFmpeg: https://www.ffmpeg.org/
.. _yt-dlp: https://github.com/yt-dlp/yt-dlp
.. _youtube-dl: https://ytdl-org.github.io/youtube-dl/ .. _youtube-dl: https://ytdl-org.github.io/youtube-dl/
.. _pyOpenSSL: https://pyopenssl.org/ .. _pyOpenSSL: https://pyopenssl.org/
.. _Snapd: https://docs.snapcraft.io/installing-snapd .. _Snapd: https://docs.snapcraft.io/installing-snapd

View File

@ -2275,10 +2275,13 @@ extractor.ytdl.module
Type Type
``string`` ``string``
Default Default
``"youtube_dl"`` ``null``
Description Description
Name of the youtube-dl Python module to import. Name of the youtube-dl Python module to import.
Setting this to ``null`` will try to import ``"yt_dlp"``
followed by ``"youtube_dl"`` as fallback.
extractor.ytdl.raw-options extractor.ytdl.raw-options
-------------------------- --------------------------
@ -2564,10 +2567,13 @@ downloader.ytdl.module
Type Type
``string`` ``string``
Default Default
``"youtube_dl"`` ``null``
Description Description
Name of the youtube-dl Python module to import. Name of the youtube-dl Python module to import.
Setting this to ``null`` will first try to import ``"yt_dlp"``
and use ``"youtube_dl"`` as fallback.
downloader.ytdl.outtmpl downloader.ytdl.outtmpl
----------------------- -----------------------

View File

@ -303,7 +303,7 @@
"format": null, "format": null,
"generic": true, "generic": true,
"logging": true, "logging": true,
"module": "youtube_dl", "module": null,
"raw-options": null "raw-options": null
}, },
"booru": "booru":
@ -337,7 +337,7 @@
"format": null, "format": null,
"forward-cookies": false, "forward-cookies": false,
"logging": true, "logging": true,
"module": "youtube_dl", "module": null,
"outtmpl": null, "outtmpl": null,
"raw-options": null "raw-options": null
} }

View File

@ -39,7 +39,7 @@ class YoutubeDLDownloader(DownloaderBase):
if not ytdl_instance: if not ytdl_instance:
ytdl_instance = self.ytdl_instance ytdl_instance = self.ytdl_instance
if not ytdl_instance: if not ytdl_instance:
module = __import__(self.config("module") or "youtube_dl") module = ytdl.import_module(self.config("module"))
self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL( self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL(
module, self, self.ytdl_opts) module, self, self.ytdl_opts)
if self.outtmpl == "default": if self.outtmpl == "default":

View File

@ -23,9 +23,9 @@ class YoutubeDLExtractor(Extractor):
def __init__(self, match): def __init__(self, match):
# import main youtube_dl module # import main youtube_dl module
module_name = self.ytdl_module_name = config.get( ytdl_module = ytdl.import_module(config.get(
("extractor", "ytdl"), "module") or "youtube_dl" ("extractor", "ytdl"), "module"))
module = __import__(module_name) self.ytdl_module_name = ytdl_module.__name__
# find suitable youtube_dl extractor # find suitable youtube_dl extractor
self.ytdl_url = url = match.group(1) self.ytdl_url = url = match.group(1)
@ -34,7 +34,7 @@ class YoutubeDLExtractor(Extractor):
self.ytdl_ie_key = "Generic" self.ytdl_ie_key = "Generic"
self.force_generic_extractor = True self.force_generic_extractor = True
else: else:
for ie in module.extractor.gen_extractor_classes(): for ie in ytdl_module.extractor.gen_extractor_classes():
if ie.suitable(url): if ie.suitable(url):
self.ytdl_ie_key = ie.ie_key() self.ytdl_ie_key = ie.ie_key()
break break
@ -48,7 +48,7 @@ class YoutubeDLExtractor(Extractor):
def items(self): def items(self):
# import subcategory module # import subcategory module
ytdl_module = __import__( ytdl_module = ytdl.import_module(
config.get(("extractor", "ytdl", self.subcategory), "module") or config.get(("extractor", "ytdl", self.subcategory), "module") or
self.ytdl_module_name) self.ytdl_module_name)
self.log.debug("Using %s", ytdl_module) self.log.debug("Using %s", ytdl_module)

View File

@ -14,6 +14,15 @@ import itertools
from . import text, util, exception from . import text, util, exception
def import_module(module_name):
if module_name is None:
try:
return __import__("yt_dlp")
except ImportError:
return __import__("youtube_dl")
return __import__(module_name.replace("-", "_"))
def construct_YoutubeDL(module, obj, user_opts, system_opts=None): def construct_YoutubeDL(module, obj, user_opts, system_opts=None):
opts = argv = None opts = argv = None
config = obj.config config = obj.config

View File

@ -8,4 +8,4 @@ hiddenimports = [
for module in package.modules for module in package.modules
] ]
hiddenimports.append("youtube_dl") hiddenimports.append("yt_dlp")