testing
This commit is contained in:
parent
cbfbee1fdf
commit
c4aaa836f1
@ -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=[]
|
||||
|
||||
@ -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)})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user