import os import yt_dlp class download(): def dropout(show,season,episode): directory='/mnt/plex/tv/'+show+'/Season '+season+'/' url_mapping={ 'Dimension 20':f'https://www.dropout.tv/dimension-20/season:{season}', 'Make Some Noise':f'https://www.dropout.tv/make-some-noise/season:{season}' } url = url_mapping.get(show) if not os.path.exists(directory): os.makedirs(directory) if episode is None or episode == '': episode = '%(playlist_index)02d' else: try: dl_ops['playliststart'] = int(episode) except ValueError: # Handle the error, e.g., log it or set a default value dl_ops['playliststart'] = 0 # or some appropriate default value dl_ops = {'format': 'bestvideo+bestaudio/best', 'audio_quality': '256K', 'paths': {'temp': '/mnt/data/downloader/temp', 'home': directory},'cookiefile': 'cookies.txt','reject_title': ['Behind The Scenes', 'Trailer', 'Recap'], 'outtmpl': show + ' - S'+season+'E'+episode+' - %(title)s.%(ext)s'} with yt_dlp.YoutubeDL(dl_ops) as ydl: ydl.download(url) # def ydl(self, url, location): # dl_ops = {'paths': {'temp': '/mnt/data/downloader/temp', 'home': location}, 'outtmpl': '%(uploader)s/%(title)s.%(ext)s'} # if location == "/mnt/plex/music/podcast": # dl_ops['format'] = 'bestaudio/best[ext=mp3]' # dl_ops['postprocessors'] = [{ # 'key': 'FFmpegExtractAudio', # 'preferredcodec': 'mp3', # 'preferredquality': '192', # }, { # 'key': 'FFmpegMetadata', # 'add_metadata': True, # }] # elif location == "/mnt/plex/music/asmr": # dl_ops['format'] = 'bestaudio/best[ext=mp3]' # dl_ops['postprocessors'] = [{ # 'key': 'FFmpegExtractAudio', # 'preferredcodec': 'mp3', # 'preferredquality': '192', # }, { # 'key': 'FFmpegMetadata', # 'add_metadata': True, # }] # else: # dl_ops['format'] = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best' # with yt_dlp.YoutubeDL(dl_ops) as ydl: # ydl.download(url)