Instagram2Fedi/src/converters.py

23 lines
612 B
Python
Raw Normal View History

2021-09-07 08:44:47 +00:00
from colorama import Fore, Back, Style
2021-09-06 08:39:24 +00:00
def split_array(arr, size):
count = len(arr) // size + 1
new_arr = []
for i in range(count):
new_arr.append(arr[i*size:(i+1)*size])
return new_arr
2021-09-07 08:44:47 +00:00
def try_to_get_carousel(array, post):
2021-09-06 08:39:24 +00:00
try:
urls = list(map(lambda arr: arr['node']['display_url'], vars(post)['_node']['edge_sidecar_to_children']['edges']))
return urls
2021-09-07 08:44:47 +00:00
print(Fore.GREEN + "🎠 > Found carousel!")
print(Style.RESET_ALL)
2021-09-06 08:39:24 +00:00
except:
2021-09-07 08:44:47 +00:00
print(Fore.RED + "🎠💥 > No carousel :( ")
print(Style.RESET_ALL)
return array
2021-09-06 08:39:24 +00:00
2021-09-07 08:44:47 +00:00