Support for player cards (i.e Vine), Fixes #234

This commit is contained in:
Dylan
2024-09-13 16:40:14 +01:00
parent 73edc9ebab
commit 93960b39da
4 changed files with 24 additions and 6 deletions

View File

@ -81,6 +81,20 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
if "hashtags" in tweetL["entities"]:
for i in tweetL["entities"]["hashtags"]:
hashtags.append(i["text"])
elif "card" in tweet and tweet['card']['name'] == "player":
width = None
height = None
vidUrl = None
for i in tweet['card']['binding_values']:
if i['key'] == 'player_stream_url':
vidUrl = i['value']['string_value']
elif i['key'] == 'player_width':
width = int(i['value']['string_value'])
elif i['key'] == 'player_height':
height = int(i['value']['string_value'])
if vidUrl != None and width != None and height != None:
media.append(vidUrl)
media_extended.append({"url":vidUrl,"type":"video","size":{"width":width,"height":height}})
#include_txt = request.args.get("include_txt", "false")
#include_rtf = request.args.get("include_rtf", "false") # for certain types of archival software (i.e Hydrus)