async def ytplay(requested_by, query, message): global playing ydl_opts = {"format": "bestaudio"} m = await message.reply_text(f"__**Searching for {query} on YouTube.**__", quote=False) try: results = await arq.youtube(query) if not results.ok: await message.reply_text(results.result) return results = results.result link = f"https://youtube.com{results[0].url_suffix}" title = results[0].title thumbnail = results[0].thumbnails[0] duration = results[0].duration views = results[0].views if time_to_seconds(duration) >= 1800: await m.edit("__**Bruh! Only songs within 30 Mins.**__") playing = False return except Exception as e: await m.edit("__**Found No Song Matching Your Query.**__") playing = False print(str(e)) return await m.edit("__**Processing Thumbnail.**__") await generate_cover(requested_by, title, views, duration, thumbnail) await m.edit("__**Downloading Music.**__") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) await m.edit("__**Transcoding.**__") os.rename(audio_file, "audio.webm") transcode("audio.webm") await m.delete() caption = ( f"🏷 **Name:** [{title[:35]}]({link})\n⏳ **Duration:** {duration}\n" + f"🎧 **Requested By:** {message.from_user.mention}\n📡 **Platform:** YouTube" ) m = await message.reply_photo( photo="final.png", caption=caption, ) os.remove("final.png") await asyncio.sleep(int(time_to_seconds(duration))) playing = False await m.delete()
async def ytplay(requested_by, query): global playing ydl_opts = {"format": "bestaudio"} m = await app.send_message( sudo_chat_id, text=f"Searching for `{query}` on YouTube" ) try: results = YoutubeSearch(query, max_results=1).to_dict() link = f"https://youtube.com{results[0]['url_suffix']}" title = results[0]["title"] thumbnail = results[0]["thumbnails"][0] duration = results[0]["duration"] views = results[0]["views"] if time_to_seconds(duration) >= 1800: # duration limit await m.edit("Bruh! Only songs within 30 Mins") playing = False return except Exception as e: await m.edit( "Found Literally Nothing!, You Should Work On Your English." ) playing = False print(str(e)) return await m.edit("Processing Thumbnail.") await generate_cover(requested_by, title, views, duration, thumbnail) await m.edit("Downloading Music.") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) await m.edit("Transcoding") os.rename(audio_file, "audio.webm") transcode("audio.webm") await m.delete() m = await app.send_photo( chat_id=sudo_chat_id, caption=f"Playing [{title}]({link}) Via YouTube", photo="final.png", ) os.remove("final.png") await asyncio.sleep(time_to_seconds(duration)) playing = False await m.delete()
async def ytplay(requested_by, query): global playing ydl_opts = {"format": "bestaudio"} m = await send(f"__**Procurando por {query} no YouTube.**__") try: results = await arq.youtube(query, 1) link = f"https://youtube.com{results[0].url_suffix}" title = results[0].title thumbnail = results[0].thumbnails[0] duration = results[0].duration views = results[0].views if time_to_seconds(duration) >= 1800: await m.edit( "__**Caramba! Apenas músicas dentro de 30 minutos.**__") playing = False return except Exception as e: await m.edit("__**OK IREI TOCA LA.**__") playing = False print(str(e)) return await m.edit("__**Processing Thumbnail.**__") await generate_cover(requested_by, title, views, duration, thumbnail) await m.edit("__**Downloading Music.**__") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) await m.edit("__**Transcoding.**__") os.rename(audio_file, "audio.webm") transcode("audio.webm") await m.delete() m = await app.send_photo( chat_id=sudo_chat_id, caption=f"**Playing** __**[{title}]({link})**__ **Via YouTube.**", photo="final.png", ) os.remove("final.png") await asyncio.sleep(int(time_to_seconds(duration))) playing = False await m.delete()
async def ytplay(requested_by, query): global playing ydl_opts = {"format": "bestaudio"} m = await app.send_message( sudo_chat_id, text=f"Searching for `{query}` on YouTube" ) try: results = YoutubeSearch(query, max_results=1).to_dict() link = f"https://youtube.com{results[0]['url_suffix']}" title = results[0]["title"] thumbnail = results[0]["thumbnails"][0] duration = results[0]["duration"] views = results[0]["views"] if time_to_seconds(duration) >= 1800: # duration limit await m.edit("Bruh! Only songs within 30 Mins") playing = False return except Exception as e: await m.edit( "Found Literally Nothing!, You Should Work On Your English." ) playing = False print(str(e)) return await m.edit("Processing Thumbnail.") await generate_cover(requested_by, title, views, duration, thumbnail) await m.edit("Downloading Music.") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) os.rename(audio_file, "audio.webm") await m.delete() m = await app.send_photo( chat_id=sudo_chat_id, caption=f"Playing [{title}]({link}) Via YouTube", photo="final.png", reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("Skip", callback_data="end")]] ), parse_mode="markdown", ) os.remove("final.png") s = await asyncio.create_subprocess_shell( "mpv audio.webm --no-video", stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) await s.wait() await m.delete() playing = False
def apply2Clicked(self): self.dte = self.ui.dateTimeEdit_2.dateTime() self.dte = re.search(r'\(.+\)', str(self.dte)) self.dt = str(self.dte.group(0)) self.dt = self.dt.replace('(', '') self.dt = self.dt.replace(')', '') self.dateandtime = re.split(r',\s', self.dt) self.year = int(self.dateandtime[0]) self.month = int(self.dateandtime[1]) self.day = int(self.dateandtime[2]) self.hour = int(self.dateandtime[3]) self.minute = int(self.dateandtime[4]) self.second = int(self.dateandtime[5]) change_files_creation_time(time_to_seconds( self.month, self.day, self.year, self.hour, self.minute, self.second ), self.filenames) self.ui.textBrowser_2.setText(str(get_mod_and_cr_time(self.filenames)))
async def ytplay(_, message: Message): global blacks, is_playing, current_player, s, m, d if message.from_user.id in blacks: await message.reply_text("You're Blacklisted, So Stop Spamming.") return elif is_playing: list_of_admins = await getadmins(message.chat.id) if message.from_user.id in list_of_admins: pass else: d = await message.reply_text( text="stop interrupting while others playing!", disable_notification=True, ) await asyncio.sleep(2) # 2 sec delay before deletion await d.delete() await message.delete() return elif len(message.command) < 2: await message.reply_text("/youtube requires one argument") return await prepare(s, m, message) ydl_opts = {"format": "bestaudio"} query = kwairi(message) current_player = message.from_user.id is_playing = True m = await message.reply_text(f"Searching for `{query}`on YouTube") try: results = YoutubeSearch(query, max_results=1).to_dict() link = f"https://youtube.com{results[0]['url_suffix']}" title = results[0]["title"] thumbnail = results[0]["thumbnails"][0] duration = results[0]["duration"] views = results[0]["views"] if time_to_seconds(duration) >= 1800: #duration limit await m.edit("Bruh! Only songs within 30 Mins") is_playing = False return except Exception as e: await m.edit( "Found Literally Nothing!, You Should Work On Your English.") is_playing = False print(str(e)) return await m.edit("Processing Thumbnail.") await generate_cover(message, title, views, duration, thumbnail) await m.edit("Downloading Music.") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) os.rename(audio_file, "audio.webm") await m.delete() m = await message.reply_photo( caption= f"Playing [{title}]({link}) Via YouTube #music\nRequested by {message.from_user.first_name}", photo="final.png", reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("STOP", callback_data="end")]]), parse_mode="markdown", ) os.remove("final.png") s = await asyncio.create_subprocess_shell( "mpv audio.webm --no-video", stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, ) await s.wait() await m.delete() is_playing = False
async def ytplay(requested_by, query, message): global playing ydl_opts = {"format": "bestaudio"} #n = await send(f"__**Searching for {query} on YouTube.**__") m = await message.reply_text( f"__**Searching for {query} on YouTube.**__", quote=False ) try: results = await arq.youtube(query) if not results.ok: await message.reply_text(results.result) return results = results.result link = f"https://youtube.com{results[0].url_suffix}" title = results[0].title thumbnail = results[0].thumbnails[0] duration = results[0].duration views = results[0].views songname = title.lower() detecting = detect(songname) wordfilter = Wordfilter() wordfilter.addWords(['yamete', 'kudasai', 'arigato', 'hentai']) if wordfilter.blacklisted(songname): await m.edit(f"__**Shame on you ! {requested_by}\nNot allowed song !!!**__\n@wuminjun block him!\n{songname}") playing = False return if detecting == "ko": await m.edit(f"__**Not allowed Language !!!**__ {songname}") playing = False return if time_to_seconds(duration) >= 3600: await m.edit("__**Bruh! Only songs within 60 Mins.**__") playing = False return except Exception as e: await m.edit("__**Found No Song Matching Your Query.**__") playing = False print(str(e)) return await m.edit("__**Processing Thumbnail.**__") await app.update_profile(first_name=f"🔉{title[:35]} ",bio = f"__{title[:35]}__ ijro etilmoqda") await generate_cover(requested_by, title, views, duration, thumbnail) await m.edit("__**Downloading Music.**__") with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) await m.edit("__**Transcoding.**__") os.rename(audio_file, "audio.webm") transcode("audio.webm") await m.delete() caption = f"🏷 **Name:** [{title}]({link})\n⏳ **Duration:** {duration}\n" \ + f"🎧 **Requested By:** {requested_by}\n📡 **Platform:** YouTube" m = await message.reply_photo( photo="final.png", caption=caption, ) msg_id = m.message_id if message.chat.username != "music_streaming_channel": copy = await app.copy_message(SUDO_CHANNEL, message.chat.username, msg_id) await app.set_profile_photo(photo="final.png") #await app.pin_chat_message(SUDO_CHAT_ID, msg_id, disable_notification=True) os.remove("final.png") await asyncio.sleep(int(time_to_seconds(duration))) await m.delete() await copy.delete() photos = await app.get_profile_photos("me") await app.delete_profile_photos([p.file_id for p in photos[1:]]) playing = False