Reoo88 commited on
Commit
04f3007
·
verified ·
1 Parent(s): c748144

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +16 -10
streamlit_app.py CHANGED
@@ -27,27 +27,33 @@ def run_monitor():
27
  # فحص حالة البث
28
  client = TikTokLiveClient(unique_id=TIKTOK_USERNAME)
29
  is_live = asyncio.run(client.is_live())
30
-
31
  if is_live:
32
  print(f"[{datetime.now().strftime('%H:%M')}] 🔴 البث بدأ! جاري النقل إلى يوتيوب...")
33
-
34
- # أمر النقل المباشر
35
- # نستخدم shell=True لضمان عمل الـ pipe (|) بشكل صحيح
36
  cmd = (
37
- f"streamlink https://www.tiktok.com/{TIKTOK_USERNAME}/live best --stdout | "
38
- f"ffmpeg -i pipe:0 -c:v copy -c:a aac -ar 44100 -ab 128k -f flv {YT_RTMP_URL}"
 
 
 
 
 
 
 
39
  )
40
-
41
  process = subprocess.Popen(cmd, shell=True)
42
  process.wait() # سينتظر هنا حتى ينتهي البث فعلياً
43
  print("⏹️ انتهى البث، العودة لوضع المراقبة...")
44
  else:
45
  #print(f"🔍 فحص: {TIKTOK_USERNAME} غير متصل حالياً.")
46
  pass
47
-
48
  except Exception as e:
49
  print(f"⚠️ تنبيه: {e}")
50
-
51
  time.sleep(POLL_INTERVAL)
52
 
53
  # تشغيل الخيط الخلفي فور تشغيل التطبيق (مرة واحدة فقط)
@@ -99,4 +105,4 @@ st.info("💡 بمجرد أن يبدأ صاحب الحساب البث، سيقو
99
  if st.button("تحديث الحالة"):
100
  st.rerun()
101
 
102
- st.write(f"آخر فحص تم في: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
 
27
  # فحص حالة البث
28
  client = TikTokLiveClient(unique_id=TIKTOK_USERNAME)
29
  is_live = asyncio.run(client.is_live())
30
+
31
  if is_live:
32
  print(f"[{datetime.now().strftime('%H:%M')}] 🔴 البث بدأ! جاري النقل إلى يوتيوب...")
33
+
34
+ # أمر النقل المباشر - محسّن للصوت
 
35
  cmd = (
36
+ f"streamlink https://www.tiktok.com/{TIKTOK_USERNAME}/live best --hls-live-edge 3 --stdout | "
37
+ f"ffmpeg -thread_queue_size 8192 -i pipe:0 "
38
+ f"-c:v copy "
39
+ f"-c:a aac -ar 48000 -b:a 192k -ac 2 "
40
+ f"-af 'highpass=f=200,lowpass=f=3000,aresample=async=1' "
41
+ f"-buffer_size 1024k "
42
+ f"-fflags +genpts+igndts "
43
+ f"-max_interleave_delta 0 "
44
+ f"-f flv {YT_RTMP_URL}"
45
  )
46
+
47
  process = subprocess.Popen(cmd, shell=True)
48
  process.wait() # سينتظر هنا حتى ينتهي البث فعلياً
49
  print("⏹️ انتهى البث، العودة لوضع المراقبة...")
50
  else:
51
  #print(f"🔍 فحص: {TIKTOK_USERNAME} غير متصل حالياً.")
52
  pass
53
+
54
  except Exception as e:
55
  print(f"⚠️ تنبيه: {e}")
56
+
57
  time.sleep(POLL_INTERVAL)
58
 
59
  # تشغيل الخيط الخلفي فور تشغيل التطبيق (مرة واحدة فقط)
 
105
  if st.button("تحديث الحالة"):
106
  st.rerun()
107
 
108
+ st.write(f"آخر فحص تم في: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")