From c4aaa836f1a4db33c6ce55caebf297bc2ed28e0a Mon Sep 17 00:00:00 2001 From: TylerCG <117808427+TylerCG@users.noreply.github.com> Date: Fri, 25 Apr 2025 23:33:20 -0400 Subject: [PATCH] testing --- app/download.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ app/main.py | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/app/download.py b/app/download.py index 847cbfd..49e0d59 100644 --- a/app/download.py +++ b/app/download.py @@ -101,6 +101,68 @@ class dropout(): with yt_dlp.YoutubeDL(dl_opts) as ydl: ydl.download([entry['webpage_url']]) + def special(show, season, episode_start): + directory = f'/tv/{show}/Season {season}/' + if not os.path.exists(directory): + os.makedirs(directory) + + with open('/data/dropout.json', 'r') as json_file: + url_mapping = json.load(json_file) + url = next((item['URL'] for item in url_mapping if item['SHOW'] == show), None) + if url is None: + raise ValueError(f"Show '{show}' not found in the JSON data.") + + playlist_url = f'{url}/season:{season}' + + # Create match_filter + filter_pattern = ( + "title = " + r"'(?i).*behind.?the.?scenes.*" + r"|.*trailer.*" + r"|.*recap.*" + r"|.*last.looks.*'" + ) + match_filter = yt_dlp.utils.match_filter_func(filter_pattern) + + ydl_opts = { + 'quiet': True, + 'skip_download': True, + 'cookiefile': '/data/dropout.cookies.txt', + } + + # Step 1: Extract playlist info + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + playlist_info = ydl.extract_info(playlist_url, download=False) + + entries = playlist_info.get('entries', []) + filtered_entries = [] + for entry in entries: + if match_filter(entry) is None: # Not filtered out + filtered_entries.append(entry) + + # Step 2: Download filtered entries with corrected episode numbers + episode_start = int(episode_start) if episode_start else 1 + + for i, entry in enumerate(filtered_entries, start=episode_start): + episode_number = f"{i:02}" + filename_template = f"{show} - S{int(season):02}E{episode_number} - %(title)s.%(ext)s" + + dl_opts = { + 'format': 'bestvideo+bestaudio/best', + 'audio_quality': '256K', + 'paths': { + 'temp': '/temp', + 'home': directory + }, + 'cookiefile': '/data/dropout.cookies.txt', + 'writesubtitles': True, + 'subtitleslangs': ['en'], + 'outtmpl': filename_template, + } + + with yt_dlp.YoutubeDL(dl_opts) as ydl: + ydl.download([entry['webpage_url']]) + def series(): json_data=[] diff --git a/app/main.py b/app/main.py index f140460..0541944 100644 --- a/app/main.py +++ b/app/main.py @@ -37,7 +37,7 @@ async def dropoutDownload(show: str, season: str, episode: str = None): try: await loop.run_in_executor(None, partial(download.dropout.show,show,season,episode)) # download.dropout.show(show,season,episode) - return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloading."}) + return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."}) except Exception as e: return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})