Commit
·
933ae1f
1
Parent(s):
69815a6
Versão 1
Browse files- __pycache__/download_video.cpython-311.pyc +0 -0
- app.py +20 -0
- download_video.py +15 -0
- index.html +22 -0
__pycache__/download_video.cpython-311.pyc
ADDED
Binary file (1.14 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, send_from_directory
|
2 |
+
import download_video
|
3 |
+
|
4 |
+
app = Flask(__name__)
|
5 |
+
|
6 |
+
@app.route('/download')
|
7 |
+
def download():
|
8 |
+
url = request.args.get('url')
|
9 |
+
if not url:
|
10 |
+
return "URL não informado.", 400
|
11 |
+
|
12 |
+
result = download_video.baixar_video(url)
|
13 |
+
return result
|
14 |
+
|
15 |
+
@app.route('/')
|
16 |
+
def index():
|
17 |
+
return send_from_directory('.', 'index.html')
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
app.run(host='0.0.0.0', port=8080)
|
download_video.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
def baixar_video(url):
|
5 |
+
try:
|
6 |
+
output = subprocess.check_output(['yt-dlp', '--no-check-certificate', '-f', 'mp4', url], stderr=subprocess.STDOUT)
|
7 |
+
return f"Vídeo baixado com sucesso: {output}"
|
8 |
+
except subprocess.CalledProcessError as e:
|
9 |
+
return f"Erro ao baixar vídeo: {e.output}"
|
10 |
+
except Exception as e:
|
11 |
+
return f"Erro ao baixar vídeo: {e}"
|
12 |
+
|
13 |
+
if __name__ == "__main__":
|
14 |
+
url = sys.argv[1]
|
15 |
+
print(baixar_video(url))
|
index.html
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="pt">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Baixar Vídeo do YouTube</title>
|
7 |
+
<script>
|
8 |
+
async function baixarVideo() {
|
9 |
+
const url = document.getElementById("url").value;
|
10 |
+
const response = await fetch(`/download?url=${encodeURIComponent(url)}`);
|
11 |
+
const result = await response.text();
|
12 |
+
alert(result);
|
13 |
+
}
|
14 |
+
</script>
|
15 |
+
</head>
|
16 |
+
<body>
|
17 |
+
<h1>Baixar Vídeo do YouTube</h1>
|
18 |
+
<label for="url">URL do vídeo:</label>
|
19 |
+
<input type="text" id="url" placeholder="Insira o URL do vídeo">
|
20 |
+
<button onclick="baixarVideo()">Baixar Vídeo</button>
|
21 |
+
</body>
|
22 |
+
</html>
|