Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,102 @@
|
|
| 1 |
import subprocess
|
| 2 |
-
from flask import Flask, Response, request
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
@app.route('/')
|
| 7 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
url = request.args.get('url')
|
| 9 |
if not url:
|
| 10 |
-
return "
|
| 11 |
|
| 12 |
-
#
|
| 13 |
cmd = ['yt-dlp', '-o', '-', '-f', 'best', url]
|
| 14 |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
| 15 |
|
| 16 |
return Response(proc.stdout, mimetype='video/mp4')
|
| 17 |
|
| 18 |
if __name__ == '__main__':
|
| 19 |
-
# مهم جداً استخدام بورت 7860 في Hugging Face
|
| 20 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 1 |
import subprocess
|
| 2 |
+
from flask import Flask, Response, request, render_template_string
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
| 5 |
|
| 6 |
+
# واجهة المستخدم HTML مع تصميم عصري (Cyber-Blue)
|
| 7 |
+
HTML_TEMPLATE = """
|
| 8 |
+
<!DOCTYPE html>
|
| 9 |
+
<html lang="ar" dir="rtl">
|
| 10 |
+
<head>
|
| 11 |
+
<meta charset="UTF-8">
|
| 12 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 13 |
+
<title>Adeeb Streamer | بوابة البث الذكي</title>
|
| 14 |
+
<style>
|
| 15 |
+
body {
|
| 16 |
+
background-color: #0d1117;
|
| 17 |
+
color: #c9d1d9;
|
| 18 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 19 |
+
display: flex;
|
| 20 |
+
flex-direction: column;
|
| 21 |
+
align-items: center;
|
| 22 |
+
justify-content: center;
|
| 23 |
+
height: 100vh;
|
| 24 |
+
margin: 0;
|
| 25 |
+
}
|
| 26 |
+
.container {
|
| 27 |
+
background: #161b22;
|
| 28 |
+
padding: 2rem;
|
| 29 |
+
border-radius: 15px;
|
| 30 |
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
|
| 31 |
+
border: 1px solid #30363d;
|
| 32 |
+
width: 90%;
|
| 33 |
+
max-width: 500px;
|
| 34 |
+
text-align: center;
|
| 35 |
+
}
|
| 36 |
+
h1 { color: #58a6ff; margin-bottom: 1.5rem; }
|
| 37 |
+
input[type="text"] {
|
| 38 |
+
width: 100%;
|
| 39 |
+
padding: 12px;
|
| 40 |
+
margin-bottom: 1rem;
|
| 41 |
+
border-radius: 8px;
|
| 42 |
+
border: 1px solid #30363d;
|
| 43 |
+
background: #0d1117;
|
| 44 |
+
color: white;
|
| 45 |
+
box-sizing: border-box;
|
| 46 |
+
}
|
| 47 |
+
button {
|
| 48 |
+
background-color: #238636;
|
| 49 |
+
color: white;
|
| 50 |
+
border: none;
|
| 51 |
+
padding: 12px 25px;
|
| 52 |
+
border-radius: 8px;
|
| 53 |
+
cursor: pointer;
|
| 54 |
+
font-weight: bold;
|
| 55 |
+
width: 100%;
|
| 56 |
+
transition: 0.3s;
|
| 57 |
+
}
|
| 58 |
+
button:hover { background-color: #2ea043; }
|
| 59 |
+
.footer { margin-top: 2rem; font-size: 0.8rem; color: #8b949e; }
|
| 60 |
+
</style>
|
| 61 |
+
</head>
|
| 62 |
+
<body>
|
| 63 |
+
<div class="container">
|
| 64 |
+
<h1>Adeeb Streamer 🚀</h1>
|
| 65 |
+
<p>الصق رابط الفيديو أدناه لبدء البث عبر النفق</p>
|
| 66 |
+
<input type="text" id="videoUrl" placeholder="https://www.youtube.com/watch?v=...">
|
| 67 |
+
<button onclick="startStream()">تشغيل البث المباشر</button>
|
| 68 |
+
<div class="footer">نظام بث آمن - مخصص لمهندسي المستقبل</div>
|
| 69 |
+
</div>
|
| 70 |
+
|
| 71 |
+
<script>
|
| 72 |
+
function startStream() {
|
| 73 |
+
const url = document.getElementById('videoUrl').value;
|
| 74 |
+
if (url) {
|
| 75 |
+
window.location.href = '/stream?url=' + encodeURIComponent(url);
|
| 76 |
+
} else {
|
| 77 |
+
alert('الرجاء إدخال رابط الفيديو أولاً');
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
</script>
|
| 81 |
+
</body>
|
| 82 |
+
</html>
|
| 83 |
+
"""
|
| 84 |
+
|
| 85 |
@app.route('/')
|
| 86 |
+
def index():
|
| 87 |
+
return render_template_string(HTML_TEMPLATE)
|
| 88 |
+
|
| 89 |
+
@app.route('/stream')
|
| 90 |
+
def stream():
|
| 91 |
url = request.args.get('url')
|
| 92 |
if not url:
|
| 93 |
+
return "خطأ: لم يتم توفير رابط الفيديو", 400
|
| 94 |
|
| 95 |
+
# أمر yt-dlp للسحب المباشر
|
| 96 |
cmd = ['yt-dlp', '-o', '-', '-f', 'best', url]
|
| 97 |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
| 98 |
|
| 99 |
return Response(proc.stdout, mimetype='video/mp4')
|
| 100 |
|
| 101 |
if __name__ == '__main__':
|
|
|
|
| 102 |
app.run(host='0.0.0.0', port=7860)
|