Fix direct embeds redirecting to gif version (#281)

This commit is contained in:
Dylan
2025-07-11 18:36:19 +01:00
parent cd39216891
commit a6be414129
2 changed files with 3 additions and 3 deletions

View File

@@ -415,7 +415,7 @@ def twitfix(sub_path):
embeddingMedia = tweetData['hasMedia'] embeddingMedia = tweetData['hasMedia']
renderMedia = None renderMedia = None
if embeddingMedia: 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 # direct embeds should always prioritize the main tweet, so don't check for qrt
# determine what type of media we're dealing with # determine what type of media we're dealing with
if not embeddingMedia and qrt is None: if not embeddingMedia and qrt is None:

View File

@@ -64,7 +64,7 @@ def determineEmbedTweet(tweetData):
return tweetData['qrt'] return tweetData['qrt']
return tweetData 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: if tweetData['allSameType'] and tweetData['media_extended'][0]['type'] == "image" and embedIndex == -1 and tweetData['combinedMediaUrl'] != None:
return {"url":tweetData['combinedMediaUrl'],"type":"image"} return {"url":tweetData['combinedMediaUrl'],"type":"image"}
else: else:
@@ -82,7 +82,7 @@ def determineMediaToEmbed(tweetData,embedIndex = -1):
if media['type'] == "image": if media['type'] == "image":
return media return media
elif media['type'] == "video" or media['type'] == "gif": 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": if config['config']['gifConvertAPI'] != "" and config['config']['gifConvertAPI'] != "none":
vurl=media['originalUrl'] if 'originalUrl' in media else media['url'] vurl=media['originalUrl'] if 'originalUrl' in media else media['url']
media['url'] = config['config']['gifConvertAPI'] + "/convert?url=" + vurl media['url'] = config['config']['gifConvertAPI'] + "/convert?url=" + vurl