From 3f5d197a484386d57b5e85c19aa79bdbe13c2ae8 Mon Sep 17 00:00:00 2001
From: Wesley Neuhaus <37388141+HugeBob@users.noreply.github.com>
Date: Thu, 21 Nov 2024 21:16:27 -0500
Subject: [PATCH] First Version!
---
index.html | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
main.py | 41 +++++++++++++++++++++++++++
requirements.txt | 5 ++++
3 files changed, 120 insertions(+)
create mode 100644 index.html
create mode 100644 main.py
create mode 100644 requirements.txt
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..b06739d
--- /dev/null
+++ b/index.html
@@ -0,0 +1,74 @@
+
+
+
+
+
+ YouTube Video Downloader
+
+
+
+
+
YouTube Video Downloader
+
+
+
+
+
+
+
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..c65d553
--- /dev/null
+++ b/main.py
@@ -0,0 +1,41 @@
+from flask import Flask, request, send_file
+import yt_dlp
+import os
+from flask_cors import CORS
+
+app = Flask(__name__)
+CORS(app)
+
+@app.route('/')
+def index():
+ return send_file('index.html')
+
+@app.route('/download', methods=['GET'])
+def download_video():
+ try:
+ video_url = request.args.get('url')
+ if not video_url:
+ return "Please provide a YouTube URL", 400
+
+ # Configure yt-dlp options
+ ydl_opts = {
+ 'format': 'best', # Download best quality
+ 'outtmpl': '%(title)s.%(ext)s', # Output template - download to current directory
+ }
+
+ # Download the video
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
+ info = ydl.extract_info(video_url, download=True)
+
+ return "Download completed", 200
+
+ except Exception as e:
+ print(f"Error: {str(e)}") # Add this for debugging
+ return str(e), 500
+
+@app.route('/ping')
+def ping():
+ return 'pong'
+
+if __name__ == '__main__':
+ app.run(debug=True, port=5000)
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..a036f3a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,5 @@
+# requirements.txt
+
+flask
+yt-dlp
+flask-cors