Check that url exists

main
Bob Mottram 2023-10-31 19:20:50 +00:00
parent 7fe094c540
commit 377754c95b
1 changed files with 21 additions and 18 deletions

View File

@ -4686,22 +4686,25 @@ def get_media_url_from_video(post_json_object: {}) -> (str, str, str, str):
media_url = None media_url = None
media_torrent = None media_torrent = None
media_magnet = None media_magnet = None
if isinstance(post_json_object['url'], list): if post_json_object.get('url'):
for media_link in post_json_object['url']: if isinstance(post_json_object['url'], list):
if not isinstance(media_link, dict): for media_link in post_json_object['url']:
continue if not isinstance(media_link, dict):
if not media_link.get('mediaType'): continue
continue if not media_link.get('mediaType'):
if not media_link.get('href'): continue
continue if not media_link.get('href'):
if media_link['mediaType'] == 'application/x-bittorrent': continue
media_torrent = remove_html(media_link['href']) if media_link['mediaType'] == 'application/x-bittorrent':
if media_link['href'].startswith('magnet:'): media_torrent = remove_html(media_link['href'])
media_magnet = remove_html(media_link['href']) if media_link['href'].startswith('magnet:'):
if media_link['mediaType'] != 'video/mp4' and \ media_magnet = remove_html(media_link['href'])
media_link['mediaType'] != 'video/ogv': if media_link['mediaType'] != 'video/mp4' and \
continue media_link['mediaType'] != 'video/ogv':
if not media_url: continue
media_type = media_link['mediaType'] if not media_url:
media_url = remove_html(media_link['href']) media_type = media_link['mediaType']
media_url = remove_html(media_link['href'])
else:
print('WARN: video url does not exist ' + str(post_json_object))
return media_type, media_url, media_torrent, media_magnet return media_type, media_url, media_torrent, media_magnet