add '-s/--simulate' to run data extraction without download

Useful for quick testing (even though -g and -j kind of do the same)
and to fill a download archive without actually downloading the files.

-s does the same as the default behaviour, except downloading stuff.
Maybe it should get a more fitting name, as it does actually write to
disk (cache, archive)?
This commit is contained in:
Mike Fährmann
2018-05-25 16:07:18 +02:00
parent 15cce22d82
commit 2df1a15fb8
3 changed files with 19 additions and 1 deletions

View File

@@ -209,7 +209,7 @@ class DownloadJob(Job):
def handle_queue(self, url, keywords):
try:
DownloadJob(url, self).run()
self.__class__(url, self).run()
except exception.NoExtractorError:
self._write_unsupported(url)
@@ -227,6 +227,18 @@ class DownloadJob(Job):
return instance
class SimulationJob(DownloadJob):
"""Simulate the extraction process without downloading anything"""
def handle_url(self, url, keywords, fallback=None):
self.pathfmt.set_keywords(keywords)
self.out.skip(self.pathfmt.path)
if self.sleep:
time.sleep(self.sleep)
if self.archive:
self.archive.add(keywords)
class KeywordJob(Job):
"""Print available keywords"""