Fixes
This commit is contained in:
parent
5dffde4a55
commit
082576061e
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
__pycache__
|
||||
.DS_Store
|
||||
data/*
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
dropout_cookies.txt
|
||||
@ -4,7 +4,8 @@ FROM python:3.11-slim
|
||||
# Install ffmpeg and other dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ffmpeg \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install yt_dlp
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
@ -13,7 +14,7 @@ ENV PYTHONUNBUFFERED=1
|
||||
# Set work directory
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /data /tv /youtube /asmr /nsfw /temp
|
||||
RUN mkdir /app/data /app/tv /app/youtube /app/asmr /app/nsfw /app/temp
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
|
||||
@ -56,7 +56,7 @@ class dropout():
|
||||
'temp': '/temp',
|
||||
'home': directory
|
||||
},
|
||||
'cookiefile': '/data/dropout_cookies.txt',
|
||||
'cookiefile': '/data/dropout.cookies.txt',
|
||||
'reject_title': [
|
||||
r'(?i).*behind.?the.?scenes.*', # Reject titles with "behind the scenes" (case-insensitive)
|
||||
r'(?i).*trailer.*', # Reject titles with "trailer" (case-insensitive)
|
||||
@ -100,7 +100,7 @@ class dropout():
|
||||
class youtube():
|
||||
def ydl(url, location):
|
||||
dl_ops = {'paths': {'temp': '/temp', 'home': location}, 'outtmpl': '%(uploader)s/%(title)s.%(ext)s'}
|
||||
if location == "/podcasts":
|
||||
if dl_ops['paths']['home'] == '/podcasts':
|
||||
dl_ops['format'] = 'bestaudio/best[ext=mp3]'
|
||||
dl_ops['postprocessors'] = [{
|
||||
'key': 'FFmpegExtractAudio',
|
||||
@ -110,7 +110,7 @@ class youtube():
|
||||
'key': 'FFmpegMetadata',
|
||||
'add_metadata': True,
|
||||
}]
|
||||
elif location == "/asmr":
|
||||
elif dl_ops['paths']['home'] == '/asmr':
|
||||
dl_ops['format'] = 'bestaudio/best[ext=mp3]'
|
||||
dl_ops['postprocessors'] = [{
|
||||
'key': 'FFmpegExtractAudio',
|
||||
@ -120,14 +120,42 @@ class youtube():
|
||||
'key': 'FFmpegMetadata',
|
||||
'add_metadata': True,
|
||||
}]
|
||||
elif location == "/nsfw":
|
||||
elif dl_ops['paths']['home'] == '/youtube':
|
||||
dl_ops['format'] = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best'
|
||||
dl_ops['cookiefile'] = '/data/youtube.cookies.txt'
|
||||
else:
|
||||
dl_ops['format'] = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best'
|
||||
|
||||
with yt_dlp.YoutubeDL(dl_ops) as ydl:
|
||||
ydl.download([url])
|
||||
# grab.thumbnail(ydl,url,location)
|
||||
|
||||
def downloadOptions(dl_ops):
|
||||
if dl_ops['paths']['home'] == "/podcasts":
|
||||
dl_ops['format'] = 'bestaudio/best[ext=mp3]'
|
||||
dl_ops['postprocessors'] = [{
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': 'mp3',
|
||||
'preferredquality': '192',
|
||||
}, {
|
||||
'key': 'FFmpegMetadata',
|
||||
'add_metadata': True,
|
||||
}]
|
||||
elif dl_ops['paths']['home'] == "/asmr":
|
||||
dl_ops['format'] = 'bestaudio/best[ext=mp3]'
|
||||
dl_ops['postprocessors'] = [{
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': 'mp3',
|
||||
'preferredquality': '192',
|
||||
}, {
|
||||
'key': 'FFmpegMetadata',
|
||||
'add_metadata': True,
|
||||
}]
|
||||
elif dl_ops['paths']['home'] == "/nsfw":
|
||||
dl_ops['format'] = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best'
|
||||
else:
|
||||
dl_ops = {
|
||||
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best',
|
||||
}
|
||||
|
||||
with yt_dlp.YoutubeDL(dl_ops) as ydl:
|
||||
ydl.download([url])
|
||||
# grab.thumbnail(ydl,url,location)
|
||||
return dl_ops
|
||||
13
app/main.py
13
app/main.py
@ -4,12 +4,14 @@ from fastapi.templating import Jinja2Templates
|
||||
# from fastapi.staticfiles import StaticFiles
|
||||
# from fastapi.concurrency import run_in_threadpool
|
||||
from pathlib import Path
|
||||
import json, download
|
||||
from functools import partial
|
||||
import json, download, asyncio
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# app.mount("/static", StaticFiles(directory="/app/app/static"), name="static")
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
|
||||
# api
|
||||
@ -33,7 +35,8 @@ async def dropoutSeries():
|
||||
@app.post("/dropoutDownload")
|
||||
async def dropoutDownload(show: str, season: str, episode: str = None):
|
||||
try:
|
||||
download.dropout.show(show,season,episode)
|
||||
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."})
|
||||
except Exception as e:
|
||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||
@ -41,8 +44,10 @@ async def dropoutDownload(show: str, season: str, episode: str = None):
|
||||
@app.post("/ydl")
|
||||
async def ydl(url: str, location: str):
|
||||
try:
|
||||
download.youtube.ydl(url,location)
|
||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Download completed."})
|
||||
await loop.run_in_executor(None, partial(download.youtube.ydl, url, location))
|
||||
# download.youtube.ydl(url,location)
|
||||
# grab.thumbnail(ydl,url,location)
|
||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Video download completed."})
|
||||
except Exception as e:
|
||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
# Netscape HTTP Cookie File
|
||||
# This file is generated by yt-dlp. Do not edit.
|
||||
|
||||
www.dropout.tv FALSE / FALSE 2376616194 locale_det en
|
||||
.dropout.tv TRUE / TRUE 1777000194 _session UElXTTdFemwzenp3RTZPQWx6clJwN3d4WlFkaEV0SXVrd2tnMUNUazJQVldOZEVlVTNOS0ZXS2twUmFHczBuMUlSZXVmTmZIeEFUeFZlajVLRVhrT0VVcm9XYU1jMUZQcTQwQUJNUUhtZ091NWZGS0kwYkMyNmZQelkxbll2QmxXYTFwZlJKNVlmdXFnZkcrVVdld3FCaFB4QnJGb2FLTWxyNlBnOFNCSkNLd1EvTS9OaE1nbTgrcjNmSmR6bE9YLS11M2pSa2VBLzZNZkozeXBXWGF4amhRPT0%3D--9ff14eeca357a6d7d1e8eb3496b039a01b2f92ab
|
||||
.www.dropout.tv TRUE / TRUE 1745465994 __cf_bm d9dI.ZmTB7AOvOULLAi6gzGen4gtP_wncSkUXNYGV18-1745464194-1.0.1.1-XU86MNGfB8sthsX_dgFr7z0XBFSuYt7yiI60jsNbL2WbD.SbKI57sVTLGBl8xYhDiD.bBN7pJRYJjKXKsn80n8C8RujDnn_55c_6rxwvcoo_pbexZbMpHbzcjc_SHxKH
|
||||
Loading…
x
Reference in New Issue
Block a user