Fix small issue with card logic
This commit is contained in:
10
vxApi.py
10
vxApi.py
@@ -124,11 +124,17 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
|
|||||||
for i in tweetL["entities"]["hashtags"]:
|
for i in tweetL["entities"]["hashtags"]:
|
||||||
hashtags.append(i["text"])
|
hashtags.append(i["text"])
|
||||||
elif "card" in tweet:
|
elif "card" in tweet:
|
||||||
|
bindingValues = None
|
||||||
|
if 'binding_values' in tweet['card']:
|
||||||
|
bindingValues = tweet['card']['binding_values']
|
||||||
|
elif 'legacy' in tweet['card'] and 'binding_values' in tweet['card']['legacy']:
|
||||||
|
bindingValues = tweet['card']['legacy']['binding_values']
|
||||||
|
if bindingValues != None:
|
||||||
if 'name' in tweet['card'] and tweet['card']['name'] == "player":
|
if 'name' in tweet['card'] and tweet['card']['name'] == "player":
|
||||||
width = None
|
width = None
|
||||||
height = None
|
height = None
|
||||||
vidUrl = None
|
vidUrl = None
|
||||||
for i in tweet['card']['binding_values']:
|
for i in bindingValues:
|
||||||
if i['key'] == 'player_stream_url':
|
if i['key'] == 'player_stream_url':
|
||||||
vidUrl = i['value']['string_value']
|
vidUrl = i['value']['string_value']
|
||||||
elif i['key'] == 'player_width':
|
elif i['key'] == 'player_width':
|
||||||
@@ -139,7 +145,7 @@ def getApiResponse(tweet,include_txt=False,include_rtf=False):
|
|||||||
media.append(vidUrl)
|
media.append(vidUrl)
|
||||||
media_extended.append({"url":vidUrl,"type":"video","size":{"width":width,"height":height}})
|
media_extended.append({"url":vidUrl,"type":"video","size":{"width":width,"height":height}})
|
||||||
else:
|
else:
|
||||||
for i in tweet['card']['binding_values']:
|
for i in bindingValues:
|
||||||
if i['key'] == 'unified_card' and 'value' in i and 'string_value' in i['value']:
|
if i['key'] == 'unified_card' and 'value' in i and 'string_value' in i['value']:
|
||||||
card = json.loads(i['value']['string_value'])
|
card = json.loads(i['value']['string_value'])
|
||||||
media_key = card['component_objects']['media_1']['data']['id']
|
media_key = card['component_objects']['media_1']['data']['id']
|
||||||
|
|||||||
Reference in New Issue
Block a user