264 lines
8.2 KiB
HTML
264 lines
8.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<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;
|
|
background-color: #141414;
|
|
color: #fff;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
.container {
|
|
max-width: 800px;
|
|
margin: auto;
|
|
padding: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.title {
|
|
font-size: 2em;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
.description {
|
|
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;
|
|
margin-right: 10px;
|
|
padding: 12px 25px;
|
|
font-size: 1em;
|
|
background-color: #e50914;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.watch-btn:hover {
|
|
background-color: #b20710;
|
|
}
|
|
|
|
.watchlist-btn {
|
|
margin-top: 30px;
|
|
padding: 12px 25px;
|
|
font-size: 1em;
|
|
background-color: #404040;
|
|
color: #fff;
|
|
border: 2px solid #555;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.watchlist-btn:hover {
|
|
background-color: #505050;
|
|
border-color: #777;
|
|
}
|
|
|
|
.watchlist-btn.active {
|
|
background-color: #1db954;
|
|
border-color: #1aa34a;
|
|
}
|
|
|
|
.watchlist-btn.active:hover {
|
|
background-color: #1aa34a;
|
|
border-color: #16a336;
|
|
}
|
|
|
|
a {
|
|
color: #ccc;
|
|
display: inline-block;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
.season-tile {
|
|
flex: 1 1 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<img src="{{ show['POSTER'] }}" alt="{{ show['SHOW'] }}">
|
|
<div class="title">{{ show['SHOW'] }}</div>
|
|
<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>
|
|
|
|
<button class="watch-btn" onclick="watchShow()">▶ Watch Now</button>
|
|
<button id="watchlist-btn" class="watchlist-btn" onclick="toggleWatchlist()">+ Add to Watchlist</button>
|
|
|
|
<p><a href="/">← Back to all shows</a></p>
|
|
</div>
|
|
|
|
<script>
|
|
const showName = "{{ show['SHOW'] }}";
|
|
|
|
// Initialize watchlist button state
|
|
async function initWatchlistButton() {
|
|
try {
|
|
const response = await fetch('/api/schedule/list');
|
|
const data = await response.json();
|
|
|
|
const watchlistJobId = `watch_${showName.toLowerCase().replace(/\s+/g, '_')}`;
|
|
const isWatchlisted = data.jobs.some(job => job.job_id === watchlistJobId);
|
|
|
|
const btn = document.getElementById('watchlist-btn');
|
|
if (isWatchlisted) {
|
|
btn.textContent = '✓ Remove from Watchlist';
|
|
btn.classList.add('active');
|
|
} else {
|
|
btn.textContent = '+ Add to Watchlist';
|
|
btn.classList.remove('active');
|
|
}
|
|
} catch (err) {
|
|
console.error('Error initializing watchlist button:', err);
|
|
}
|
|
}
|
|
|
|
// Toggle watchlist
|
|
async function toggleWatchlist() {
|
|
const btn = document.getElementById('watchlist-btn');
|
|
const watchlistJobId = `watch_${showName.toLowerCase().replace(/\s+/g, '_')}`;
|
|
|
|
try {
|
|
// Check if already watchlisted
|
|
const response = await fetch('/api/schedule/list');
|
|
const data = await response.json();
|
|
const isWatchlisted = data.jobs.some(job => job.job_id === watchlistJobId);
|
|
|
|
if (isWatchlisted) {
|
|
// Remove from watchlist
|
|
const deleteResponse = await fetch(`/api/schedule/remove/${watchlistJobId}`, {
|
|
method: 'DELETE'
|
|
});
|
|
|
|
if (deleteResponse.ok) {
|
|
btn.textContent = '+ Add to Watchlist';
|
|
btn.classList.remove('active');
|
|
alert(`${showName} removed from watchlist.`);
|
|
} else {
|
|
alert('Error removing from watchlist.');
|
|
}
|
|
} else {
|
|
// Add to watchlist (schedule daily at 6 AM)
|
|
const formData = new FormData();
|
|
formData.append('job_id', watchlistJobId);
|
|
formData.append('task', 'download_latest');
|
|
formData.append('show', showName);
|
|
formData.append('cron', '10 19 * * *'); // Daily at 7:10 PM
|
|
|
|
const addResponse = await fetch('/api/schedule/add', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
|
|
if (addResponse.ok) {
|
|
btn.textContent = '✓ Remove from Watchlist';
|
|
btn.classList.add('active');
|
|
alert(`${showName} added to watchlist. New episodes will download daily at 7:10 PM.`);
|
|
} else {
|
|
alert('Error adding to watchlist.');
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
alert('Error toggling watchlist.');
|
|
}
|
|
}
|
|
|
|
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.");
|
|
});
|
|
}
|
|
|
|
// Initialize watchlist button when page loads
|
|
document.addEventListener('DOMContentLoaded', initWatchlistButton);
|
|
</script>
|
|
</body>
|
|
</html>
|