async def ytplay(_, message: Message): global que if message.chat.id in DISABLED_GROUPS: return lel = await message.reply("🔄 <b>Processing</b>") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor group first</b>", ) return try: await USER.join_chat(invitelink) await USER.send_message( message.chat.id, "I joined this group for playing music in VC" ) await lel.edit( "<b>helper userbot joined your chat</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for userbot! Make sure user is not banned in group." "\n\nOr manually add assistant to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot not in this chat, Ask admin to send /play command for first time or add {user.first_name} manually</i>" ) return await lel.edit("🔎 <b>Finding</b>") user_id = message.from_user.id user_name = message.from_user.first_name query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 <b>Processing</b>") ydl_opts = {"format": "bestaudio/best"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly." ) print(str(e)) return try: secmul, dur, dur_arr = 1, 0, duration.split(':') for i in range(len(dur_arr)-1, -1, -1): dur += (int(dur_arr[i]) * secmul) secmul *= 60 if (dur / 60) > DURATION_LIMIT: await lel.edit(f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!") return except: pass dlurl=url dlurl=dlurl.replace("youtube","youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ] ) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.active_chats: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption=f"#⃣ Your requested song <b>queued</b> at position {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: await callsmusic.set_stream(chat_id, file_path) except: message.reply("Group Call is not connected or I can't join it") return await message.reply_photo( photo="final.png", reply_markup=keyboard, caption="▶️ <b>Playing</b> here the song requested by {} via Youtube Music 😎".format( message.from_user.mention() ), ) os.remove("final.png") return await lel.delete()
async def lol_cb(b, cb): global que cbd = cb.data.strip() chat_id = cb.message.chat.id typed_=cbd.split(None, 1)[1] #useer_id = cb.message.reply_to_message.from_user.id try: x,query,useer_id = typed_.split("|") except: await cb.message.edit("Song Not Found") return useer_id = int(useer_id) if cb.from_user.id != useer_id: await cb.answer("You ain't the person who requested to play the song!", show_alert=True) return await cb.message.edit("Hang On... Player Starting") x=int(x) try: useer_name = cb.message.reply_to_message.from_user.first_name except: useer_name = cb.message.from_user.first_name results = YoutubeSearch(query, max_results=5).to_dict() resultss=results[x]["url_suffix"] title=results[x]["title"][:40] thumbnail=results[x]["thumbnails"][0] duration=results[x]["duration"] views=results[x]["views"] url = f"https://youtube.com{resultss}" try: secmul, dur, dur_arr = 1, 0, duration.split(':') for i in range(len(dur_arr)-1, -1, -1): dur += (int(dur_arr[i]) * secmul) secmul *= 60 if (dur / 60) > DURATION_LIMIT: await cb.message.edit(f"Music longer than {DURATION_LIMIT}min are not allowed to play") return except: pass try: thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) except Exception as e: print(e) return dlurl=url dlurl=dlurl.replace("youtube","youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ] ) requested_by = useer_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) if chat_id in callsmusic.active_chats: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title try: r_by = cb.message.reply_to_message.from_user except: r_by = cb.message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await cb.message.delete() await b.send_photo(chat_id, photo="final.png", caption=f"#⃣ Song requested by {r_by.mention} <b>queued</b> at position {position}!", reply_markup=keyboard, ) os.remove("final.png") else: que[chat_id] = [] qeue = que.get(chat_id) s_name = title try: r_by = cb.message.reply_to_message.from_user except: r_by = cb.message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await callsmusic.set_stream(chat_id, file_path) await cb.message.delete() await b.send_photo(chat_id, photo="final.png", reply_markup=keyboard, caption=f"▶️ <b>Playing</b> here the song requested by {r_by.mention} via Youtube Music 😎", ) os.remove("final.png")
async def play(_, message: Message): global que global useer if message.chat.id in DISABLED_GROUPS: return lel = await message.reply("🔄 <b>Processing</b>") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor group first</b>", ) return try: await USER.join_chat(invitelink) await USER.send_message( message.chat.id, "I joined this group for playing music in VC" ) await lel.edit( "<b>helper userbot joined your chat</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for userbot! Make sure user is not banned in group." "\n\nOr manually add assistant to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot not in this chat, Ask admin to send /play command for first time or add {user.first_name} manually</i>" ) return text_links=None await lel.edit("🔎 <b>Finding</b>") if message.reply_to_message: if message.reply_to_message.audio: pass entities = [] toxt = message.reply_to_message.text \ or message.reply_to_message.caption if message.reply_to_message.entities: entities = message.reply_to_message.entities + entities elif message.reply_to_message.caption_entities: entities = message.reply_to_message.entities + entities urls = [entity for entity in entities if entity.type == 'url'] text_links = [ entity for entity in entities if entity.type == 'text_link' ] else: urls=None if text_links: urls = True user_id = message.from_user.id user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" audio = ( (message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None ) if audio: if round(audio.duration / 60) > DURATION_LIMIT: await lel.edit( f"❌ Videos longer than {DURATION_LIMIT} minute(s) aren't allowed to play!" ) return keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ] ) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/f6086f8909fbfeb0844f2.png" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert( (await message.reply_to_message.download(file_name)) if not path.isfile(path.join("downloads", file_name)) else file_name ) elif urls: query = toxt await lel.edit("🎵 <b>Processing</b>") ydl_opts = {"format": "bestaudio/best"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly." ) print(str(e)) return try: secmul, dur, dur_arr = 1, 0, duration.split(':') for i in range(len(dur_arr)-1, -1, -1): dur += (int(dur_arr[i]) * secmul) secmul *= 60 if (dur / 60) > DURATION_LIMIT: await lel.edit(f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!") return except: pass dlurl=url dlurl=dlurl.replace("youtube","youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ] ) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio/best"} try: results = YoutubeSearch(query, max_results=5).to_dict() except: await lel.edit("Give me something to play") # Looks like hell. Aren't it?? F**K OFF try: toxxt = "**Select the song you want to play**\n\n" j = 0 useer=user_name emojilist = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣",] while j < 5: toxxt += f"{emojilist[j]} <b>Title - [{results[j]['title']}](https://youtube.com{results[j]['url_suffix']})</b>\n" toxxt += f" ╚ <b>Duration</b> - {results[j]['duration']}\n" toxxt += f" ╚ <b>Views</b> - {results[j]['views']}\n" toxxt += f" ╚ <b>Channel</b> - {results[j]['channel']}\n\n" j += 1 koyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("1️⃣", callback_data=f'plll 0|{query}|{user_id}'), InlineKeyboardButton("2️⃣", callback_data=f'plll 1|{query}|{user_id}'), InlineKeyboardButton("3️⃣", callback_data=f'plll 2|{query}|{user_id}'), ], [ InlineKeyboardButton("4️⃣", callback_data=f'plll 3|{query}|{user_id}'), InlineKeyboardButton("5️⃣", callback_data=f'plll 4|{query}|{user_id}'), ], [InlineKeyboardButton(text="❌", callback_data="cls")], ] ) await lel.edit(toxxt,reply_markup=koyboard,disable_web_page_preview=True) # WHY PEOPLE ALWAYS LOVE P**N ?? (A point to think) return # Returning to pornhub except: await lel.edit("No Enough results to choose.. Starting direct play..") # print(results) try: url = f"https://youtube.com{results[0]['url_suffix']}" title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly." ) print(str(e)) return try: secmul, dur, dur_arr = 1, 0, duration.split(':') for i in range(len(dur_arr)-1, -1, -1): dur += (int(dur_arr[i]) * secmul) secmul *= 60 if (dur / 60) > DURATION_LIMIT: await lel.edit(f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!") return except: pass dlurl=url dlurl=dlurl.replace("youtube","youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ] ) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.active_chats: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption=f"#⃣ Your requested song <b>queued</b> at position {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: await callsmusic.set_stream(chat_id, file_path) except: message.reply("Group Call is not connected or I can't join it") return await message.reply_photo( photo="final.png", reply_markup=keyboard, caption="▶️ <b>Playing</b> here the song requested by {} via Youtube Music 😎".format( message.from_user.mention() ), ) os.remove("final.png") return await lel.delete()
async def play(_, message: Message): global que lel = await message.reply("🔄 <b>Processing</b>") try: conchat = await _.get_chat(message.chat.id) conv = conchat.linked_chat conid = conchat.linked_chat.id chid = conid except: await message.reply("Is chat even linked") return try: administrators = await get_administrators(conv) except: await message.reply("Am I admin of Channel") try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add helper to your channel</b>", ) try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor channel first</b>", ) return try: await USER.join_chat(invitelink) await lel.edit( "<b>helper userbot joined your channel</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your channel due to heavy requests for userbot! Make sure user is not banned in group." "\n\nOr manually add assistant to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot not in this chat, Ask channel admin to send /play command for first time or add {user.first_name} manually</i>" ) return message.from_user.id text_links = None message.from_user.first_name await lel.edit("🔎 <b>Finding</b>") message.from_user.id user_id = message.from_user.id message.from_user.first_name user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" if message.reply_to_message: if message.reply_to_message.audio: pass entities = [] toxt = message.reply_to_message.text or message.reply_to_message.caption if message.reply_to_message.entities: entities = message.reply_to_message.entities + entities elif message.reply_to_message.caption_entities: entities = message.reply_to_message.entities + entities urls = [entity for entity in entities if entity.type == "url"] text_links = [entity for entity in entities if entity.type == "text_link"] else: urls = None if text_links: urls = True audio = ( (message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None ) if audio: if round(audio.duration / 60) > DURATION_LIMIT: await lel.edit( f"❌ Videos longer than {DURATION_LIMIT} minute(s) aren't allowed to play!" ) return keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="cplaylist"), InlineKeyboardButton("Menu ⏯ ", callback_data="cmenu"), ], [InlineKeyboardButton(text="❌ Close", callback_data="ccls")], ] ) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/f6086f8909fbfeb0844f2.png" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file = await convert( (await message.reply_to_message.download(file_name)) if not path.isfile(path.join("downloads", file_name)) else file_name ) elif urls: query = toxt await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio/best"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly." ) print(str(e)) return try: secmul, dur, dur_arr = 1, 0, duration.split(":") for i in range(len(dur_arr) - 1, -1, -1): dur += int(dur_arr[i]) * secmul secmul *= 60 if (dur / 60) > DURATION_LIMIT: await lel.edit( f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!" ) return except: pass dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="cplaylist"), InlineKeyboardButton("Menu ⏯ ", callback_data="cmenu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="ccls")], ] ) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file = await convert(youtube.download(url)) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio/best"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly." ) print(str(e)) return try: secmul, dur, dur_arr = 1, 0, duration.split(":") for i in range(len(dur_arr) - 1, -1, -1): dur += int(dur_arr[i]) * secmul secmul *= 60 if (dur / 60) > DURATION_LIMIT: await lel.edit( f"❌ Videos longer than {DURATION_LIMIT} minutes aren't allowed to play!" ) return except: pass dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup( [ [ InlineKeyboardButton("📖 Playlist", callback_data="cplaylist"), InlineKeyboardButton("Menu ⏯ ", callback_data="cmenu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="ccls")], ] ) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file = await convert(youtube.download(url)) chat_id = chid if chat_id in callsmusic.active_chats: position = await queues.put(chat_id, file=file) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption=f"#⃣ Your requested song <b>queued</b> at position {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = chid que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file appendable = [s_name, r_by, loc] qeue.append(appendable) await callsmusic.set_stream(chat_id, file) await message.reply_photo( photo="final.png", reply_markup=keyboard, caption="▶️ <b>Playing</b> the song requested by {} via Youtube Music 😎 in Linked Channel".format( message.from_user.mention() ), ) os.remove("final.png") return await lel.delete()
async def play(_, message: Message): global que lel = await message.reply("🔄 **işlemde**") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Kanalda sesli açma yetkisi vermeyi unutma babuş</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Beni grubunuzda sesli sohbet ve davetle bağlantı yetkisi verin yoksa çalışamam...</b>", ) return try: await USER.join_chat(invitelink) await USER.send_message(message.chat.id, "Helloğ ben geldimke") await lel.edit("<b>Tamam artık burda ses botuğ</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Sel bekleme hatası 🔴 \Sayın {user.first_name} userbot için yoğun isteklerden dolayı grubunuza katılamadı! Kullanıcının grupta yasaklanmadığından emin olun." "\n\nYa da @zevzekcalarasistan manuel olarak ekleyin</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} Userbot bu sohbette değil, Yöneticiden ilk kez komut göndermesini /play isteyin veya ekleyin {user.first_name} kendiniz ekleyin</i>" ) return message.from_user.id message.from_user.first_name await lel.edit("🔎 **Finding**") message.from_user.id user_id = message.from_user.id message.from_user.first_name user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" audio = ((message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None) if audio: if round(audio.duration / 60) > DURATION_LIMIT: raise DurationLimitError( f"❌ {DURATION_LIMIT} dakikadan uzun videoların oynatılmasına izin verilmez!" ) keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/f6086f8909fbfeb0844f2.png" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await converter.convert(( await message.reply_to_message.download(file_name) ) if not path.isfile(path.join("downloads", file_name)) else file_name) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **İşlemde**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Şarkı bulunamadı Başka bir şarkı deneyin veya belki doğru şekilde yazın." ) print(str(e)) return keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [InlineKeyboardButton(text="YouTube'da İzle 🎬", url=f"{url}")], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption= f"#⃣ İstediğiniz şarkı pozisyonda ** sıraya girdi ** {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: message.reply( "Dostum sesli sohbet açık değil nasıl müzik çalmamı bekliyorsun..." ) return await message.reply_photo( photo="final.png", reply_markup=keyboard, caption= "Youtube Music aracılığıyla {} tarafından istenen şarkı ▶ ️ ** burada çalınıyor **" .format(message.from_user.mention()), ) os.remove("final.png") return await lel.delete()
async def play(_, message: Message): global que lel = await message.reply("🔄 **Processing**") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "@VenomVcManager" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>Remember to add @VenomVcManager to your channel</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>Add me as admin of yor group first</b>", ) return try: await USER.join_chat(invitelink) await USER.send_message( message.chat.id, "I joined this group for playing music in VC") await lel.edit("<b>@VenomVcManager joined your chat</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 Flood Wait Error 🔴 \nUser {user.first_name} couldn't join your group due to heavy requests for @VenomVcManager! Make sure @VenomVcManager is not banned in group." "\n\nOr manually add @VenomVcManager to your Group and try again</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} not in this chat, Ask admin to send /play command for first time or add @VenomVcManager manually</i>" ) return message.from_user.id message.from_user.first_name text_links = None await lel.edit("🔎 **Finding**") message.from_user.id if message.reply_to_message: entities = [] toxt = message.reply_to_message.text or message.reply_to_message.caption if message.reply_to_message.entities: entities = message.reply_to_message.entities + entities elif message.reply_to_message.caption_entities: entities = message.reply_to_message.entities + entities urls = [entity for entity in entities if entity.type == 'url'] text_links = [ entity for entity in entities if entity.type == 'text_link' ] else: urls = None if text_links: urls = True user_id = message.from_user.id message.from_user.first_name user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" audio = ((message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None) if audio: if round(audio.duration / 60) > DURATION_LIMIT: raise DurationLimitError( f"❌ Videos longer than {DURATION_LIMIT} minute(s) aren't allowed to play!" ) keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/126bc465a9fa70ec4eaa5.jpg" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(( await message.reply_to_message.download(file_name) ) if not path.isfile(path.join("downloads", file_name)) else file_name) elif urls: query = toxt await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly.") print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **Processing**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "Song not found.Try another song or maybe spell it properly.") print(str(e)) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist", callback_data="playlist"), InlineKeyboardButton("Menu ⏯ ", callback_data="menu"), ], [ InlineKeyboardButton(text="🎬 YouTube", url=f"{url}"), InlineKeyboardButton(text="Download 📥", url=f"{dlurl}"), ], [InlineKeyboardButton(text="❌ Close", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption= f"#⃣ Your requested song **queued** at position {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: message.reply("Group Call is not connected or I can't join it") return await message.reply_photo( photo="final.png", reply_markup=keyboard, caption= "▶️ **Playing** here the song requested by {} via Youtube Music 😜". format(message.from_user.mention()), ) os.remove("final.png") return await lel.delete()
async def play(_, message: Message): global que lel = await message.reply("🔄 **ρяσ¢єѕѕιηg**") administrators = await get_administrators(message.chat) chid = message.chat.id try: user = await USER.get_me() except: user.first_name = "helper" usar = user wew = usar.id try: # chatdetails = await USER.get_chat(chid) await _.get_chat_member(chid, wew) except: for administrator in administrators: if administrator == message.from_user.id: if message.chat.title.startswith("Channel Music: "): await lel.edit( "<b>яємємвєя тσ α∂∂ нєℓρєя тσ уσυя ¢нαηηєℓ</b>", ) pass try: invitelink = await _.export_chat_invite_link(chid) except: await lel.edit( "<b>α∂∂ мє αѕ α∂мιη σƒ уσя gяσυρ ƒιяѕт</b>", ) return try: await USER.join_chat(invitelink) await USER.send_message( message.chat.id, "ι נσιηє∂ тнιѕ gяσυρ ƒσя ρℓαуιηg мυѕι¢ ιη ν¢") await lel.edit("<b>нєℓρєя υѕєявσт נσιηє∂ уσυя ¢нαт</b>", ) except UserAlreadyParticipant: pass except Exception: # print(e) await lel.edit( f"<b>🔴 ƒℓσσ∂ ωαιт єяяσя 🔴 \ηυѕєя [Userbot](https://t.me/lightningmujik) ¢συℓ∂η'т נσιη уσυя gяσυρ ∂υє тσ нєανу яєqυєѕтѕ ƒσя υѕєявσт! мαкє ѕυяє υѕєя ιѕ ησт вαηηє∂ ιη gяσυρ." "\η\ησя мαηυαℓℓу α∂∂ αѕѕιѕтαηт тσ уσυя gяσυρ αη∂ тяу αgαιη</b>", ) try: await USER.get_chat(chid) # lmoa = await client.get_chat_member(chid,wew) except: await lel.edit( f"<i> {user.first_name} υѕєявσт ησт ιη тнιѕ ¢нαт, αѕк α∂мιη тσ ѕєη∂ /υѕєявσтנσιη ¢σммαη∂ ƒσя ƒιяѕт тιмє σя α∂∂ [𝕌𝕤𝕖𝕣𝕓𝕠𝕥](https://t.me/lightningmujik) мαηυαℓℓу</i>" ) return message.from_user.id message.from_user.first_name await lel.edit("🔎 **ƒιη∂ιηg**") message.from_user.id user_id = message.from_user.id message.from_user.first_name user_name = message.from_user.first_name rpk = "[" + user_name + "](tg://user?id=" + str(user_id) + ")" audio = ((message.reply_to_message.audio or message.reply_to_message.voice) if message.reply_to_message else None) if audio: if round(audio.duration / 60) > DURATION_LIMIT: raise DurationLimitError( f"❌ νι∂єσѕ ℓσηgєя тнαη {DURATION_LIMIT} мιηυтє(ѕ) αяєη'т αℓℓσωє∂ тσ ρℓαу!" ) keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 ρℓαуℓιѕт", callback_data="ρℓαуℓιѕт"), InlineKeyboardButton("Menu ⏯ ", callback_data="мєηυ"), ], [InlineKeyboardButton(text="❌ ¢ℓσѕє", callback_data="cls")], ]) file_name = get_file_name(audio) title = file_name thumb_name = "https://telegra.ph/file/b0c914fae86cb425793c3.jpg" thumbnail = thumb_name duration = round(audio.duration / 60) views = "Locally added" requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await converter.convert(( await message.reply_to_message.download(file_name) ) if not path.isfile(path.join("downloads", file_name)) else file_name) else: query = "" for i in message.command[1:]: query += " " + str(i) print(query) await lel.edit("🎵 **ρяσ¢єѕѕιηg**") ydl_opts = {"format": "bestaudio[ext=m4a]"} try: results = YoutubeSearch(query, max_results=1).to_dict() url = f"https://youtube.com{results[0]['url_suffix']}" # print(results) title = results[0]["title"][:40] thumbnail = results[0]["thumbnails"][0] thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) duration = results[0]["duration"] results[0]["url_suffix"] views = results[0]["views"] except Exception as e: await lel.edit( "ѕσηg ησт ƒσυη∂.тяу αησтнєя ѕσηg σя мαувє ѕρєℓℓ ιт ρяσρєяℓу.") print(str(e)) return keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 ρℓαуℓιѕт", callback_data="ρℓαуℓιѕт"), InlineKeyboardButton("мєηυ ⏯ ", callback_data="menu"), ], [InlineKeyboardButton(text="Watch On YouTube 🎬", url=f"{url}")], [InlineKeyboardButton(text="❌ ¢ℓσѕє", callback_data="cls")], ]) requested_by = message.from_user.first_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) chat_id = get_chat_id(message.chat) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await message.reply_photo( photo="final.png", caption= f"#⃣ уσυя яєqυєѕтє∂ ѕσηg **qυєυє∂** αт ρσѕιтιση {position}!", reply_markup=keyboard, ) os.remove("final.png") return await lel.delete() else: chat_id = get_chat_id(message.chat) que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) try: callsmusic.pytgcalls.join_group_call(chat_id, file_path) except: message.reply("gяσυρ ¢αℓℓ ιѕ ησт ¢σηηє¢тє∂ σя ι ¢αη'т נσιη ιт") return await message.reply_photo( photo="final.png", reply_markup=keyboard, caption= "▶️ **ρℓαуιηg** нєяє тнє ѕσηg яєqυєѕтє∂ ву {} νια уσυтυвє мυѕι¢ 😜". format(message.from_user.mention()), ) os.remove("final.png") return await lel.delete()
async def lol_cb(b, cb): global que cbd = cb.data.strip() chat_id = cb.message.chat.id typed_ = cbd.split(None, 1)[1] useer_id = cb.message.reply_to_message.from_user.id try: x, query = typed_.split("|") except: await cb.message.edit("Song Not Found") return if cb.from_user.id != useer_id: await cb.answer("You ain't the person who requested to play the song!", show_alert=True) return await cb.message.edit("Hang On... Player Starting") x = int(x) useer_name = cb.message.reply_to_message.from_user.first_name results = YoutubeSearch(query, max_results=5).to_dict() resultss = results[x]["url_suffix"] title = results[x]["title"][:40] thumbnail = results[x]["thumbnails"][0] duration = results[x]["duration"] views = results[x]["views"] url = f"https://youtube.com{resultss}" try: thumb_name = f"thumb{title}.jpg" thumb = requests.get(thumbnail, allow_redirects=True) open(thumb_name, "wb").write(thumb.content) except Exception as e: print(e) return dlurl = url dlurl = dlurl.replace("youtube", "youtubepp") keyboard = InlineKeyboardMarkup([ [ InlineKeyboardButton("📖 Playlist 📖", callback_data="playlist"), InlineKeyboardButton("🎛 Menu 🎛", callback_data="menu"), ], [ InlineKeyboardButton(text="📺 Watch On YouTube 📺", url=f"{url}"), ], [ InlineKeyboardButton(text="💬 Group 💬", url="https://t.me/unlimitedworld_tm_group"), InlineKeyboardButton(text="🔔 Channel 🔔", url="https://t.me/unlimitedworld_TM_channel"), ], [InlineKeyboardButton(text="❌ Close ❌", callback_data="cls")], ]) requested_by = useer_name await generate_cover(requested_by, title, views, duration, thumbnail) file_path = await convert(youtube.download(url)) if chat_id in callsmusic.pytgcalls.active_calls: position = await queues.put(chat_id, file=file_path) qeue = que.get(chat_id) s_name = title r_by = cb.message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) await cb.message.delete() await b.send_photo( chat_id, photo="final.png", caption= f"#⃣ Your requested song **queued** at position {position}!", reply_markup=keyboard, ) os.remove("final.png") else: que[chat_id] = [] qeue = que.get(chat_id) s_name = title r_by = cb.message.reply_to_message.from_user loc = file_path appendable = [s_name, r_by, loc] qeue.append(appendable) callsmusic.pytgcalls.join_group_call(chat_id, file_path) await cb.message.delete() await b.send_photo( chat_id, photo="final.png", reply_markup=keyboard, caption= f"▶️ **Playing** here the song requested by {cb.message.reply_to_message.from_user.mention} via Youtube Music 😜", ) os.remove("final.png")