mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 02:32:33 +01:00
[twitter] extend 'videos' option to force extraction with ytdl
(closes #459)
This commit is contained in:
parent
f8ac67ce50
commit
c01ff78467
@ -1029,9 +1029,15 @@ Description Extract images from retweets.
|
||||
extractor.twitter.videos
|
||||
------------------------
|
||||
=========== =====
|
||||
Type ``bool``
|
||||
Type ``bool`` or ``string``
|
||||
Default ``false``
|
||||
Description Use `youtube-dl`_ to download from video tweets.
|
||||
Description Control video download behavior.
|
||||
|
||||
* ``true``: Download videos and use `youtube-dl`_ to handle
|
||||
HLS ``.m3u8`` manifests
|
||||
* ``"ytdl"``: Download videos and let `youtube-dl`_ handle all of
|
||||
video extraction and download
|
||||
* ``false``: Skip video Tweets
|
||||
=========== =====
|
||||
|
||||
|
||||
|
@ -54,17 +54,20 @@ class TwitterExtractor(Extractor):
|
||||
yield Message.Urllist, urls, data
|
||||
|
||||
if self.videos and "-videoContainer" in tweet:
|
||||
url = self._video_from_tweet(data["tweet_id"])
|
||||
ext = text.ext_from_url(url)
|
||||
|
||||
if ext == "m3u8":
|
||||
url = "ytdl:" + url
|
||||
data["extension"] = "mp4"
|
||||
data["_ytdl_extra"] = {"protocol": "m3u8_native"}
|
||||
if self.videos == "ytdl":
|
||||
data["extension"] = None
|
||||
url = "ytdl:{}/{}/status/{}".format(
|
||||
self.root, data["user"], data["tweet_id"])
|
||||
else:
|
||||
data["extension"] = ext
|
||||
url = self._video_from_tweet(data["tweet_id"])
|
||||
ext = text.ext_from_url(url)
|
||||
if ext == "m3u8":
|
||||
url = "ytdl:" + url
|
||||
data["extension"] = "mp4"
|
||||
data["_ytdl_extra"] = {"protocol": "m3u8_native"}
|
||||
else:
|
||||
data["extension"] = ext
|
||||
data["num"] = 1
|
||||
|
||||
yield Message.Url, url, data
|
||||
|
||||
def metadata(self):
|
||||
@ -279,8 +282,8 @@ class TwitterTweetExtractor(TwitterExtractor):
|
||||
}),
|
||||
# Reply to another tweet (#403)
|
||||
("https://twitter.com/tyson_hesse/status/1103767554424598528", {
|
||||
"options": (("videos", True),),
|
||||
"pattern": r"ytdl:https://video.twimg.com/ext_tw_video/.*.m3u8",
|
||||
"options": (("videos", "ytdl"),),
|
||||
"pattern": r"ytdl:https://twitter.com/.+/1103767554424598528",
|
||||
}),
|
||||
# /i/web/ URL
|
||||
("https://twitter.com/i/web/status/1155074198240292865", {
|
||||
|
Loading…
Reference in New Issue
Block a user