fixed downloading
This commit is contained in:
parent
546e6ea3bb
commit
153a4eb555
@ -1,6 +1,4 @@
|
|||||||
import os, yt_dlp, json, requests, re, time
|
import os, yt_dlp, json, requests, re
|
||||||
from selenium import webdriver
|
|
||||||
from selenium.webdriver.common.keys import Keys
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
@ -178,13 +176,6 @@ class dropout():
|
|||||||
|
|
||||||
def series():
|
def series():
|
||||||
json_data=[]
|
json_data=[]
|
||||||
# driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
|
|
||||||
# driver.get('https://www.dropout.tv/series')
|
|
||||||
# for _ in range(5): # Adjust the range as needed
|
|
||||||
# driver.find_element_by_tag_name('body').send_keys(Keys.END)
|
|
||||||
# time.sleep(2) # Wait for new content to load
|
|
||||||
# html = driver.page_source
|
|
||||||
|
|
||||||
html=requests.get('https://www.dropout.tv/series').text
|
html=requests.get('https://www.dropout.tv/series').text
|
||||||
|
|
||||||
# If you want to parse the HTML
|
# If you want to parse the HTML
|
||||||
|
|||||||
18
app/main.py
18
app/main.py
@ -2,6 +2,7 @@ from fastapi import FastAPI, Request, Form
|
|||||||
from fastapi.responses import HTMLResponse, JSONResponse
|
from fastapi.responses import HTMLResponse, JSONResponse
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
from fastapi import BackgroundTasks
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import json, download, asyncio
|
import json, download, asyncio
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -40,11 +41,12 @@ async def dropoutSeries():
|
|||||||
|
|
||||||
@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 dropoutDownload(
|
async def dropoutDownload(
|
||||||
|
background_tasks: BackgroundTasks,
|
||||||
show: str = Form(...),
|
show: str = Form(...),
|
||||||
season: int = Form(...),
|
season: int = Form(...)
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
await loop.run_in_executor(None, partial(download.dropout.show,show,season,None))
|
background_tasks.add_task(download.dropout.show,show,season,None)
|
||||||
# download.dropout.show(show,season,episode)
|
# download.dropout.show(show,season,episode)
|
||||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."})
|
return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -52,21 +54,22 @@ async def dropoutDownload(
|
|||||||
|
|
||||||
@app.post("/dropout/download/specials", description="Downloads a seasons behind the scenes and trailers, ignores main episodes.")
|
@app.post("/dropout/download/specials", description="Downloads a seasons behind the scenes and trailers, ignores main episodes.")
|
||||||
async def dropoutDownload(
|
async def dropoutDownload(
|
||||||
|
background_tasks: BackgroundTasks,
|
||||||
show: str = Form(...),
|
show: str = Form(...),
|
||||||
season: int = Form(...),
|
season: int = Form(...),
|
||||||
episode: Optional[int] = Form(None)
|
episode: Optional[int] = Form(None)
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
await loop.run_in_executor(None, partial(download.dropout.specials,show,season,episode))
|
background_tasks.add_task(download.dropout.specials,show,season,episode)
|
||||||
# download.dropout.show(show,season,episode)
|
# download.dropout.show(show,season,episode)
|
||||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."})
|
return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||||
|
|
||||||
@app.post("/ydl")
|
@app.post("/ydl")
|
||||||
async def ydl(url: str = Form(...), location: str = Form(...)):
|
async def ydl(background_tasks: BackgroundTasks, url: str = Form(...), location: str = Form(...)):
|
||||||
try:
|
try:
|
||||||
await loop.run_in_executor(None, partial(download.youtube.ydl, url, location))
|
background_tasks.add_task(download.youtube.ydl, url, location)
|
||||||
# download.youtube.ydl(url,location)
|
# download.youtube.ydl(url,location)
|
||||||
# grab.thumbnail(ydl,url,location)
|
# grab.thumbnail(ydl,url,location)
|
||||||
return JSONResponse(status_code=200, content={"status": "success", "message": "Video download completed."})
|
return JSONResponse(status_code=200, content={"status": "success", "message": "Video download completed."})
|
||||||
@ -93,8 +96,9 @@ async def index(request: Request, show = str):
|
|||||||
try:
|
try:
|
||||||
for item in cached_data:
|
for item in cached_data:
|
||||||
if show == item['LINK']:
|
if show == item['LINK']:
|
||||||
show_data = item
|
if "SEASONS" not in item:
|
||||||
return templates.TemplateResponse("show.html", {"request": request, "show": show_data})
|
item['SEASONS'] = download.grab.season(item['URL'])
|
||||||
|
return templates.TemplateResponse("show.html", {"request": request, "show": item})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -3,32 +3,86 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ show['SHOW'] }}</title>
|
<title>{{ show['SHOW'] }}</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
display: flex;
|
background-color: #141414;
|
||||||
flex-wrap: wrap;
|
color: #fff;
|
||||||
justify-content: center;
|
margin: 0;
|
||||||
background-color: #141414 !important;
|
padding: 0;
|
||||||
}
|
}
|
||||||
/* Add any styles you want */
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 600px;
|
max-width: 800px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
padding: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 24px;
|
font-size: 2em;
|
||||||
margin-top: 10px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
font-size: 16px;
|
font-size: 1em;
|
||||||
color: #555;
|
color: #ccc;
|
||||||
margin-top: 10px;
|
margin: 15px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.season-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.season-tile {
|
||||||
|
background-color: #222;
|
||||||
|
border: 1px solid #333;
|
||||||
|
padding: 10px 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 5px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.season-tile:hover {
|
||||||
|
background-color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.watch-btn {
|
||||||
|
margin-top: 30px;
|
||||||
|
padding: 12px 25px;
|
||||||
|
font-size: 1em;
|
||||||
|
background-color: #e50914;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.watch-btn:hover {
|
||||||
|
background-color: #b20710;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #ccc;
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.season-tile {
|
||||||
|
flex: 1 1 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -36,11 +90,66 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<img src="{{ show['POSTER'] }}" alt="{{ show['SHOW'] }}">
|
<img src="{{ show['POSTER'] }}" alt="{{ show['SHOW'] }}">
|
||||||
<div class="title">{{ show['SHOW'] }}</div>
|
<div class="title">{{ show['SHOW'] }}</div>
|
||||||
<div class="description">
|
<div class="description">{{ show['DESCRIPTION'] }}</div>
|
||||||
{{ show['DESCRIPTION'] }}
|
|
||||||
|
<div class="season-grid">
|
||||||
|
{% for season in show['SEASONS'] %}
|
||||||
|
<div class="season-tile" onclick="downloadSeason('{{ season }}')">
|
||||||
|
Season {{ season }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<!-- Optional back link -->
|
|
||||||
|
<button class="watch-btn" onclick="watchShow()">▶ Watch Now</button>
|
||||||
|
|
||||||
<p><a href="/">← Back to all shows</a></p>
|
<p><a href="/">← Back to all shows</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function downloadSeason(season) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("show", "{{ show['SHOW'] }}");
|
||||||
|
formData.append("season", parseInt(season, 10));
|
||||||
|
|
||||||
|
fetch('/dropout/download', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) throw new Error('Network error');
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
alert(`Season ${season} downloading.`);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
alert("Error downloading season.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function watchShow() {
|
||||||
|
fetch('/watch', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ show: "{{ show['SHOW'] }}" })
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) throw new Error('Network error');
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => {
|
||||||
|
alert('Playback started!');
|
||||||
|
// Optionally redirect to video player
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
alert("Error starting playback.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user