From fe8b58a7b9f88f9d15ae2e95e4cd1894f79eaab1 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 28 Jun 2021 10:20:39 -0500 Subject: [PATCH] Include quoted tweets and retweets in audio detection and playback --- src/sessions/twitter/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sessions/twitter/utils.py b/src/sessions/twitter/utils.py index ce0ae47b..fc080bdf 100644 --- a/src/sessions/twitter/utils.py +++ b/src/sessions/twitter/utils.py @@ -41,9 +41,9 @@ def find_urls (tweet, twitter_media=False): if i["expanded_url"] not in urls: urls.append(i["expanded_url"]) if hasattr(tweet, "quoted_status"): - urls.extend(find_urls(tweet.quoted_status)) + urls.extend(find_urls(tweet.quoted_status, twitter_media)) if hasattr(tweet, "retweeted_status"): - urls.extend(find_urls(tweet.retweeted_status)) + urls.extend(find_urls(tweet.retweeted_status, twitter_media)) if hasattr(tweet, "message"): i = "message" elif hasattr(tweet, "full_text"): @@ -70,6 +70,14 @@ def find_list(name, lists): if lists[i].name == name: return lists[i].id def is_audio(tweet): + if hasattr(tweet, "quoted_status") and hasattr(tweet.quoted_status, "extended_entities"): + result = is_audio(tweet.quoted_status) + if result != None: + return result + if hasattr(tweet, "retweeted_status") and hasattr(tweet.retweeted_status, "extended_entities"): + result = is_audio(tweet.retweeted_status) + if result == True: + return result # Checks firstly for Twitter videos and audios. if hasattr(tweet, "extended_entities"): for mediaItem in tweet.extended_entities["media"]: