diff options
| author | 2020-06-01 23:11:37 -0400 | |
|---|---|---|
| committer | 2020-06-01 23:11:37 -0400 | |
| commit | a70a3246927b72f1ded37acd55ee719515441b5b (patch) | |
| tree | 57f0d3ab0b1387b665325f42a24b8aab63cbce07 /gallery_dl/downloader | |
| parent | 90e50db2e3c38f523bb5195d295290b06e5cedb0 (diff) | |
New upstream version 1.14.0.upstream/1.14.0
Diffstat (limited to 'gallery_dl/downloader')
| -rw-r--r-- | gallery_dl/downloader/common.py | 12 | ||||
| -rw-r--r-- | gallery_dl/downloader/http.py | 10 | ||||
| -rw-r--r-- | gallery_dl/downloader/ytdl.py | 24 |
3 files changed, 30 insertions, 16 deletions
diff --git a/gallery_dl/downloader/common.py b/gallery_dl/downloader/common.py index eca1284..d858075 100644 --- a/gallery_dl/downloader/common.py +++ b/gallery_dl/downloader/common.py @@ -9,7 +9,6 @@ """Common classes and constants used by downloader modules.""" import os -import logging from .. import config, util @@ -17,15 +16,12 @@ class DownloaderBase(): """Base class for downloaders""" scheme = "" - def __init__(self, extractor, output): - self.session = extractor.session - self.out = output + def __init__(self, job): + self.out = job.out + self.session = job.extractor.session self.part = self.config("part", True) self.partdir = self.config("part-directory") - - self.log = logging.getLogger("downloader." + self.scheme) - self.log.job = extractor.log.job - self.log.extractor = extractor + self.log = job.get_logger("downloader." + self.scheme) if self.partdir: self.partdir = util.expand_path(self.partdir) diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py index 021dc16..6644827 100644 --- a/gallery_dl/downloader/http.py +++ b/gallery_dl/downloader/http.py @@ -24,16 +24,18 @@ except ImportError: class HttpDownloader(DownloaderBase): scheme = "http" - def __init__(self, extractor, output): - DownloaderBase.__init__(self, extractor, output) + def __init__(self, job): + DownloaderBase.__init__(self, job) + extractor = job.extractor + self.chunk_size = 16384 + self.downloading = False + self.adjust_extension = self.config("adjust-extensions", True) self.retries = self.config("retries", extractor._retries) self.timeout = self.config("timeout", extractor._timeout) self.verify = self.config("verify", extractor._verify) self.mtime = self.config("mtime", True) self.rate = self.config("rate") - self.downloading = False - self.chunk_size = 16384 if self.retries < 0: self.retries = float("inf") diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py index fe6c4bc..c3dd863 100644 --- a/gallery_dl/downloader/ytdl.py +++ b/gallery_dl/downloader/ytdl.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Mike Fährmann +# Copyright 2018-2020 Mike Fährmann # # 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 @@ -17,8 +17,9 @@ import os class YoutubeDLDownloader(DownloaderBase): scheme = "ytdl" - def __init__(self, extractor, output): - DownloaderBase.__init__(self, extractor, output) + def __init__(self, job): + DownloaderBase.__init__(self, job) + extractor = job.extractor retries = self.config("retries", extractor._retries) options = { @@ -35,7 +36,7 @@ class YoutubeDLDownloader(DownloaderBase): if self.config("logging", True): options["logger"] = self.log - self.forward_cookies = self.config("forward-cookies", True) + self.forward_cookies = self.config("forward-cookies", False) outtmpl = self.config("outtmpl") self.outtmpl = DEFAULT_OUTTMPL if outtmpl == "default" else outtmpl @@ -70,6 +71,10 @@ class YoutubeDLDownloader(DownloaderBase): if "url" in info_dict: text.nameext_from_url(info_dict["url"], pathfmt.kwdict) + formats = info_dict.get("requested_formats") + if formats and not compatible_formats(formats): + info_dict["ext"] = "mkv" + if self.outtmpl: self.ytdl.params["outtmpl"] = self.outtmpl pathfmt.filename = filename = self.ytdl.prepare_filename(info_dict) @@ -105,4 +110,15 @@ class YoutubeDLDownloader(DownloaderBase): return True +def compatible_formats(formats): + video_ext = formats[0].get("ext") + audio_ext = formats[1].get("ext") + + if video_ext == "webm" and audio_ext == "webm": + return True + + exts = ("mp3", "mp4", "m4a", "m4p", "m4b", "m4r", "m4v", "ismv", "isma") + return video_ext in exts and audio_ext in exts + + __downloader__ = YoutubeDLDownloader |
