File size: 5,872 Bytes
69b885f 4cb4020 83a2f7b 4cb4020 6f15580 09d1e4c 0d3ebe0 c748144 10f6ba8 0d3ebe0 10f6ba8 0d3ebe0 10f6ba8 0d3ebe0 10f6ba8 6f15580 0d3ebe0 10f6ba8 04f3007 10f6ba8 0d3ebe0 04f3007 0d3ebe0 04f3007 0d3ebe0 04f3007 10f6ba8 0d3ebe0 69b885f 0d3ebe0 04f3007 10f6ba8 0d3ebe0 04f3007 10f6ba8 0d3ebe0 10f6ba8 0d3ebe0 10f6ba8 0d3ebe0 69b885f 0d3ebe0 10f6ba8 0d3ebe0 04f3007 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | import streamlit as st
import asyncio
import os
import time
import subprocess
import threading
from datetime import datetime
from TikTokLive import TikTokLiveClient
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# โ๏ธ ุงูุฅุนุฏุงุฏุงุช ุงูุซุงุจุชุฉ (ุชุนุฏู ู
ุฑุฉ ูุงุญุฏุฉ ููุท)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
TIKTOK_USERNAME = "@osei_iraq" # ุงูุญุณุงุจ ุงูู
ุฑุงุฏ ุฑุตุฏู
YOUTUBE_STREAM_KEY = "p0ep-37wz-q3yg-7twf-3acb" # ู
ูุชุงุญ ุจุซ ููุชููุจ
POLL_INTERVAL = 60 # ูุญุต ูู ุฏูููุฉ
YT_RTMP_URL = f"rtmp://a.rtmp.youtube.com/live2/{YOUTUBE_STREAM_KEY}"
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ๐ ู
ุญุฑู ุงูุนู
ู ูู ุงูุฎูููุฉ (Background Engine)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
def run_monitor():
"""ูุฐู ุงูุฏุงูุฉ ูู ุงูุชู ุชุธู ุชุนู
ู ุญุชู ูู ุฃุบููุช ุงูุตูุญุฉ"""
print("โ
ุจุฏุฃ ู
ุญุฑู ุงูู
ุฑุงูุจุฉ ุงูุชููุงุฆู 24/7...")
while True:
try:
# ูุญุต ุญุงูุฉ ุงูุจุซ
client = TikTokLiveClient(unique_id=TIKTOK_USERNAME)
is_live = asyncio.run(client.is_live())
if is_live:
print(f"[{datetime.now().strftime('%H:%M')}] ๐ด ุงูุจุซ ุจุฏุฃ! ุฌุงุฑู ุงูููู ุฅูู ููุชููุจ...")
# ุฃู
ุฑ ุงูููู ุงูู
ุจุงุดุฑ - ู
ุญุณูู ููุตูุช
cmd = (
f"streamlink https://www.tiktok.com/{TIKTOK_USERNAME}/live best --hls-live-edge 3 --stdout | "
f"ffmpeg -thread_queue_size 8192 -i pipe:0 "
f"-c:v copy "
f"-c:a aac -ar 48000 -b:a 192k -ac 2 "
f"-af 'highpass=f=200,lowpass=f=3000,aresample=async=1' "
f"-buffer_size 1024k "
f"-fflags +genpts+igndts "
f"-max_interleave_delta 0 "
f"-f flv {YT_RTMP_URL}"
)
process = subprocess.Popen(cmd, shell=True)
process.wait() # ุณููุชุธุฑ ููุง ุญุชู ููุชูู ุงูุจุซ ูุนููุงู
print("โน๏ธ ุงูุชูู ุงูุจุซุ ุงูุนูุฏุฉ ููุถุน ุงูู
ุฑุงูุจุฉ...")
else:
#print(f"๐ ูุญุต: {TIKTOK_USERNAME} ุบูุฑ ู
ุชุตู ุญุงููุงู.")
pass
except Exception as e:
print(f"โ ๏ธ ุชูุจูู: {e}")
time.sleep(POLL_INTERVAL)
# ุชุดุบูู ุงูุฎูุท ุงูุฎููู ููุฑ ุชุดุบูู ุงูุชุทุจูู (ู
ุฑุฉ ูุงุญุฏุฉ ููุท)
if "background_started" not in st.session_state:
# ุงูุจุญุซ ุนู ุฃู ุฎูุท ูุนู
ู ู
ุณุจูุงู ูู
ูุน ุงูุชูุฑุงุฑ
for thread in threading.enumerate():
if thread.name == "TikTokMonitorThread":
st.session_state.background_started = True
break
else:
# ุฅุฐุง ูู
ููู ููุงู ุฎูุทุ ูุจุฏุฃ ูุงุญุฏ ุฌุฏูุฏ
monitor_thread = threading.Thread(target=run_monitor, name="TikTokMonitorThread", daemon=True)
monitor_thread.start()
st.session_state.background_started = True
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ๐จ ูุงุฌูุฉ ุงูู
ุณุชุฎุฏู
(ููู
ุชุงุจุนุฉ ููุท)
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
st.set_page_config(page_title="AutoStreamer 24/7", page_icon="๐ด")
# ุชูุณูู ุงูุดูู
st.markdown("""
<style>
.status-box {
padding: 20px; border-radius: 15px; background-color: #0e1117;
border: 1px solid #262730; text-align: center;
}
.live-tag { color: #ff4b4b; font-weight: bold; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
</style>
""", unsafe_allow_html=True)
st.title("๐ด ูุธุงู
ุงูุจุซ ุงูุชููุงุฆู ุงูู
ุณุชู
ุฑ")
st.markdown(f"""
<div class="status-box">
<h3>ุญุงูุฉ ุงููุธุงู
: <span style="color: #00ff00;">ู
ุชุตู ููุนู
ู โ
</span></h3>
<p>ูุชู
ู
ุฑุงูุจุฉ ุงูุญุณุงุจ: <b>{TIKTOK_USERNAME}</b></p>
<p class="live-tag">ุงููุธุงู
ูุนู
ู ูู ุฎูููุฉ ุงูุณูุฑูุฑ ุงูุขู</p>
</div>
""", unsafe_allow_html=True)
st.success("โน๏ธ ูู
ููู ุฅุบูุงู ูุฐู ุงูุตูุญุฉ ุงูุขู. ุงูุณูุฑูุฑ ุณูููู
ุจุฑุตุฏ ุงูุจุซ ูุฑูุนู ุชููุงุฆูุงู ูู ุฃู ููุช (ุงูููู
ุ ุบุฏุงูุ ุฃู ุฃู ููุช).")
st.info("๐ก ุจู
ุฌุฑุฏ ุฃู ูุจุฏุฃ ุตุงุญุจ ุงูุญุณุงุจ ุงูุจุซุ ุณูููู
ุงููุธุงู
ุจูุชุญู ููุฑุงู ููููู ุฅูู ููุงุชู ุนูู ููุชููุจ.")
# ุนุฑุถ ุงูุณุฌูุงุช ุงูุจุณูุทุฉ
if st.button("ุชุญุฏูุซ ุงูุญุงูุฉ"):
st.rerun()
st.write(f"ุขุฎุฑ ูุญุต ุชู
ูู: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|