added custom download
This commit is contained in:
parent
9e1c32a123
commit
6b32f18ad5
@ -88,7 +88,6 @@ class grab():
|
|||||||
|
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
|
|
||||||
def thumbnail(ydl,url,location):
|
def thumbnail(ydl,url,location):
|
||||||
# Extracting video information
|
# Extracting video information
|
||||||
video_info = ydl.extract_info(url, download=False)
|
video_info = ydl.extract_info(url, download=False)
|
||||||
@ -134,6 +133,28 @@ class dropout():
|
|||||||
with ArchiveOnlyYDL(dl_opts) as ydl:
|
with ArchiveOnlyYDL(dl_opts) as ydl:
|
||||||
ydl.download([playlist_url])
|
ydl.download([playlist_url])
|
||||||
|
|
||||||
|
def custom(url, directory, prefix):
|
||||||
|
filename_template = f"{prefix}%(title)s.%(ext)s" if prefix else "%(title)s.%(ext)s"
|
||||||
|
|
||||||
|
dl_opts = {
|
||||||
|
'progress_hooks': [my_hook],
|
||||||
|
'download_archive': '/data/logs/dropout.archive.log',
|
||||||
|
'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([url] if isinstance(url, str) else url)
|
||||||
|
|
||||||
|
|
||||||
def show(show, season, specials=False, episode_start=None):
|
def show(show, season, specials=False, episode_start=None):
|
||||||
season_str = f"{int(season):02}" if not specials else "00"
|
season_str = f"{int(season):02}" if not specials else "00"
|
||||||
directory = f"/tv/{show}/{'Specials' if specials else f'Season {season}'}"
|
directory = f"/tv/{show}/{'Specials' if specials else f'Season {season}'}"
|
||||||
@ -196,7 +217,6 @@ class dropout():
|
|||||||
with yt_dlp.YoutubeDL(dl_opts) as ydl:
|
with yt_dlp.YoutubeDL(dl_opts) as ydl:
|
||||||
ydl.download([entry['webpage_url']])
|
ydl.download([entry['webpage_url']])
|
||||||
|
|
||||||
|
|
||||||
def series(force_download):
|
def series(force_download):
|
||||||
json_data=[]
|
json_data=[]
|
||||||
html=requests.get('https://www.dropout.tv/series').text
|
html=requests.get('https://www.dropout.tv/series').text
|
||||||
|
|||||||
53
app/main.py
53
app/main.py
@ -23,8 +23,8 @@ logger.handlers = []
|
|||||||
handler = TimedRotatingFileHandler(
|
handler = TimedRotatingFileHandler(
|
||||||
filename="/data/logs/syllabus.log",
|
filename="/data/logs/syllabus.log",
|
||||||
when="midnight", # Rotate at midnight
|
when="midnight", # Rotate at midnight
|
||||||
interval=1, # Every 1 day
|
interval=30, # Every 30 day
|
||||||
backupCount=30, # Keep last 7 logs
|
backupCount=12, # Keep last 7 logs
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
utc=False # Use UTC for time reference
|
utc=False # Use UTC for time reference
|
||||||
)
|
)
|
||||||
@ -68,18 +68,19 @@ async def log_requests(request: Request, call_next):
|
|||||||
|
|
||||||
|
|
||||||
# api
|
# api
|
||||||
@app.post("/ebook/download", description="Download an ebook via a url.")
|
|
||||||
async def ebookDownload(
|
# @app.post("/ebook/download", description="Download an ebook via a url.")
|
||||||
background_tasks: BackgroundTasks,
|
# async def ebookDownload(
|
||||||
url: str = Form(...),
|
# background_tasks: BackgroundTasks,
|
||||||
author: str = Form(...)
|
# url: str = Form(...),
|
||||||
):
|
# author: str = Form(...)
|
||||||
try:
|
# ):
|
||||||
background_tasks.add_task(download.ebook,url,author)
|
# try:
|
||||||
# download.dropout.show(show,season,episode)
|
# background_tasks.add_task(download.ebook,url,author)
|
||||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Book downloaded."})
|
# # download.dropout.show(show,season,episode)
|
||||||
except Exception as e:
|
# return JSONResponse(status_code=200, content={"status": "success", "message": "Book downloaded."})
|
||||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
# except Exception as e:
|
||||||
|
# return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||||
|
|
||||||
@app.get("/dropout/update")
|
@app.get("/dropout/update")
|
||||||
async def dropoutUpdate(force: bool = False):
|
async def dropoutUpdate(force: bool = False):
|
||||||
@ -125,12 +126,28 @@ def get_latest_season(item):
|
|||||||
logging.error(f"Error getting latest season: {e}")
|
logging.error(f"Error getting latest season: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@app.post("/dropout/custom", description="")
|
||||||
|
async def dropout_download(
|
||||||
|
background_tasks: BackgroundTasks,
|
||||||
|
url: str = Form(...),
|
||||||
|
directory: Optional[int] = Form(None),
|
||||||
|
prefix: Optional[str] = Form(None)
|
||||||
|
):
|
||||||
|
# Ensure output directory exists
|
||||||
|
os.makedirs(directory, exist_ok=True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
background_tasks.add_task(download.dropout.custom, url, directory, prefix)
|
||||||
|
return {"status": "success", "message": "Download started"}
|
||||||
|
except Exception as e:
|
||||||
|
raise JSONResponse(status_code=500, content=f"Download failed: {str(e)}")
|
||||||
|
|
||||||
@app.post("/dropout/download", description="Download an entire season from episode 1. Ignores behind the scenes and trailers.")
|
@app.post("/dropout/download", description="Download an entire season from episode 1. Ignores behind the scenes and trailers.")
|
||||||
async def dropout_download(
|
async def dropout_download(
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
show: str = Form(...),
|
show: str = Form(...),
|
||||||
season: Optional[int] = Form(None),
|
season: Optional[int] = Form(None),
|
||||||
latest: bool = Form(False),
|
latest: bool = Form(True),
|
||||||
archive: bool = Form(False),
|
archive: bool = Form(False),
|
||||||
specials: bool = Form(False),
|
specials: bool = Form(False),
|
||||||
episode_start: Optional[int] = Form(None)
|
episode_start: Optional[int] = Form(None)
|
||||||
@ -172,11 +189,7 @@ async def dropout_download(
|
|||||||
status_code=200,
|
status_code=200,
|
||||||
content={
|
content={
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": (
|
"message": (task_msg)
|
||||||
f"Series is being added to the completed archive for '{show}', season {season}."
|
|
||||||
if archive else
|
|
||||||
f"Series download started for '{show}', season {season}{' specials' if specials else ''}."
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user