add SITE_FULL_VIDEOS in preparation for next commit

master
Aevann 2024-04-07 07:12:06 +02:00
parent e5ae5c80b2
commit 9d50b43e8a
4 changed files with 36 additions and 33 deletions

View File

@ -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:

View File

@ -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

View File

@ -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:
if SITE == 'watchpeopledie.tv' and 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
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

View File

@ -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!"}