generated from dellevin/template
feat: complete local version to overwrite remote
This commit is contained in:
BIN
99demo/down-video/__pycache__/main.cpython-312.pyc
Normal file
BIN
99demo/down-video/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
2951
99demo/down-video/bilibili_cookies.txt
Normal file
2951
99demo/down-video/bilibili_cookies.txt
Normal file
File diff suppressed because it is too large
Load Diff
241
99demo/down-video/main.py
Normal file
241
99demo/down-video/main.py
Normal file
@@ -0,0 +1,241 @@
|
||||
import yt_dlp
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import queue
|
||||
import threading
|
||||
import subprocess
|
||||
from urllib.parse import urlparse
|
||||
from flask import Flask, render_template, request, jsonify, Response, stream_with_context, send_file
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
DEFAULT_OUTPUT_DIR = r"D:\UserData\Desktop\xiazai"
|
||||
TWITTER_COOKIE = "x_cookies.txt"
|
||||
BILIBILI_COOKIE = "bilibili_cookies.txt"
|
||||
PROXY_URL = "socks5://127.0.0.1:10808"
|
||||
|
||||
|
||||
def check_ffmpeg():
|
||||
"""检查 FFmpeg 是否可用"""
|
||||
try:
|
||||
result = subprocess.run(['ffmpeg', '-version'], capture_output=True, text=True, timeout=5)
|
||||
return result.returncode == 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def is_twitter_url(url):
|
||||
"""检查是否是 Twitter/X 链接"""
|
||||
domain = urlparse(url).netloc.lower()
|
||||
return 'x.com' in domain or 'twitter.com' in domain
|
||||
|
||||
|
||||
def is_bilibili_url(url):
|
||||
"""检查是否是 Bilibili 链接"""
|
||||
domain = urlparse(url).netloc.lower()
|
||||
return 'bilibili.com' in domain or 'b23.tv' in domain
|
||||
|
||||
|
||||
def _find_files_by_title(output_dir, safe_title):
|
||||
"""根据安全标题查找目录中的相关文件"""
|
||||
return [
|
||||
f for f in os.listdir(output_dir)
|
||||
if f.startswith(safe_title) and os.path.isfile(os.path.join(output_dir, f))
|
||||
]
|
||||
|
||||
|
||||
def _merge_mp4_m4a(output_dir, safe_title):
|
||||
"""
|
||||
查找同名的 .mp4 和 .m4a 并用 FFmpeg 合并。
|
||||
返回 (merged: bool, message: str, filepath: str)
|
||||
"""
|
||||
files = _find_files_by_title(output_dir, safe_title)
|
||||
mp4_files = [f for f in files if f.endswith('.mp4')]
|
||||
m4a_files = [f for f in files if f.endswith('.m4a')]
|
||||
|
||||
if not mp4_files or not m4a_files:
|
||||
return False, "未检测到需要合并的 .mp4 + .m4a"
|
||||
|
||||
# 取最可能匹配的一对:文件名最短(不含 quality suffix 的通常最短)
|
||||
mp4_files.sort(key=len)
|
||||
m4a_files.sort(key=len)
|
||||
mp4_path = os.path.join(output_dir, mp4_files[0])
|
||||
m4a_path = os.path.join(output_dir, m4a_files[0])
|
||||
|
||||
# 合并输出文件名
|
||||
merged_name = safe_title + "_merged.mp4"
|
||||
merged_path = os.path.join(output_dir, merged_name)
|
||||
counter = 1
|
||||
while os.path.exists(merged_path):
|
||||
merged_name = f"{safe_title}_merged_{counter}.mp4"
|
||||
merged_path = os.path.join(output_dir, merged_name)
|
||||
counter += 1
|
||||
|
||||
cmd = [
|
||||
'ffmpeg', '-y',
|
||||
'-i', mp4_path,
|
||||
'-i', m4a_path,
|
||||
'-c', 'copy',
|
||||
merged_path
|
||||
]
|
||||
try:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
||||
if result.returncode == 0 and os.path.exists(merged_path):
|
||||
# 合并成功后删除原始分片
|
||||
try:
|
||||
os.remove(mp4_path)
|
||||
os.remove(m4a_path)
|
||||
except Exception:
|
||||
pass
|
||||
return True, f"已合并为 {merged_name}", merged_path
|
||||
else:
|
||||
return False, f"FFmpeg 合并失败: {result.stderr[:200]}", ""
|
||||
except Exception as e:
|
||||
return False, f"合并异常: {str(e)}", ""
|
||||
|
||||
|
||||
def download_video(video_url, output_dir, platform):
|
||||
"""
|
||||
通用下载函数,返回 (success: bool, message: str, title: str, filepath: str)
|
||||
"""
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
ydl_opts = {
|
||||
'outtmpl': os.path.join(output_dir, '%(title)s.%(ext)s'),
|
||||
'ignoreerrors': True,
|
||||
}
|
||||
|
||||
if platform == 'twitter':
|
||||
cookie_file = TWITTER_COOKIE
|
||||
if PROXY_URL:
|
||||
ydl_opts['proxy'] = PROXY_URL
|
||||
elif platform == 'bilibili':
|
||||
cookie_file = BILIBILI_COOKIE
|
||||
# Bilibili 不使用代理,且需要合并配置
|
||||
ydl_opts['merge_output_format'] = 'mp4'
|
||||
ydl_opts['postprocessors'] = [{
|
||||
'key': 'FFmpegVideoConvertor',
|
||||
'preferedformat': 'mp4',
|
||||
}]
|
||||
else:
|
||||
return False, "不支持的平台", "", ""
|
||||
|
||||
if os.path.exists(cookie_file):
|
||||
ydl_opts['cookiefile'] = cookie_file
|
||||
else:
|
||||
return False, f"Cookie 文件 '{cookie_file}' 未找到", "", ""
|
||||
|
||||
try:
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(video_url, download=True)
|
||||
if not info:
|
||||
return False, "未能获取视频信息,下载可能失败", "", ""
|
||||
|
||||
title = info.get('title', 'Unknown Title')
|
||||
safe_title = re.sub(r'[<>:\"/\\|?*]', '_', title)
|
||||
files = _find_files_by_title(output_dir, safe_title)
|
||||
|
||||
if not files:
|
||||
return False, "下载完成但未找到输出文件", title, ""
|
||||
|
||||
# 确定最终视频文件路径
|
||||
# 优先取合并后的文件,否则取最大的 mp4 文件
|
||||
filepath = ""
|
||||
candidate_files = [f for f in files if f.endswith('.mp4')]
|
||||
if candidate_files:
|
||||
# 优先 merged 文件
|
||||
merged_candidates = [f for f in candidate_files if '_merged' in f]
|
||||
if merged_candidates:
|
||||
filepath = os.path.join(output_dir, merged_candidates[0])
|
||||
else:
|
||||
# 取最新/最大的文件
|
||||
candidate_files.sort(key=lambda f: os.path.getsize(os.path.join(output_dir, f)), reverse=True)
|
||||
filepath = os.path.join(output_dir, candidate_files[0])
|
||||
else:
|
||||
# 没有 mp4,取任意文件
|
||||
files.sort(key=lambda f: os.path.getsize(os.path.join(output_dir, f)), reverse=True)
|
||||
filepath = os.path.join(output_dir, files[0])
|
||||
|
||||
# Bilibili 后处理:如果存在分离的 mp4 + m4a,手动合并
|
||||
extra_msg = ""
|
||||
if platform == 'bilibili':
|
||||
has_mp4 = any(f.endswith('.mp4') for f in files)
|
||||
has_m4a = any(f.endswith('.m4a') for f in files)
|
||||
if has_mp4 and has_m4a:
|
||||
merged, merge_msg, merged_path = _merge_mp4_m4a(output_dir, safe_title)
|
||||
extra_msg = f" ({merge_msg})" if merge_msg else ""
|
||||
if merged and merged_path:
|
||||
filepath = merged_path
|
||||
|
||||
return True, f"下载成功!保存到 {output_dir}{extra_msg}", title, filepath
|
||||
|
||||
except Exception as e:
|
||||
return False, f"下载失败: {str(e)}", "", ""
|
||||
|
||||
|
||||
@app.route("/file")
|
||||
def serve_file():
|
||||
"""提供视频文件访问和下载"""
|
||||
filepath = request.args.get("path", "")
|
||||
as_download = request.args.get("download", "0") == "1"
|
||||
|
||||
if not filepath:
|
||||
return "Missing path", 400
|
||||
|
||||
# 安全检查:确保是绝对路径且文件存在
|
||||
filepath = os.path.abspath(filepath)
|
||||
if not os.path.exists(filepath) or not os.path.isfile(filepath):
|
||||
return "File not found", 404
|
||||
|
||||
# 只允许访问视频文件(防止任意文件读取)
|
||||
ext = os.path.splitext(filepath)[1].lower()
|
||||
if ext not in ('.mp4', '.m4a', '.webm', '.mkv', '.mov', '.avi'):
|
||||
return "File type not allowed", 403
|
||||
|
||||
return send_file(filepath, as_attachment=as_download)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
ffmpeg_ok = check_ffmpeg()
|
||||
return render_template("index.html", ffmpeg_ok=ffmpeg_ok)
|
||||
|
||||
|
||||
@app.route("/download", methods=["POST"])
|
||||
def download():
|
||||
data = request.get_json()
|
||||
url = data.get("url", "").strip() if data else ""
|
||||
output_dir = data.get("output_dir", DEFAULT_OUTPUT_DIR).strip() if data else DEFAULT_OUTPUT_DIR
|
||||
|
||||
if not url:
|
||||
return jsonify({"success": False, "message": "请输入视频链接"}), 400
|
||||
|
||||
if is_twitter_url(url):
|
||||
platform = 'twitter'
|
||||
elif is_bilibili_url(url):
|
||||
platform = 'bilibili'
|
||||
else:
|
||||
return jsonify({"success": False, "message": "仅支持 Twitter/X 和 Bilibili 视频链接"}), 400
|
||||
|
||||
if not output_dir:
|
||||
output_dir = DEFAULT_OUTPUT_DIR
|
||||
|
||||
success, message, title, filepath = download_video(url, output_dir, platform)
|
||||
return jsonify({"success": success, "message": message, "title": title, "filepath": filepath})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=" * 50)
|
||||
print("Twitter / Bilibili 视频下载器")
|
||||
print("=" * 50)
|
||||
if check_ffmpeg():
|
||||
print("FFmpeg 已检测到")
|
||||
else:
|
||||
print("警告: 未检测到 FFmpeg")
|
||||
print(f"默认保存目录: {DEFAULT_OUTPUT_DIR}")
|
||||
print("访问 http://127.0.0.1:5000 打开下载页面")
|
||||
print("=" * 50)
|
||||
app.run(host="0.0.0.0", port=5000, debug=False, threaded=True)
|
||||
380
99demo/down-video/templates/index.html
Normal file
380
99demo/down-video/templates/index.html
Normal file
@@ -0,0 +1,380 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>视频下载器</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background: #0a0a0a;
|
||||
color: #f5f5f5;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
}
|
||||
/* 左侧面板 */
|
||||
.left-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid #222;
|
||||
min-width: 420px;
|
||||
}
|
||||
.input-section {
|
||||
padding: 32px;
|
||||
border-bottom: 1px solid #222;
|
||||
}
|
||||
.input-section h1 {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 4px;
|
||||
color: #fff;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
.input-section .subtitle {
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.input-group label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 6px;
|
||||
color: #888;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
.input-group input {
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #333;
|
||||
border-radius: 10px;
|
||||
background: #0a0a0a;
|
||||
color: #f5f5f5;
|
||||
font-size: 14px;
|
||||
outline: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
.input-group input::placeholder { color: #444; }
|
||||
.input-group input:focus { border-color: #fff; background: #000; }
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
button:hover:not(:disabled) { background: #e0e0e0; transform: translateY(-1px); }
|
||||
button:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
.status {
|
||||
margin-top: 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
display: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
.status.show { display: block; }
|
||||
.status.success { background: #0a1f0a; color: #4ade80; border: 1px solid #1a3a1a; }
|
||||
.status.error { background: #1f0a0a; color: #f87171; border: 1px solid #3a1a1a; }
|
||||
.status.info { background: #0a0a1f; color: #60a5fa; border: 1px solid #1a1a3a; }
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border: 2px solid rgba(255,255,255,0.15);
|
||||
border-top-color: #60a5fa;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin-right: 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
.footer-meta {
|
||||
margin-top: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-size: 11px;
|
||||
color: #444;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
.badge.ok { background: #0a1f0a; color: #4ade80; border: 1px solid #1a3a1a; }
|
||||
.badge.warn { background: #1f1a0a; color: #fbbf24; border: 1px solid #3a301a; }
|
||||
|
||||
/* 日志区域 */
|
||||
.log-section {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.log-header {
|
||||
padding: 14px 32px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
border-bottom: 1px solid #1a1a1a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.log-panel {
|
||||
flex: 1;
|
||||
padding: 20px 32px;
|
||||
background: #000;
|
||||
color: #4ade80;
|
||||
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
overflow-y: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 右侧面板 */
|
||||
.right-panel {
|
||||
flex: 1.2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.right-panel .placeholder {
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
.right-panel .placeholder svg {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.3;
|
||||
}
|
||||
.right-panel .placeholder p {
|
||||
font-size: 14px;
|
||||
}
|
||||
.video-wrap {
|
||||
width: 100%;
|
||||
max-width: 720px;
|
||||
height: 100%;
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.video-wrap.show { display: flex; }
|
||||
.video-player {
|
||||
max-width: 100%;
|
||||
max-height: calc(100% - 70px);
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
border-radius: 12px;
|
||||
background: #000;
|
||||
border: 1px solid #222;
|
||||
outline: none;
|
||||
}
|
||||
.video-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
.video-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
line-height: 1.4;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.video-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.countdown {
|
||||
font-size: 12px;
|
||||
color: #f87171;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.btn-download {
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
background: #1a1a1a;
|
||||
color: #fff;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
border: 1px solid #333;
|
||||
transition: all 0.2s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.btn-download:hover { background: #2a2a2a; border-color: #444; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="left-panel">
|
||||
<div class="input-section">
|
||||
<h1>视频下载</h1>
|
||||
<p class="subtitle">支持 X 和 Bilibili</p>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="url">视频链接</label>
|
||||
<input type="url" id="url" placeholder="https://x.com/... 或 https://www.bilibili.com/video/...">
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label for="outputDir">保存路径</label>
|
||||
<input type="text" id="outputDir" value="D:\UserData\Desktop\xiazai">
|
||||
</div>
|
||||
|
||||
<button id="downloadBtn" onclick="startDownload()">开始下载</button>
|
||||
|
||||
<div id="status" class="status"></div>
|
||||
|
||||
<div class="footer-meta">
|
||||
<span>FFmpeg</span>
|
||||
{% if ffmpeg_ok %}
|
||||
<span class="badge ok">已就绪</span>
|
||||
{% else %}
|
||||
<span class="badge warn">未检测到</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="log-section" style="display:none;">
|
||||
<div class="log-header">
|
||||
<span>控制台输出</span>
|
||||
<span id="logStatus" style="font-size:11px;color:#444;">等待开始</span>
|
||||
</div>
|
||||
<pre id="logPanel" class="log-panel"></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-panel">
|
||||
<div id="placeholder" class="placeholder">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<rect x="2" y="2" width="20" height="20" rx="4"/>
|
||||
<polygon points="9,8 17,12 9,16"/>
|
||||
</svg>
|
||||
<p>下载完成后在此预览视频</p>
|
||||
</div>
|
||||
|
||||
<div id="videoWrap" class="video-wrap">
|
||||
<video id="videoPlayer" class="video-player" controls></video>
|
||||
<div class="video-info">
|
||||
<div id="videoTitle" class="video-title"></div>
|
||||
<div class="video-actions">
|
||||
<a id="downloadLink" class="btn-download" href="#" target="_blank">下载文件</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const urlInput = document.getElementById('url');
|
||||
const btn = document.getElementById('downloadBtn');
|
||||
const statusEl = document.getElementById('status');
|
||||
const logPanel = document.getElementById('logPanel');
|
||||
const logStatus = document.getElementById('logStatus');
|
||||
const placeholder = document.getElementById('placeholder');
|
||||
const videoWrap = document.getElementById('videoWrap');
|
||||
const videoPlayer = document.getElementById('videoPlayer');
|
||||
const videoTitle = document.getElementById('videoTitle');
|
||||
const countdownEl = document.getElementById('countdown');
|
||||
const downloadLink = document.getElementById('downloadLink');
|
||||
|
||||
function showStatus(text, type) {
|
||||
statusEl.textContent = text;
|
||||
statusEl.className = 'status show ' + type;
|
||||
}
|
||||
function clearStatus() { statusEl.className = 'status'; }
|
||||
|
||||
function showVideo(filepath, title) {
|
||||
placeholder.style.display = 'none';
|
||||
videoWrap.classList.add('show');
|
||||
videoPlayer.src = '/file?path=' + encodeURIComponent(filepath);
|
||||
videoTitle.textContent = title || '未命名视频';
|
||||
downloadLink.href = '/file?path=' + encodeURIComponent(filepath) + '&download=1';
|
||||
downloadLink.setAttribute('download', '');
|
||||
}
|
||||
|
||||
async function startDownload() {
|
||||
const url = urlInput.value.trim();
|
||||
const outputDir = document.getElementById('outputDir').value.trim();
|
||||
if (!url) {
|
||||
showStatus('请输入视频链接', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
btn.disabled = true;
|
||||
clearStatus();
|
||||
showStatus('', 'info');
|
||||
statusEl.innerHTML = '<span class="spinner"></span>正在下载,请稍候...';
|
||||
statusEl.className = 'status show info';
|
||||
|
||||
// 隐藏之前的视频
|
||||
videoWrap.classList.remove('show');
|
||||
placeholder.style.display = 'block';
|
||||
videoPlayer.src = '';
|
||||
|
||||
try {
|
||||
const res = await fetch('/download', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ url: url, output_dir: outputDir })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
showStatus((data.title ? '《' + data.title + '》' : '') + ' 下载完成', 'success');
|
||||
if (data.filepath) {
|
||||
showVideo(data.filepath, data.title);
|
||||
}
|
||||
} else {
|
||||
showStatus(data.message, 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
showStatus('请求失败: ' + err.message, 'error');
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
urlInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') startDownload();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
35
99demo/down-video/x_cookies.txt
Normal file
35
99demo/down-video/x_cookies.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
# Netscape HTTP Cookie File
|
||||
# This file is generated by yt-dlp. Do not edit.
|
||||
|
||||
zhutix.com FALSE / FALSE 1782047186 X_CACHE_KEY 0291346395e7ad60497281e3e38d4231
|
||||
.x.com TRUE / FALSE 1808747867 __cuid b00c4a6e73cf471e95c093aec1d1c0b0
|
||||
.x.com TRUE / TRUE 1807414323 personalization_id "v1_X+OVgjnn20lE7ppYGHrXzQ=="
|
||||
.x.com TRUE / TRUE 1807414324 guest_id v1%3A177285432573681062
|
||||
.x.com TRUE / TRUE 1807414357 kdt aYTMkoEta2sR2Cbrf9TCU2vL6NQrNTk6xP26HzJA
|
||||
.x.com TRUE / TRUE 1807414357 auth_token e0a16f1e58541f609e0b26bfd2759c5508ad67c6
|
||||
.x.com TRUE / TRUE 1807414357 ct0 0699cddc947b9fa7e4b226e70d7fc69fdd46a9d4623aea18b98cf8ed9d99fd308a01fec0e531ae1bb50b602a0ba9e87691d694888c39440c7bc8bdc3e35afd1d0757903d5bc702b71fa81c648a0108e7
|
||||
.x.com TRUE / TRUE 1808748895 guest_id_ads v1%3A177285432573681062
|
||||
.x.com TRUE / TRUE 1808748895 guest_id_marketing v1%3A177285432573681062
|
||||
.x.com TRUE / TRUE 1805724895 twid u%3D1051785185509822466
|
||||
.x.com TRUE / TRUE 1777215667 __cf_bm k7mwLxnd0mtyuyQLThqb20Oyb3q2.yEJfZw570X8CEI-1777213867.2375512-1.0.1.1-GAwpDeSYeFaRo9HzHK2Xf5tYtXiD4SzQj_L0kFw1S1P7FZWwSnOuJZ2JfxMxlG7vnUjDS0lBbszszPUWdOFb0upzl1YbBdE0jf6q0t7nJB0qvN9MElSi3lTTFOdf7HEs
|
||||
www.dropbox.com FALSE / TRUE 1790090452 gvc MTk3NzU0NTUwMjg0MDYzMDYzMzA4NTQ0MjEyNzAzODM1MzUxNTYz
|
||||
www.dropbox.com FALSE / TRUE 1787066452 __Host-js_csrf ee7vG1QZzX2hhBoptjGNMkhg
|
||||
.dropbox.com TRUE / TRUE 1787066452 t ee7vG1QZzX2hhBoptjGNMkhg
|
||||
.netflix.com TRUE / FALSE 1789916349 nfvdid BQFmAAEBEKpkhEFXmQMTd61zb4rT6FdApPuZS-qvyP3HIzl9d5Tk2rjxE6wW5b--LFBw-Ebbcmp7rJ640s9P91ltSiy8DTzu-0gEy3Ob8B_JHniDavIQXQ%3D%3D
|
||||
.netflix.com TRUE / TRUE 1789916349 SecureNetflixId v%3D3%26mac%3DAQEAEQABABSSBFH4KvE6qPl_-6UI_re1LAdlfAy3rZk.%26dt%3D1758380348892
|
||||
.netflix.com TRUE / TRUE 1789916349 NetflixId v%3D3%26ct%3DBgjHlOvcAxLAAb-lG8nEmlB-x4EMpdZG6gG0_ZGe7HgQvUbBUgbe6kPr6Or-1cC94UaN0RbSzxx_OYBaaHLg2MvdKRvw0dKlWwzRJyychkiKImYRxA1PHETG8KjG86tx5smLKn9QcETtqecvyrKl04PUFZ6KuO8Y3LrCO8posa-VMj5U3gonTjruh63uy_zFQYQygkvrJIShQ1yQjNxCropJEzK536vs46y7MYjt_KPCIK9E8tpT80whmRDQ7DgBniSOyGTtiKKyFhgGIg4KDEsJyQjnvm9ZXXKI7g..
|
||||
.yandex.com TRUE / TRUE 1795878312 yuidss 3388071441761318311
|
||||
.yandex.com TRUE / TRUE 1795878312 is_gdpr 0
|
||||
.yandex.com TRUE / TRUE 1795878312 yandexuid 3388071441761318311
|
||||
.yandex.com TRUE / TRUE 1806578318 my YwA=
|
||||
.yandex.com TRUE / TRUE 1795878652 is_gdpr_b CMWxMBD63gIoAg==
|
||||
.yandex.com TRUE / TRUE 1806578314 i Tl5C1iTbvBz58B4Pigqm2d8QgUC+4wYSpsK4t9kymsq2s0hX0eVihjDkvNmLxPLd8yXet7JjFuW1h5SeT3bJ+65Aepo=
|
||||
.yandex.com TRUE / TRUE 1806846551 yp 2087646552.pcs.0#1792854544.swntab.0#1787786326.szm.1:1920x1080:1304x732:15#1774610321.ygu.1#1772882321.dlp.2
|
||||
.yandex.com TRUE / TRUE 1806848331 _yasc RfaPS2g6xVw7Omhl+7/4pXIp30Wti0n8MwSiKMV6meOJl3Phq4TlP15XKqkV+MVJhr3OKmKyvTnS0m3SuMVVFhSLDPGFpWauk4yqACQuAydoupgmirYCoa16gRa9L3hZv/kc4QnkyqvC3E2KLQ==
|
||||
.yandex.com TRUE / TRUE 1806848512 bh EkEiQ2hyb21pdW0iO3Y9IjE0MCIsICJOb3Q9QT9CcmFuZCI7dj0iMjQiLCAiR29vZ2xlIENocm9tZSI7dj0iMTQwIhoFIng4NiIiECIxNDAuMC43MzM5LjEyOCIqAj8wMgIiIjoJIldpbmRvd3MiQggiMTkuMC4wIkoEIjY0IlJdIkNocm9taXVtIjt2PSIxNDAuMC43MzM5LjEyOCIsICJOb3Q9QT9CcmFuZCI7dj0iMjQuMC4wLjAiLCAiR29vZ2xlIENocm9tZSI7dj0iMTQwLjAuNzMzOS4xMjgiWgI/MGDD84vNBmoe3Mrh/wiS2KGxA5/P4eoD+/rw5w3r//32D/68z4cI
|
||||
www.kninebox.com FALSE / FALSE 1800025226 SITE_TOTAL_ID c9a65e54de60ac4fe330c0ff3782502c
|
||||
www.zabbix.com FALSE / TRUE 1798733253 bblastvisit 1767197255
|
||||
www.zabbix.com FALSE / TRUE 1798733263 bblastactivity 1767197264
|
||||
x.com FALSE / FALSE 1788406355 g_state {"i_l":0,"i_ll":1772854333755,"i_e":{"enable_itp_optimization":0}}
|
||||
x.com FALSE / FALSE 0 lang zh-cn
|
||||
www.wmmflix.com FALSE / FALSE 1805607768 lastvisit 121%091774071767%09%2Fapp-index-run%3Fapp%3Dsearch%26keywords%3Dtt0817177
|
||||
Reference in New Issue
Block a user