summaryrefslogtreecommitdiffstats
path: root/gallery_dl/downloader
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/downloader')
-rw-r--r--gallery_dl/downloader/http.py15
-rw-r--r--gallery_dl/downloader/ytdl.py17
2 files changed, 23 insertions, 9 deletions
diff --git a/gallery_dl/downloader/http.py b/gallery_dl/downloader/http.py
index e3229eb..4c5fed5 100644
--- a/gallery_dl/downloader/http.py
+++ b/gallery_dl/downloader/http.py
@@ -38,11 +38,12 @@ class HttpDownloader(DownloaderBase):
if self.retries < 0:
self.retries = float("inf")
if self.rate:
- self.rate = text.parse_bytes(self.rate)
- if not self.rate:
- self.log.warning("Invalid rate limit specified")
- elif self.rate < self.chunk_size:
- self.chunk_size = self.rate
+ rate = text.parse_bytes(self.rate)
+ if not rate:
+ self.log.warning("Invalid rate limit (%r)", self.rate)
+ elif rate < self.chunk_size:
+ self.chunk_size = rate
+ self.rate = rate
def download(self, url, pathfmt):
try:
@@ -124,10 +125,10 @@ class HttpDownloader(DownloaderBase):
if not offset:
mode = "w+b"
if filesize:
- self.log.info("Unable to resume partial download")
+ self.log.debug("Unable to resume partial download")
else:
mode = "r+b"
- self.log.info("Resuming download at byte %d", offset)
+ self.log.debug("Resuming download at byte %d", offset)
# start downloading
self.out.start(pathfmt.path)
diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py
index 7d8b905..ce921e3 100644
--- a/gallery_dl/downloader/ytdl.py
+++ b/gallery_dl/downloader/ytdl.py
@@ -8,7 +8,7 @@
"""Downloader module for URLs requiring youtube-dl support"""
-from youtube_dl import YoutubeDL
+from youtube_dl import YoutubeDL, DEFAULT_OUTTMPL
from .common import DownloaderBase
from .. import text
import os
@@ -36,6 +36,9 @@ class YoutubeDLDownloader(DownloaderBase):
options["logger"] = self.log
self.forward_cookies = self.config("forward-cookies", True)
+ outtmpl = self.config("outtmpl")
+ self.outtmpl = DEFAULT_OUTTMPL if outtmpl == "default" else outtmpl
+
self.ytdl = YoutubeDL(options)
def download(self, url, pathfmt):
@@ -60,7 +63,17 @@ class YoutubeDLDownloader(DownloaderBase):
def _download_video(self, pathfmt, info_dict):
if "url" in info_dict:
text.nameext_from_url(info_dict["url"], pathfmt.kwdict)
- pathfmt.set_extension(info_dict["ext"])
+
+ if self.outtmpl:
+ self.ytdl.params["outtmpl"] = self.outtmpl
+ pathfmt.filename = filename = self.ytdl.prepare_filename(info_dict)
+ pathfmt.extension = info_dict["ext"]
+ pathfmt.path = pathfmt.directory + filename
+ pathfmt.realpath = pathfmt.temppath = (
+ pathfmt.realdirectory + filename)
+ else:
+ pathfmt.set_extension(info_dict["ext"])
+
if pathfmt.exists():
pathfmt.temppath = ""
return True