diff --git a/files/helpers/actions.py b/files/helpers/actions.py index a02df00cf..c3ad00cc7 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -203,7 +203,7 @@ def execute_snappy(post, v): captured2 = [] for href, title in captured: - if not (href.startswith('/') or href.startswith(f'{SITE_FULL}/') or href.startswith(f'{SITE_FULL_IMAGES}/') or href.startswith('https://videos.watchpeopledie.tv/')): + if not any((href.startswith(x) for x in ('/', f'{SITE_FULL}/', f'{SITE_FULL_IMAGES}/', f'{SITE_FULL_VIDEOS}/'))): captured2.append((href, title)) if captured2: diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index e07381638..7ff472c90 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -61,22 +61,27 @@ PUSH_NOTIF_LIMIT = 1000 IS_LOCALHOST = SITE == "localhost" or SITE == "127.0.0.1" or SITE.startswith("192.168.") or SITE.endswith(".local") -if IS_LOCALHOST: - SITE_FULL = 'http://' + SITE - SITE_IMAGES = SITE - SITE_FULL_IMAGES = f'http://{SITE_IMAGES}' -elif SITE in {'rdrama.net', 'watchpeopledie.tv'}: - SITE_FULL = 'https://' + SITE +if SITE in {'rdrama.net', 'watchpeopledie.tv'}: SITE_IMAGES = 'i.' + SITE - SITE_FULL_IMAGES = f'https://{SITE_IMAGES}' -else: - SITE_FULL = 'https://' + SITE - SITE_IMAGES = SITE - SITE_FULL_IMAGES = SITE_FULL - -if SITE == 'staging.rdrama.net': +elif SITE == 'staging.rdrama.net': SITE_IMAGES = 'i.rdrama.net' +else: + SITE_IMAGES = SITE + +if SITE == 'watchpeopledie.tv': + SITE_VIDEOS = 'videos.watchpeopledie.tv' +else: + SITE_VIDEOS = f'{SITE}/videos' + +if IS_LOCALHOST: + SITE_FULL = f'http://{SITE}' + SITE_FULL_IMAGES = f'http://{SITE_IMAGES}' + SITE_FULL_VIDEOS = f'http://{SITE_VIDEOS}' +else: + SITE_FULL = f'https://{SITE}' SITE_FULL_IMAGES = f'https://{SITE_IMAGES}' + SITE_FULL_VIDEOS = f'https://{SITE_VIDEOS}' + if SITE == 'rdrama.net': OTHER_SITE_NAME = 'WPD' @@ -884,8 +889,10 @@ approved_embed_hosts = [ ### First-Party 'rdrama.net', 'i.rdrama.net', - 'staging.rdrama.net', + 'watchpeopledie.tv', + 'i.watchpeopledie.tv', 'videos.watchpeopledie.tv', + 'staging.rdrama.net', ### Third-Party Image Hosts 'i.imgur.com', @@ -930,11 +937,9 @@ approved_embed_hosts = [ 'i.ytimg.com/vi', ] -if SITE_IMAGES not in approved_embed_hosts: - approved_embed_hosts = [SITE_IMAGES] + approved_embed_hosts - -if SITE not in approved_embed_hosts: - approved_embed_hosts = [SITE] + approved_embed_hosts +for i in (SITE_VIDEOS, SITE_IMAGES, SITE): + if i not in approved_embed_hosts: + approved_embed_hosts = [i] + approved_embed_hosts def is_site_url(url): return (url diff --git a/files/helpers/media.py b/files/helpers/media.py index 0a54c08df..c160b9888 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -153,10 +153,8 @@ def reencode_video(old, new, check_sizes=False): if SITE == 'watchpeopledie.tv': rclone_copy(new) - url = f'https://videos.{SITE}' + new.split('/videos')[1] - else: - url = f"{SITE_FULL}{new}" + url = SITE_FULL_VIDEOS + new.split('/videos')[1] purge_files_in_cloudflare_cache(url) @@ -211,20 +209,20 @@ def process_video(file, v): ) g.db.add(media) + url = SITE_FULL_VIDEOS + new.split('/videos')[1] + if SITE == 'watchpeopledie.tv' and v and v.username.lower().startswith("icosaka"): - gevent.spawn(delete_file, new, f'https://videos.{SITE}' + new.split('/videos')[1]) - return f'https://videos.{SITE}' + new.split('/videos')[1], None, None + gevent.spawn(delete_file, new, url) + return url, None, None name = f'/images/{time.time()}'.replace('.','') + '.webp' ffmpeg.input(new).output(name, loglevel="quiet", map_metadata=-1, **{"vf":"scale='iw':-2", 'q:v':3, 'frames:v':1}).run() posterurl = SITE_FULL_IMAGES + name - if SITE == 'watchpeopledie.tv': - if not is_reencoding: - gevent.spawn(rclone_copy, new) - return f'https://videos.{SITE}' + new.split('/videos')[1], posterurl, name - else: - return f"{SITE_FULL}{new}", posterurl, name + if SITE == 'watchpeopledie.tv' and not is_reencoding: + gevent.spawn(rclone_copy, new) + + return url, posterurl, name def process_image(filename, v, resize=0, trim=False, uploader_id=None): # thumbnails are processed in a thread and not in the request context diff --git a/files/routes/admin.py b/files/routes/admin.py index 94515b66d..0aafeadc7 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -1888,8 +1888,8 @@ def delete_media_post(v): purge_files_in_cloudflare_cache(url) - if url.startswith('https://videos.watchpeopledie.tv/'): - filename = url.split('https://videos.watchpeopledie.tv/')[1] + if SITE == 'watchpeopledie.tv' and url.startswith(SITE_FULL_VIDEOS): + filename = url.split(SITE_FULL_VIDEOS)[1] gevent.spawn(rclone.delete, f'no:/videos/{filename}') return {"message": "Media deleted successfully!"}