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