From 9e95b0bc88cf69963fb1f653552eea4500e44b25 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 24 Jun 2023 19:44:51 +0100 Subject: [PATCH] Fix for an odd edge case --- twitfix.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/twitfix.py b/twitfix.py index f5acdf3..d47831e 100644 --- a/twitfix.py +++ b/twitfix.py @@ -375,6 +375,17 @@ def link_to_vnf_from_unofficial_api(video_link): print(" ➤ [ + ] Attempting to download tweet info from UNOFFICIAL Twitter API") tweet = twExtract.extractStatus(video_link) print (" ➤ [ ✔ ] Unofficial API Success") + + if "extended_entities" not in tweet: + # check if any entities with urls ending in /video/XXX or /photo/XXX exist + if "entities" in tweet and "urls" in tweet["entities"]: + for url in tweet["entities"]["urls"]: + if "/video/" in url["expanded_url"] or "/photo/" in url["expanded_url"]: + subTweet = twExtract.extractStatus(url["expanded_url"]) + if "extended_entities" in subTweet: + tweet["extended_entities"] = subTweet["extended_entities"] + break + return link_to_vnf_from_tweet_data(tweet,video_link) def link_to_vnf(video_link): # Return a VideoInfo object or die trying