[reddit] add 'videos' option

This commit is contained in:
Mike Fährmann
2020-01-31 23:45:02 +01:00
parent 2ad43618cc
commit dff33b260c
3 changed files with 31 additions and 2 deletions

View File

@@ -983,6 +983,21 @@ Description The ``refresh-token`` value you get from
=========== =====
extractor.reddit.videos
-----------------------
=========== =====
Type ``bool`` or ``string``
Default ``true``
Description Control video download behavior.
* ``true``: Download videos and use `youtube-dl`_ to handle
HLS and DASH manifests
* ``"ytdl"``: Download videos and let `youtube-dl`_ handle all of
video extraction and download
* ``false``: Ignore videos
=========== =====
extractor.sankaku.wait-min & .wait-max
--------------------------------------
=========== =====

View File

@@ -122,6 +122,7 @@
"id-min": "0",
"id-max": "zik0zj",
"recursion": 0,
"videos": true,
"user-agent": "Python:gallery-dl:0.8.4 (by /u/mikf1)"
},
"sankaku":

View File

@@ -32,6 +32,8 @@ class RedditExtractor(Extractor):
match_user = RedditUserExtractor.pattern.match
parentdir = self.config("parent-directory")
videos = self.config("videos", True)
submissions = self.submissions()
visited = set()
depth = 0
@@ -52,11 +54,22 @@ class RedditExtractor(Extractor):
if url.startswith("https://i.redd.it/"):
text.nameext_from_url(url, submission)
yield Message.Url, url, submission
elif submission["is_video"]:
text.nameext_from_url(url, submission)
yield Message.Url, "ytdl:" + url, submission
if videos:
text.nameext_from_url(url, submission)
if videos == "ytdl":
url = "https://www.reddit.com" + \
submission["permalink"]
else:
submission["_ytdl_extra"] = {
"title": submission["title"],
}
yield Message.Url, "ytdl:" + url, submission
elif not submission["is_self"]:
urls.append((url, submission))
elif parentdir:
yield Message.Directory, comments[0]