Merge pull request #7 from gunchleoc/support-video
Add support for video
This commit is contained in:
commit
765e398010
|
@ -12,14 +12,41 @@ def split_array(arr, size):
|
||||||
|
|
||||||
def try_to_get_carousel(array, post):
|
def try_to_get_carousel(array, post):
|
||||||
try:
|
try:
|
||||||
urls = list(map(lambda arr: arr['node']['display_url'], vars(post)['_node']['edge_sidecar_to_children']['edges']))
|
node = vars(post)['_node']
|
||||||
return urls
|
if 'edge_sidecar_to_children' in node:
|
||||||
print(Fore.GREEN + "🎠 > Found carousel!")
|
try:
|
||||||
print(Style.RESET_ALL)
|
urls = list(map(lambda arr: arr['node']['display_url'], node['edge_sidecar_to_children']['edges']))
|
||||||
print(datetime.datetime.now())
|
print(Fore.GREEN + "🎠 > Found carousel!")
|
||||||
|
print(Style.RESET_ALL)
|
||||||
|
print(datetime.datetime.now())
|
||||||
|
return urls
|
||||||
|
except Exception as e:
|
||||||
|
print(Fore.RED + "🎠💥 > No carousel :( \n", e)
|
||||||
|
print(Style.RESET_ALL)
|
||||||
|
print(datetime.datetime.now())
|
||||||
|
return array
|
||||||
|
else:
|
||||||
|
print(Fore.YELLOW + "🎠💥 > No carousel\n")
|
||||||
|
|
||||||
|
# We can also have video in a separate key
|
||||||
|
if 'is_video' in node and node ['is_video']:
|
||||||
|
try:
|
||||||
|
urls = [node['video_url']]
|
||||||
|
print(Fore.GREEN + "🎞 > Found video!")
|
||||||
|
print(Style.RESET_ALL)
|
||||||
|
print(datetime.datetime.now())
|
||||||
|
return urls
|
||||||
|
except Exception as e:
|
||||||
|
print(Fore.RED + "🎞💥 > No video :( \n", e)
|
||||||
|
print(Style.RESET_ALL)
|
||||||
|
print(datetime.datetime.now())
|
||||||
|
return array
|
||||||
|
else:
|
||||||
|
print(Fore.YELLOW + "🎠💥 > No video\n")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(Fore.RED + "🎠💥 > No carousel :( \n", e)
|
print(Fore.RED + "😱💥 > No node :( \n", e)
|
||||||
print(Style.RESET_ALL)
|
print(Style.RESET_ALL)
|
||||||
print(datetime.datetime.now())
|
print(datetime.datetime.now())
|
||||||
return array
|
return array
|
||||||
|
return array
|
||||||
|
|
Loading…
Reference in New Issue