fixed thumbnails

This commit is contained in:
root 2023-05-20 16:55:24 +02:00
parent 31b09b1ca3
commit 5ef903010c
3 changed files with 15 additions and 10 deletions

View File

@ -1,2 +1,4 @@
# UnusualVideos
https://www.youtube.com/channel/UCpnkp_D4FLPCiXOmDhoAeYA
# UUM Archive
https://www.youtube.com/@unusualvideos_archive

View File

@ -4,9 +4,10 @@
# Archive Settings
--download-archive yt-dlp-archive.txt
-a yt-dlp-channels.txt
-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
--write-description
#-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'
--write-thumbnail
--skip-download
--restrict-filenames
# Debug
-v

View File

@ -4,6 +4,7 @@ import sys
import fnmatch
from datetime import datetime
sys.path.append('./')
os.environ['DJANGO_SETTINGS_MODULE'] = 'ragnarok.settings'
import django
@ -35,8 +36,8 @@ def find_image_file(name_pattern, folder):
return os.path.join(root, filename)
return None
for filename in os.listdir(folder_path):
files = os.listdir(folder_path)
for filename in files:
if filename.endswith('.mp4'):
# Create a new Video object
video = Video()
@ -53,11 +54,12 @@ for filename in os.listdir(folder_path):
# Open the file and save it to the Video object
with open(os.path.join(folder_path, filename), 'rb') as f:
video.file.save(filename, f)
#filepath = find_image_file("V"+str(id), folder_path)
with open(filepath, 'rb') as f:
video.thumbnail.save(filename, f)
index = [idx for idx, s in enumerate(files) if bool(re.search('V'+str(video.id)+'( |_)', s)) and '.webp' in s]
if not index:
continue
index = index[0]
with open(os.path.join(folder_path, files[index]), 'rb') as f:
video.thumbnail.save(files[index], f)
# Save the Video object to the database
video.save()