From a6be414129b6c2038d816883ac92c4ed7f3ba2ec Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 11 Jul 2025 18:36:19 +0100 Subject: [PATCH] Fix direct embeds redirecting to gif version (#281) --- twitfix.py | 2 +- utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/twitfix.py b/twitfix.py index d1356c4..59b153c 100644 --- a/twitfix.py +++ b/twitfix.py @@ -415,7 +415,7 @@ def twitfix(sub_path): embeddingMedia = tweetData['hasMedia'] renderMedia = None if embeddingMedia: - renderMedia = determineMediaToEmbed(tweetData,embedIndex) + renderMedia = determineMediaToEmbed(tweetData,embedIndex,convertGif=False) # direct embeds should always prioritize the main tweet, so don't check for qrt # determine what type of media we're dealing with if not embeddingMedia and qrt is None: diff --git a/utils.py b/utils.py index 483c63d..b3656f8 100644 --- a/utils.py +++ b/utils.py @@ -64,7 +64,7 @@ def determineEmbedTweet(tweetData): return tweetData['qrt'] return tweetData -def determineMediaToEmbed(tweetData,embedIndex = -1): +def determineMediaToEmbed(tweetData,embedIndex = -1,convertGif = True): if tweetData['allSameType'] and tweetData['media_extended'][0]['type'] == "image" and embedIndex == -1 and tweetData['combinedMediaUrl'] != None: return {"url":tweetData['combinedMediaUrl'],"type":"image"} else: @@ -82,7 +82,7 @@ def determineMediaToEmbed(tweetData,embedIndex = -1): if media['type'] == "image": return media elif media['type'] == "video" or media['type'] == "gif": - if media['type'] == "gif": + if media['type'] == "gif" and convertGif: if config['config']['gifConvertAPI'] != "" and config['config']['gifConvertAPI'] != "none": vurl=media['originalUrl'] if 'originalUrl' in media else media['url'] media['url'] = config['config']['gifConvertAPI'] + "/convert?url=" + vurl