add option to use different youtube-dl modules (fixes #1330)
by setting the 'downloader.ytdl.module' value. For example
{
"downloader": {
"ytdl": {
"module": "yt_dlp"
}
}
}
or '-o module=yt_dlp'
This commit is contained in:
@@ -1943,6 +1943,16 @@ Description
|
|||||||
`downloader.ytdl.raw-options`_ to ``true`` to suppress all output.
|
`downloader.ytdl.raw-options`_ to ``true`` to suppress all output.
|
||||||
|
|
||||||
|
|
||||||
|
downloader.ytdl.module
|
||||||
|
----------------------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``"youtube_dl"``
|
||||||
|
Description
|
||||||
|
Name of the youtube-dl Python module to import.
|
||||||
|
|
||||||
|
|
||||||
downloader.ytdl.outtmpl
|
downloader.ytdl.outtmpl
|
||||||
-----------------------
|
-----------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018-2020 Mike Fährmann
|
# Copyright 2018-2021 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"""Downloader module for URLs requiring youtube-dl support"""
|
"""Downloader module for URLs requiring youtube-dl support"""
|
||||||
|
|
||||||
from youtube_dl import YoutubeDL, DEFAULT_OUTTMPL
|
|
||||||
from .common import DownloaderBase
|
from .common import DownloaderBase
|
||||||
from .. import text
|
from .. import text
|
||||||
import os
|
import os
|
||||||
@@ -16,8 +15,14 @@ import os
|
|||||||
|
|
||||||
class YoutubeDLDownloader(DownloaderBase):
|
class YoutubeDLDownloader(DownloaderBase):
|
||||||
scheme = "ytdl"
|
scheme = "ytdl"
|
||||||
|
module = None
|
||||||
|
|
||||||
def __init__(self, job):
|
def __init__(self, job):
|
||||||
|
module = self.module
|
||||||
|
if not module:
|
||||||
|
module_name = self.config("module") or "youtube_dl"
|
||||||
|
module = YoutubeDLDownloader.module = __import__(module_name)
|
||||||
|
|
||||||
DownloaderBase.__init__(self, job)
|
DownloaderBase.__init__(self, job)
|
||||||
extractor = job.extractor
|
extractor = job.extractor
|
||||||
|
|
||||||
@@ -42,10 +47,11 @@ class YoutubeDLDownloader(DownloaderBase):
|
|||||||
options["logger"] = self.log
|
options["logger"] = self.log
|
||||||
self.forward_cookies = self.config("forward-cookies", False)
|
self.forward_cookies = self.config("forward-cookies", False)
|
||||||
|
|
||||||
outtmpl = self.config("outtmpl")
|
self.outtmpl = self.config("outtmpl")
|
||||||
self.outtmpl = DEFAULT_OUTTMPL if outtmpl == "default" else outtmpl
|
if self.outtmpl == "default":
|
||||||
|
self.outtmpl = module.DEFAULT_OUTTMPL
|
||||||
|
|
||||||
self.ytdl = YoutubeDL(options)
|
self.ytdl = module.YoutubeDL(options)
|
||||||
|
|
||||||
def download(self, url, pathfmt):
|
def download(self, url, pathfmt):
|
||||||
if self.forward_cookies:
|
if self.forward_cookies:
|
||||||
|
|||||||
@@ -7,3 +7,5 @@ hiddenimports = [
|
|||||||
for package in (extractor, downloader, postprocessor)
|
for package in (extractor, downloader, postprocessor)
|
||||||
for module in package.modules
|
for module in package.modules
|
||||||
]
|
]
|
||||||
|
|
||||||
|
hiddenimports.append("youtube_dl")
|
||||||
|
|||||||
Reference in New Issue
Block a user