Check that video site has a path

merge-requests/30/head
Bob Mottram 2022-11-07 11:15:08 +00:00
parent cd442d1415
commit 903bedbf01
1 changed files with 36 additions and 31 deletions

View File

@ -63,6 +63,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('>vimeo.com/')[1]
if '<' in url:
url = url.split('<')[0]
if url:
content += \
"<center>\n<span itemprop=\"video\">\n" + \
"<iframe loading=\"lazy\" decoding=\"async\" " + \
@ -82,7 +83,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
if '/channel/' not in url and '/playlist' not in url:
if url and '/channel/' not in url and '/playlist' not in url:
url = url.replace('/watch?v=', '/embed/')
if '&' in url:
url = url.split('&')[0]
@ -104,7 +105,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
if '/channel/' not in url and '/playlist' not in url:
if url and '/channel/' not in url and '/playlist' not in url:
url = 'embed/' + url
if '&' in url:
url = url.split('&')[0]
@ -140,7 +141,10 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
if '"' + video_site in content:
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0].replace('/watch?v=', '/embed/')
url = url.split('"')[0]
if not url:
continue
url = url.replace('/watch?v=', '/embed/')
if '&' in url:
url = url.split('&')[0]
if '?utm_' in url:
@ -174,6 +178,7 @@ def _add_embedded_video_from_sites(translate: {}, content: str,
url = content.split('"' + video_site)[1]
if '"' in url:
url = url.split('"')[0]
if url:
video_site_settings = ''
if '#' in url:
video_site_settings = '#' + url.split('#', 1)[1]