[twitter] refactor extraction of TwitPic URLs

flattening
pull/3449/head
ClosedPort22 2 years ago
parent 3eb352fcb0
commit 38786a9593
No known key found for this signature in database

@ -220,13 +220,12 @@ class TwitterExtractor(Extractor):
def _extract_twitpic(self, tweet, files):
for url in tweet["entities"].get("urls", ()):
url = url["expanded_url"]
if "//twitpic.com/" in url and "/photos/" not in url:
response = self.request(
url.replace("http:", "https:", 1), fatal=False)
if response.status_code >= 400:
if "//twitpic.com/" not in url or "/photos/" in url:
continue
url = text.extr(
response.text, 'name="twitter:image" value="', '"')
resp = self.request(url.replace("http:", "https:", 1), fatal=False)
if resp.status_code >= 400:
continue
url = text.extr(resp.text, 'name="twitter:image" value="', '"')
if url:
files.append({"url": url})

Loading…
Cancel
Save