fixed downloading

This commit is contained in:
TylerCG 2025-04-28 10:29:49 -04:00
parent 546e6ea3bb
commit 153a4eb555
3 changed files with 135 additions and 31 deletions

View File

@ -1,6 +1,4 @@
import os, yt_dlp, json, requests, re, time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os, yt_dlp, json, requests, re
from bs4 import BeautifulSoup
from urllib.parse import urlsplit
@ -178,13 +176,6 @@ class dropout():
def series():
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
# If you want to parse the HTML

View File

@ -2,6 +2,7 @@ from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.templating import Jinja2Templates
from fastapi.staticfiles import StaticFiles
from fastapi import BackgroundTasks
from functools import partial
import json, download, asyncio
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.")
async def dropoutDownload(
background_tasks: BackgroundTasks,
show: str = Form(...),
season: int = Form(...),
season: int = Form(...)
):
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)
return JSONResponse(status_code=200, content={"status": "success", "message": "Series downloaded."})
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.")
async def dropoutDownload(
background_tasks: BackgroundTasks,
show: str = Form(...),
season: int = Form(...),
episode: Optional[int] = Form(None)
):
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)
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)})
@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:
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)
# grab.thumbnail(ydl,url,location)
return JSONResponse(status_code=200, content={"status": "success", "message": "Video download completed."})
@ -93,8 +96,9 @@ async def index(request: Request, show = str):
try:
for item in cached_data:
if show == item['LINK']:
show_data = item
return templates.TemplateResponse("show.html", {"request": request, "show": show_data})
if "SEASONS" not in item:
item['SEASONS'] = download.grab.season(item['URL'])
return templates.TemplateResponse("show.html", {"request": request, "show": item})
except Exception as e:
return JSONResponse(status_code=500, content={"status": "error", "message": str(e)})
except Exception as e:

View File

@ -3,32 +3,86 @@
<head>
<meta charset="UTF-8">
<title>{{ show['SHOW'] }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
display: flex;
flex-wrap: wrap;
justify-content: center;
background-color: #141414 !important;
background-color: #141414;
color: #fff;
margin: 0;
padding: 0;
}
/* Add any styles you want */
.container {
max-width: 600px;
max-width: 800px;
margin: auto;
padding: 20px;
text-align: center;
}
img {
max-width: 100%;
height: auto;
border-radius: 6px;
}
.title {
font-size: 24px;
margin-top: 10px;
font-size: 2em;
margin-top: 20px;
}
.description {
font-size: 16px;
color: #555;
margin-top: 10px;
font-size: 1em;
color: #ccc;
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>
</head>
@ -36,11 +90,66 @@
<div class="container">
<img src="{{ show['POSTER'] }}" alt="{{ show['SHOW'] }}">
<div class="title">{{ show['SHOW'] }}</div>
<div class="description">
{{ show['DESCRIPTION'] }}
<div class="description">{{ show['DESCRIPTION'] }}</div>
<div class="season-grid">
{% for season in show['SEASONS'] %}
<div class="season-tile" onclick="downloadSeason('{{ season }}')">
Season {{ season }}
</div>
{% endfor %}
</div>
<!-- Optional back link -->
<button class="watch-btn" onclick="watchShow()">▶ Watch Now</button>
<p><a href="/">← Back to all shows</a></p>
</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>
</html>