Anoar2025 commited on
Commit
448ff17
·
verified ·
1 Parent(s): 3951a3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -56
app.py CHANGED
@@ -3,7 +3,7 @@ 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">
@@ -12,69 +12,26 @@ HTML_TEMPLATE = """
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>
@@ -90,12 +47,21 @@ def index():
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__':
 
3
 
4
  app = Flask(__name__)
5
 
6
+ # واجهة المستخدم المحسنة
7
  HTML_TEMPLATE = """
8
  <!DOCTYPE html>
9
  <html lang="ar" dir="rtl">
 
12
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
13
  <title>Adeeb Streamer | بوابة البث الذكي</title>
14
  <style>
15
+ 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; }
16
+ .container { background: #161b22; padding: 2rem; border-radius: 15px; border: 1px solid #30363d; width: 90%; max-width: 500px; text-align: center; }
17
+ h1 { color: #58a6ff; }
18
+ input { width: 100%; padding: 12px; margin: 1rem 0; border-radius: 8px; border: 1px solid #30363d; background: #0d1117; color: white; }
19
+ button { background-color: #238636; color: white; border: none; padding: 12px 25px; border-radius: 8px; cursor: pointer; width: 100%; font-weight: bold; }
20
+ .note { font-size: 0.8rem; color: #8b949e; margin-top: 1rem; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  </style>
22
  </head>
23
  <body>
24
  <div class="container">
25
  <h1>Adeeb Streamer 🚀</h1>
26
+ <input type="text" id="videoUrl" placeholder="الصق رابط يوتيوب هنا...">
27
+ <button onclick="startStream()">تشغيل الآن</button>
28
+ <p class="note">ملاحظة: قد يستغرق بدء التشغيل ثواني قليلة لجلب البيانات</p>
 
29
  </div>
 
30
  <script>
31
  function startStream() {
32
  const url = document.getElementById('videoUrl').value;
33
  if (url) {
34
  window.location.href = '/stream?url=' + encodeURIComponent(url);
 
 
35
  }
36
  }
37
  </script>
 
47
  def stream():
48
  url = request.args.get('url')
49
  if not url:
50
+ return "الرابط مطلوب", 400
51
+
52
+ # التعديل الجوهري هنا: نطلب أفضل جودة MP4 تحتوي على الصوت والصورة في ملف واحد
53
+ # نستخدم صيغة 'best[ext=mp4]' لضمان التوافق مع المتصفح
54
+ cmd = [
55
+ 'yt-dlp',
56
+ '-f', 'best[ext=mp4]/best',
57
+ '-o', '-',
58
+ '--no-playlist',
59
+ url
60
+ ]
61
 
 
 
62
  proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
63
 
64
+ # إرسال البيانات كبث مباشر مع ترويسة MP4
65
  return Response(proc.stdout, mimetype='video/mp4')
66
 
67
  if __name__ == '__main__':