Merge branch 'main' into 'main'

Fixed MP4 and MP3 Video/Audio Sorting

See merge request mrpvtdagger/oki.cx-youtube-converter!1
This commit is contained in:
Dagger 2022-08-19 03:14:24 +00:00
commit 57abfbdfea

View File

@ -8,15 +8,11 @@ def convert_video(link, media_format):
return ''.join(random.choice(chars) for _ in range(size))
rand_filename = f"{randmname(25)}.{media_format.lower()}"
stream_filter = ""
if media_format == "mp4":
stream_filter = "progressive=True, file_extension=mp4"
elif media_format == "mp3":
stream_filter = "only_audio=True"
yt = YouTube(link)
yt.streams.filter(stream_filter).order_by('resolution').desc().first().download(filename=rand_filename, output_path="files/ytdl")
if media_format == "MP4":
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download(filename=rand_filename, output_path="files/ytdl")
elif media_format == "MP3":
yt.streams.filter(only_audio=True).first().download(filename=rand_filename, output_path="files/ytdl")
cdn_url = {
"url": f"https://cdn.oki.cx/files/ytdl/{rand_filename}",