[reddit] add 'videos' option

pull/599/head
Mike Fährmann 5 years ago
parent 2ad43618cc
commit dff33b260c
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -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 extractor.sankaku.wait-min & .wait-max
-------------------------------------- --------------------------------------
=========== ===== =========== =====

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

@ -32,6 +32,8 @@ class RedditExtractor(Extractor):
match_user = RedditUserExtractor.pattern.match match_user = RedditUserExtractor.pattern.match
parentdir = self.config("parent-directory") parentdir = self.config("parent-directory")
videos = self.config("videos", True)
submissions = self.submissions() submissions = self.submissions()
visited = set() visited = set()
depth = 0 depth = 0
@ -52,11 +54,22 @@ class RedditExtractor(Extractor):
if url.startswith("https://i.redd.it/"): if url.startswith("https://i.redd.it/"):
text.nameext_from_url(url, submission) text.nameext_from_url(url, submission)
yield Message.Url, url, submission yield Message.Url, url, submission
elif submission["is_video"]: elif submission["is_video"]:
text.nameext_from_url(url, submission) if videos:
yield Message.Url, "ytdl:" + url, submission 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"]: elif not submission["is_self"]:
urls.append((url, submission)) urls.append((url, submission))
elif parentdir: elif parentdir:
yield Message.Directory, comments[0] yield Message.Directory, comments[0]

Loading…
Cancel
Save