Загрузить файлы в «templates»
This commit is contained in:
210
templates/Player.html
Normal file
210
templates/Player.html
Normal file
@@ -0,0 +1,210 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ meta.title }}</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { background: #0f0f0f; color: #eee; font-family: Arial, sans-serif; }
|
||||
.container { max-width: 960px; margin: 30px auto; padding: 0 16px 40px; }
|
||||
.topbar {
|
||||
display: flex; justify-content: space-between;
|
||||
align-items: center; margin-bottom: 14px;
|
||||
}
|
||||
.back-btn {
|
||||
background: #2a2a2a; color: #aaa; border: 1px solid #444;
|
||||
border-radius: 6px; padding: 7px 14px; font-size: 13px;
|
||||
cursor: pointer; text-decoration: none;
|
||||
}
|
||||
.back-btn:hover { color: #fff; border-color: #888; }
|
||||
.player-wrap { background: #000; border-radius: 10px; overflow: hidden; }
|
||||
video { width: 100%; display: block; max-height: 540px; }
|
||||
|
||||
/* Controls */
|
||||
.controls {
|
||||
display: flex; flex-wrap: wrap; gap: 12px;
|
||||
align-items: flex-end; padding: 14px 0;
|
||||
}
|
||||
.controls label { font-size: 12px; color: #aaa; display: block; margin-bottom: 5px; }
|
||||
select {
|
||||
background: #1e1e1e; color: #fff; border: 1px solid #444;
|
||||
border-radius: 6px; padding: 6px 10px; font-size: 13px; cursor: pointer;
|
||||
}
|
||||
select:hover { border-color: #888; }
|
||||
.btn {
|
||||
background: #ff4444; color: #fff; border: none;
|
||||
border-radius: 6px; padding: 8px 20px; font-size: 13px;
|
||||
cursor: pointer; font-weight: bold;
|
||||
}
|
||||
.btn:hover { background: #cc0000; }
|
||||
|
||||
.dl-btn {
|
||||
background: #1a7a1a; color: #fff; border: none;
|
||||
border-radius: 6px; padding: 8px 20px; font-size: 13px;
|
||||
cursor: pointer; font-weight: bold; text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
.dl-btn:hover { background: #145214; }
|
||||
.dl-btn.loading { background: #555; cursor: not-allowed; pointer-events: none; }
|
||||
|
||||
.dl-status {
|
||||
font-size: 12px; color: #aaa; margin-top: 6px;
|
||||
display: none; min-width: 200px;
|
||||
}
|
||||
.progress-bar-wrap {
|
||||
background: #333; border-radius: 4px; height: 6px;
|
||||
margin-top: 4px; overflow: hidden; display: none;
|
||||
}
|
||||
.progress-bar { background: #1a7a1a; height: 100%; width: 0%; transition: width 0.3s; }
|
||||
|
||||
.card { background: #1a1a1a; border-radius: 10px; padding: 20px; margin-top: 20px; }
|
||||
.card h2 { font-size: 18px; margin-bottom: 10px; }
|
||||
.meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: #aaa; margin-bottom: 14px; }
|
||||
.description {
|
||||
font-size: 13px; color: #ccc; line-height: 1.65;
|
||||
max-height: 120px; overflow: hidden; white-space: pre-wrap;
|
||||
transition: max-height 0.3s ease;
|
||||
}
|
||||
.description.expanded { max-height: 3000px; }
|
||||
.toggle-desc {
|
||||
margin-top: 8px; background: none; border: none;
|
||||
color: #3ea6ff; font-size: 13px; cursor: pointer;
|
||||
}
|
||||
.toggle-desc:hover { text-decoration: underline; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<!-- Top bar -->
|
||||
<div class="topbar">
|
||||
<a href="/" class="back-btn">← Назад</a>
|
||||
</div>
|
||||
|
||||
<!-- Player -->
|
||||
<div class="player-wrap">
|
||||
<video id="player" controls autoplay preload="auto">
|
||||
<source id="video-src"
|
||||
src="/stream?format_id={{ default_format }}&url={{ youtube_url|urlencode }}"
|
||||
type="video/mp4">
|
||||
{% for sub in subtitles %}
|
||||
<track id="track-{{ sub.lang }}" kind="subtitles"
|
||||
label="{{ sub.label }}" srclang="{{ sub.lang }}"
|
||||
src="/subtitles?url={{ youtube_url|urlencode }}&lang={{ sub.lang }}&auto={{ sub.auto }}">
|
||||
{% endfor %}
|
||||
</video>
|
||||
</div>
|
||||
|
||||
<!-- Controls -->
|
||||
<div class="controls">
|
||||
|
||||
<div>
|
||||
<label>🎬 Качество</label>
|
||||
<select id="quality-select">
|
||||
{% for f in formats %}
|
||||
<option value="{{ f.id }}" {% if f.id == default_format %}selected{% endif %}>
|
||||
{{ f.label }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>💬 Субтитры</label>
|
||||
<select id="sub-select">
|
||||
<option value="">Off</option>
|
||||
{% for sub in subtitles %}
|
||||
<option value="{{ sub.lang }}-{{ sub.auto }}">{{ sub.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button class="btn" onclick="applySettings()">▶ Apply</button>
|
||||
|
||||
<!-- Download section -->
|
||||
<div>
|
||||
<label>⬇ Download</label>
|
||||
<button class="dl-btn" id="dl-btn" onclick="startDownload()">
|
||||
⬇ Download MP4
|
||||
</button>
|
||||
<div class="dl-status" id="dl-status"></div>
|
||||
<!-- ✅ Remove the progress bar wrap entirely -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Video info card -->
|
||||
<div class="card">
|
||||
<h2>{{ meta.title }}</h2>
|
||||
<div class="meta">
|
||||
<span>📺 {{ meta.uploader }}</span>
|
||||
<span>👁 {{ meta.views }} views</span>
|
||||
<span>⏱ {{ meta.duration }}</span>
|
||||
<span>📅 {{ meta.upload_date }}</span>
|
||||
</div>
|
||||
<div class="description" id="desc">{{ meta.description }}</div>
|
||||
<button class="toggle-desc" id="toggle-btn" onclick="toggleDesc()">▼ Show more</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const player = document.getElementById('player');
|
||||
const videoSrc = document.getElementById('video-src');
|
||||
const youtubeUrl = {{ youtube_url | tojson }};
|
||||
function applySettings() {
|
||||
const formatId = document.getElementById('quality-select').value;
|
||||
const subVal = document.getElementById('sub-select').value;
|
||||
const currentTime = player.currentTime;
|
||||
|
||||
videoSrc.src = `/stream?format_id=${formatId}&url=${encodeURIComponent(youtubeUrl)}`;
|
||||
player.load();
|
||||
player.currentTime = currentTime;
|
||||
player.play();
|
||||
|
||||
for (let i = 0; i < player.textTracks.length; i++)
|
||||
player.textTracks[i].mode = 'disabled';
|
||||
|
||||
if (subVal) {
|
||||
const lang = subVal.split('-')[0];
|
||||
const trackEl = document.getElementById(`track-${lang}`);
|
||||
if (trackEl) trackEl.track.mode = 'showing';
|
||||
}
|
||||
}
|
||||
|
||||
function toggleDesc() {
|
||||
const desc = document.getElementById('desc');
|
||||
const btn = document.getElementById('toggle-btn');
|
||||
desc.classList.toggle('expanded');
|
||||
btn.textContent = desc.classList.contains('expanded') ? '▲ Show less' : '▼ Show more';
|
||||
}
|
||||
|
||||
function startDownload() {
|
||||
const formatId = document.getElementById('quality-select').value;
|
||||
const status = document.getElementById('dl-status');
|
||||
const dlBtn = document.getElementById('dl-btn');
|
||||
|
||||
// Show feedback so user knows something is happening
|
||||
status.style.display = 'block';
|
||||
status.textContent = '⏳ Starting download…';
|
||||
dlBtn.textContent = '⏳ Downloading…';
|
||||
dlBtn.classList.add('loading');
|
||||
|
||||
// ✅ Direct navigation — browser handles saving natively
|
||||
window.location.href =
|
||||
`/download?url=${encodeURIComponent(youtubeUrl)}&format_id=${formatId}`;
|
||||
|
||||
// Reset button after a moment — page doesn't reload on file downloads
|
||||
setTimeout(() => {
|
||||
dlBtn.textContent = '⬇ Download MP4';
|
||||
dlBtn.classList.remove('loading');
|
||||
status.textContent = '✅ Download started — check your browser downloads.';
|
||||
setTimeout(() => {
|
||||
status.style.display = 'none';
|
||||
}, 4000);
|
||||
}, 3000);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user