From dbaab69775342d2c42759de7c5694ae3484c0190 Mon Sep 17 00:00:00 2001 From: TylerCG <117808427+TylerCG@users.noreply.github.com> Date: Mon, 12 May 2025 20:00:57 -0400 Subject: [PATCH] test --- app/download.py | 30 +++++++++++++++++++++++++----- app/main.py | 5 ++++- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/download.py b/app/download.py index a34f65f..f684d93 100644 --- a/app/download.py +++ b/app/download.py @@ -107,7 +107,31 @@ class grab(): print("Downloaded MP4 but no thumbnail found.") class dropout(): - def show(show, season, archive, episode_start): + def archive(show, season): + with open('/data/dropout.json', 'r') as json_file: + url_mapping = json.load(json_file) + + # Find the URL associated with the given show + 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.") + + # Set download options to skip the download and only write to the archive + dl_opts = { + 'quiet': True, + 'skip_download': True, + 'cookiefile': '/data/dropout.cookies.txt', + 'download_archive': '/data/logs/dropout.archive.log' + } + + # Assuming you are constructing a playlist URL for the season + playlist_url = f'{url}/season:{season}' + + # Process the URL and add to the archive without downloading + with yt_dlp.YoutubeDL(dl_opts) as ydl: + ydl.download([playlist_url]) # Pass a list containing the URL + + def show(show, season, episode_start=None): directory = f'/tv/{show}/Season {season}/' if not os.path.exists(directory): os.makedirs(directory) @@ -167,10 +191,6 @@ class dropout(): 'subtitleslangs': ['en'], 'outtmpl': filename_template, } - if archive: - dl_opts['skip_download'] = True - dl_opts.pop('writesubtitles', None) # Optional: don't write subtitles during archive - with yt_dlp.YoutubeDL(dl_opts) as ydl: ydl.download([entry['webpage_url']]) diff --git a/app/main.py b/app/main.py index 7737b50..9495975 100644 --- a/app/main.py +++ b/app/main.py @@ -162,7 +162,10 @@ async def dropout_download( logger.info(f"message={task_msg}") # Schedule the background task - background_tasks.add_task(download.dropout.show, show, season, archive, None) + if archive: + background_tasks.add_task(download.dropout.archive, show, season) + else: + background_tasks.add_task(download.dropout.show, show, season) return JSONResponse( status_code=200,