(client, m: Message)
| 102 | @Client.on_message(filters.command(["stream", f"stream@{USERNAME}"]) & filters.group & ~filters.edited) |
| 103 | @authorized_users_only |
| 104 | async def stream(client, m: Message): |
| 105 | msg = await m.reply_text("🔄 `Processing ...`") |
| 106 | chat_id = m.chat.id |
| 107 | media = m.reply_to_message |
| 108 | if not media and not ' ' in m.text: |
| 109 | await msg.edit("❗ __Send Me An Live Stream Link / YouTube Video Link / Reply To An Video To Start Video Streaming!__") |
| 110 | |
| 111 | elif ' ' in m.text: |
| 112 | text = m.text.split(' ', 1) |
| 113 | query = text[1] |
| 114 | if not 'http' in query: |
| 115 | return await msg.edit("❗ __Send Me An Live Stream Link / YouTube Video Link / Reply To An Video To Start Video Streaming!__") |
| 116 | regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" |
| 117 | match = re.match(regex, query) |
| 118 | if match: |
| 119 | await msg.edit("🔄 `Starting YouTube Video Stream ...`") |
| 120 | try: |
| 121 | meta = ydl.extract_info(query, download=False) |
| 122 | formats = meta.get('formats', [meta]) |
| 123 | for f in formats: |
| 124 | ytstreamlink = f['url'] |
| 125 | link = ytstreamlink |
| 126 | search = VideosSearch(query, limit=1) |
| 127 | opp = search.result()["result"] |
| 128 | oppp = opp[0] |
| 129 | thumbid = oppp["thumbnails"][0]["url"] |
| 130 | split = thumbid.split("?") |
| 131 | thumb = split[0].strip() |
| 132 | except Exception as e: |
| 133 | return await msg.edit(f"❌ **YouTube Download Error !** \n\n`{e}`") |
| 134 | print(e) |
| 135 | |
| 136 | else: |
| 137 | await msg.edit("🔄 `Starting Live Video Stream ...`") |
| 138 | link = query |
| 139 | thumb = "https://telegra.ph/file/3e14128ad5c9ec47801bd.jpg" |
| 140 | |
| 141 | vid_call = VIDEO_CALL.get(chat_id) |
| 142 | if vid_call: |
| 143 | await VIDEO_CALL[chat_id].stop() |
| 144 | VIDEO_CALL.pop(chat_id) |
| 145 | await sleep(3) |
| 146 | |
| 147 | aud_call = AUDIO_CALL.get(chat_id) |
| 148 | if aud_call: |
| 149 | await AUDIO_CALL[chat_id].stop() |
| 150 | AUDIO_CALL.pop(chat_id) |
| 151 | await sleep(3) |
| 152 | |
| 153 | try: |
| 154 | await sleep(2) |
| 155 | await group_call.join(chat_id) |
| 156 | await group_call.start_video(link, with_audio=True, repeat=False) |
| 157 | VIDEO_CALL[chat_id] = group_call |
| 158 | await msg.delete() |
| 159 | await m.reply_photo( |
| 160 | photo=thumb, |
| 161 | caption=f"▶️ **Started [Video Streaming]({query}) In {m.chat.title} !**", |
nothing calls this directly
no outgoing calls
no test coverage detected