test
This commit is contained in:
parent
4e30e636ea
commit
dbaab69775
@ -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']])
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user