Spaces:
Sleeping
Sleeping
Download app.py from Anoar2025/adeeb-stream: direct link, hf CLI and curl.
- Browser
- Download file 2.68 kB
-
https://huggingface.co/spaces/Anoar2025/adeeb-stream/resolve/main/app.py
- Command line
-
hf download hf://spaces/Anoar2025/adeeb-stream/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Anoar2025/adeeb-stream/resolve/main/app.py
2.68 kB
| import subprocess | |
| from flask import Flask, Response, request, render_template_string | |
| app = Flask(__name__) | |
| # واجهة المستخدم المحسنة | |
| HTML_TEMPLATE = """ | |
| <!DOCTYPE html> | |
| <html lang="ar" dir="rtl"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Adeeb Streamer | بوابة البث الذكي</title> | |
| <style> | |
| body { background-color: #0d1117; color: #c9d1d9; font-family: sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; } | |
| .container { background: #161b22; padding: 2rem; border-radius: 15px; border: 1px solid #30363d; width: 90%; max-width: 500px; text-align: center; } | |
| h1 { color: #58a6ff; } | |
| input { width: 100%; padding: 12px; margin: 1rem 0; border-radius: 8px; border: 1px solid #30363d; background: #0d1117; color: white; } | |
| button { background-color: #238636; color: white; border: none; padding: 12px 25px; border-radius: 8px; cursor: pointer; width: 100%; font-weight: bold; } | |
| .note { font-size: 0.8rem; color: #8b949e; margin-top: 1rem; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Adeeb Streamer 🚀</h1> | |
| <input type="text" id="videoUrl" placeholder="الصق رابط يوتيوب هنا..."> | |
| <button onclick="startStream()">تشغيل الآن</button> | |
| <p class="note">ملاحظة: قد يستغرق بدء التشغيل ثواني قليلة لجلب البيانات</p> | |
| </div> | |
| <script> | |
| function startStream() { | |
| const url = document.getElementById('videoUrl').value; | |
| if (url) { | |
| window.location.href = '/stream?url=' + encodeURIComponent(url); | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> | |
| """ | |
| def index(): | |
| return render_template_string(HTML_TEMPLATE) | |
| def stream(): | |
| url = request.args.get('url') | |
| if not url: | |
| return "الرابط مطلوب", 400 | |
| # التعديل الجوهري هنا: نطلب أفضل جودة MP4 تحتوي على الصوت والصورة في ملف واحد | |
| # نستخدم صيغة 'best[ext=mp4]' لضمان التوافق مع المتصفح | |
| cmd = [ | |
| 'yt-dlp', | |
| '-f', 'best[ext=mp4]/best', | |
| '-o', '-', | |
| '--no-playlist', | |
| url | |
| ] | |
| proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) | |
| # إرسال البيانات كبث مباشر مع ترويسة MP4 | |
| return Response(proc.stdout, mimetype='video/mp4') | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |