Skip to content

Download videos from almost any website. Lightweight, self-hosted media downloader with a clean web UI.

HTML

feat: add youtube playlist support

AmanoSpica8b9ea498a183
diff --git a/app.py b/app.py
index 703f435..3e9e70a 100644
--- a/app.py
+++ b/app.py
@@ -124,6 +124,29 @@ def get_info():
return jsonify({"error": str(e)}), 400
[email protected]("/api/playlist", methods=["POST"])
+def get_playlist_info():
+ data = request.json
+ url = data.get("url", "").strip()
+ if not url:
+ return jsonify({"error": "No URL provided"}), 400
+
+ cmd = ["yt-dlp", "--flat-playlist", "-J", url]
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=60)
+ if result.returncode != 0:
+ return jsonify({"error": result.stderr.strip().split("\n")[-1]}), 400
+
+ info = json.loads(result.stdout)
+ entries = info.get("entries", [])
+ urls = [entry.get("url") for entry in entries if entry.get("url")]
+ return jsonify({"urls": urls})
+ except subprocess.TimeoutExpired:
+ return jsonify({"error": "Timed out fetching playlist info"}), 400
+ except Exception as e:
+ return jsonify({"error": str(e)}), 400
+
+
@app.route("/api/download", methods=["POST"])
def start_download():
data = request.json
diff --git a/templates/index.html b/templates/index.html
index 0bae3d3..a29bec9 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -462,6 +462,22 @@
container.innerHTML = '';
cardData = [];
+ // Check if youtube playlist URL
+ for (let i = 0; i < urls.length; i++) {
+ if (urls[i].includes('youtube.com/playlist')) {
+ const res = await fetch('/api/playlist', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ url: urls[i] }),
+ });
+ const data = await res.json();
+ if (data.urls) {
+ // replace playlist URL with individual video URLs
+ urls.splice(i, 1, ...data.urls);
+ }
+ }
+ }
+
for (let i = 0; i < urls.length; i++) {
const url = urls[i];
const idx = cardData.length;