add 'mtime' option

This commit is contained in:
Mike Fährmann
2019-06-20 17:19:44 +02:00
parent ee4d7c3d89
commit db3f52881a
5 changed files with 35 additions and 3 deletions

View File

@@ -25,6 +25,7 @@ class HttpDownloader(DownloaderBase):
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
@@ -151,9 +152,10 @@ class HttpDownloader(DownloaderBase):
self.downloading = False
if adj_ext:
pathfmt.set_extension(adj_ext)
filetime = response.headers.get("Last-Modified")
if filetime:
pathfmt.keywords["_filetime"] = filetime
if self.mtime:
filetime = response.headers.get("Last-Modified")
if filetime:
pathfmt.keywords["_filetime"] = filetime
return True
def receive(self, response, file):

View File

@@ -27,6 +27,7 @@ class YoutubeDLDownloader(DownloaderBase):
"socket_timeout": self.config("timeout", extractor._timeout),
"nocheckcertificate": not self.config("verify", extractor._verify),
"nopart": not self.part,
"updatetime": self.config("mtime", True),
}
options.update(self.config("raw-options") or {})

View File

@@ -182,6 +182,12 @@ def build_parser():
dest="part", nargs=0, action=ConfigConstAction, const=False,
help="Do not use .part files",
)
downloader.add_argument(
"--no-mtime",
dest="mtime", nargs=0, action=ConfigConstAction, const=False,
help=("Do not set file modification times according to "
"Last-Modified HTTP response headers")
)
downloader.add_argument(
"--no-check-certificate",
dest="verify", nargs=0, action=ConfigConstAction, const=False,