mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
a68c12d530
commit
23b20a8a58
28
utils.py
28
utils.py
|
@ -4677,3 +4677,31 @@ def corp_servers() -> ():
|
||||||
"""
|
"""
|
||||||
return ('GitHub.com', 'github.com', 'cloudflare', 'microsoft.com',
|
return ('GitHub.com', 'github.com', 'cloudflare', 'microsoft.com',
|
||||||
'google.com')
|
'google.com')
|
||||||
|
|
||||||
|
|
||||||
|
def get_media_url_from_video(post_json_object: {}) -> (str, str, str, str):
|
||||||
|
"""Within a Video post (eg peertube) return the media details
|
||||||
|
"""
|
||||||
|
media_type = None
|
||||||
|
media_url = None
|
||||||
|
media_torrent = None
|
||||||
|
media_magnet = None
|
||||||
|
if isinstance(post_json_object['url'], list):
|
||||||
|
for media_link in post_json_object['url']:
|
||||||
|
if not isinstance(media_link, dict):
|
||||||
|
continue
|
||||||
|
if not media_link.get('mediaType'):
|
||||||
|
continue
|
||||||
|
if not media_link.get('href'):
|
||||||
|
continue
|
||||||
|
if media_link['mediaType'] == 'application/x-bittorrent':
|
||||||
|
media_torrent = remove_html(media_link['href'])
|
||||||
|
if media_link['href'].startswith('magnet:'):
|
||||||
|
media_magnet = remove_html(media_link['href'])
|
||||||
|
if media_link['mediaType'] != 'video/mp4' and \
|
||||||
|
media_link['mediaType'] != 'video/ogv':
|
||||||
|
continue
|
||||||
|
if not media_url:
|
||||||
|
media_type = media_link['mediaType']
|
||||||
|
media_url = remove_html(media_link['href'])
|
||||||
|
return media_type, media_url, media_torrent, media_magnet
|
||||||
|
|
24
video.py
24
video.py
|
@ -16,6 +16,7 @@ from utils import get_attributed_to
|
||||||
from utils import get_content_from_post
|
from utils import get_content_from_post
|
||||||
from utils import dangerous_markup
|
from utils import dangerous_markup
|
||||||
from utils import license_link_from_name
|
from utils import license_link_from_name
|
||||||
|
from utils import get_media_url_from_video
|
||||||
from blocking import is_blocked
|
from blocking import is_blocked
|
||||||
from filters import is_filtered
|
from filters import is_filtered
|
||||||
|
|
||||||
|
@ -91,27 +92,8 @@ def convert_video_to_note(base_dir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
conversation_id = remove_id_ending(post_json_object['id'])
|
conversation_id = remove_id_ending(post_json_object['id'])
|
||||||
|
|
||||||
media_type = None
|
media_type, media_url, media_torrent, media_magnet = \
|
||||||
media_url = None
|
get_media_url_from_video(post_json_object)
|
||||||
media_torrent = None
|
|
||||||
media_magnet = None
|
|
||||||
for media_link in post_json_object['url']:
|
|
||||||
if not isinstance(media_link, dict):
|
|
||||||
continue
|
|
||||||
if not media_link.get('mediaType'):
|
|
||||||
continue
|
|
||||||
if not media_link.get('href'):
|
|
||||||
continue
|
|
||||||
if media_link['mediaType'] == 'application/x-bittorrent':
|
|
||||||
media_torrent = remove_html(media_link['href'])
|
|
||||||
if media_link['href'].startswith('magnet:'):
|
|
||||||
media_magnet = remove_html(media_link['href'])
|
|
||||||
if media_link['mediaType'] != 'video/mp4' and \
|
|
||||||
media_link['mediaType'] != 'video/ogv':
|
|
||||||
continue
|
|
||||||
if not media_url:
|
|
||||||
media_type = media_link['mediaType']
|
|
||||||
media_url = remove_html(media_link['href'])
|
|
||||||
|
|
||||||
if not media_url:
|
if not media_url:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue