Skip to content

Commit

Permalink
[twitter] handle quoted tweets (#526)
Browse files Browse the repository at this point in the history
… and categorize them as retweets
  • Loading branch information
mikf committed Jan 4, 2020
1 parent 0b4cb8e commit 5532e9c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ def _data_from_tweet(self, tweet):
cl, _, cr = content.rpartition("pic.twitter.com/")
data["content"] = cl if cl and len(cr) < 16 else content

if extr('<div class="QuoteTweet', '>'):
data["retweet_id"] = text.parse_int(extr('data-item-id="', '"'))
data["retweeter"] = data["user"]["name"]
data["author"] = {
"name" : extr('data-screen-name="', '"'),
"id" : text.parse_int(extr('data-user-id="' , '"')),
"nick" : text.unescape(extr(
'QuoteTweet-fullname', '<').partition('>')[2]),
}

return data

def _video_from_tweet(self, tweet_id):
Expand Down Expand Up @@ -319,6 +329,11 @@ class TwitterTweetExtractor(TwitterExtractor):
("https://twitter.com/i/web/status/1155074198240292865", {
"pattern": r"https://pbs.twimg.com/media/EAel0vUUYAAZ4Bq.jpg:orig",
}),
# quoted tweet (#526)
("https://twitter.com/Meiyu_miu/status/1070693241413021696", {
"count": 4,
"keyword": "0c627af2b8cdccc7e0da8fd221155c4a4a3141a8",
}),
)

def __init__(self, match):
Expand Down

0 comments on commit 5532e9c

Please sign in to comment.