def callback(ch, method, properties, body): youtube=SearchVideos(body, offset = 1, mode = "dict", max_results = 1) print(" [x] Received %r" % youtube.result()) time.sleep(body.count(b'.')) print(" [x] Done")
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text("دانلود دیگری در جریان است بعدا تلاش کن") return urlissed = get_text(message) pablo = await client.send_message(message.chat.id, f"`{urlissed} در حال بارگیری`") if not urlissed: await pablo.edit("خطا") return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 8: await pablo.edit( f" دقیقه است{duration}ویدیو های بیشتر از 8دقیقه دانلود نمیشوند. این مورد" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception: # await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**عنوان ➠** `{thum}` **درخواست :** `{urlissed}` **چنل :** `{thums}` **لینک :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, supports_streaming=True, progress=progress, progress_args=( pablo, c_time, f"`از یوتیوب {urlissed} در حال آپلود", file_stark, ), ) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text( "Unduhan yang lain sedang berlangsung, coba lagi nanti.") return urlissed = get_text(message) pablo = await client.send_message( message.chat.id, f"`Mendownload {urlissed} dari youtube, tunggu sebentar!`") if not urlissed: await pablo.edit( "Sintax, Perintah tidak valid. Silahkan periksa menu help untuk mengetahui lebih lanjut!" ) return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 8: await pablo.edit( f"❌ Video berdurasi lebih dari 8 menit tidak diperbolehkan, video yang diperbolehkan berdurasi {duration} minute(s)" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: #await pablo.edit(event, f"**Gagal mengunduh** \n**Terjadi kesalahan :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**Judul video :** `{thum}` \n**Requested For :** `{urlissed}` \n**Channel :** `{thums}` \n**Link :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, supports_streaming=True, progress=progress, progress_args=(pablo, c_time, f'`Uploading {urlissed}.. Song from YouTube Music!`', file_stark)) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def ytmusic(client, message: Message): urlissed = get_text(message) if not urlissed: await client.send_message( message.chat.id, "Invalid Command Syntax, Please Check Help Menu To Know More!", ) return global dl_limit if dl_limit >= 4: await message.reply_text( "Daisy's server busy due to too many downloads, try again after sometime." ) return pablo = await client.send_message( message.chat.id, f"`Getting {urlissed} From Youtube Servers. Please Wait.`" ) search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] mio[0]["duration"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" dl_limit = dl_limit + 1 await asyncio.sleep(0.6) sedlyf = wget.download(kekme) opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [ { "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "720", } ], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: with YoutubeDL(opts) as ytdl: ytdl_data = ytdl.extract_info(mo, download=True) except Exception as e: await pablo.edit(f"**Failed To Download** \n**Error :** `{str(e)}`") dl_limit = dl_limit - 1 return c_time = time.time() capy = f"**Song Name :** `{thum}` \n**Requested For :** `{urlissed}` \n**Channel :** `{thums}` \n**Link :** `{mo}`" file_stark = f"{ytdl_data['id']}.mp3" await client.send_audio( message.chat.id, audio=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), title=str(ytdl_data["title"]), performer=str(ytdl_data["uploader"]), thumb=sedlyf, caption=capy, progress=progress, progress_args=( pablo, c_time, f"`Uploading {urlissed} Song From YouTube Music!`", file_stark, ), ) dl_limit = dl_limit - 1 await pablo.delete() for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def process(v_url, dtype, opts): lazy = v_url sender = await lazy.get_sender() me = await lazy.client.get_me() if not sender.id == me.id: rkp = await lazy.reply("`processing...`") else: rkp = await lazy.edit("`processing...`") url = v_url.pattern_match.group(1) if not url: return await rkp.edit("`Error \nusage song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get('search_result') try: url = q[0]['link'] except: return await rkp.edit("`failed to find`") type = "audio" await rkp.edit("`Preparing to download...`") try: await rkp.edit("`Fetching data, please wait..`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await rkp.edit(f"`{str(DE)}`") return except ContentTooShortError: await rkp.edit("`The download content was too short.`") return except GeoRestrictedError: await rkp.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await rkp.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await rkp.edit("`There was an error during post processing.`") return except UnavailableVideoError: await rkp.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await rkp.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await rkp.edit("`There was an error during info extraction.`") return except Exception as e: await rkp.edit(f"{str(type(e)): {str(e)}}") return c_time = time.time() if dtype == "song": if int(rip_data["duration"] / 60) > 30: await rkp.edit("`Song is too long for processing.`") return await rkp.edit(f"`Preparing to upload song:`\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, attributes=[ DocumentAttributeAudio(duration=int(rip_data['duration']), title=str(rip_data['title']), performer=str(rip_data['uploader'])) ], progress_callback=lambda d, t: asyncio.get_event_loop( ).create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp3"))) else: if int(rip_data["duration"] / 60) > 10: await rkp.edit("`Video is too long for processing.`") return await rkp.edit(f"`Preparing to upload video:`\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp4", supports_streaming=True, caption=url, progress_callback=lambda d, t: asyncio.get_event_loop( ).create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp4")))
##########https://github.com/alexmercerind/youtube-search-python/########## from youtubesearchpython import SearchVideos, SearchPlaylists import sys print(sys.version) while True: if (sys.version[0]=="2"): what = raw_input("Playlist (p) search / Video (v) search? ") q = what.lower() if (q=="v" or q=="video" or q=="videos"): videos = SearchVideos(raw_input("Your video: "), offset = 1, mode = "json", max_results = 20) videos_result = videos.result() #Getting JSON result (You can set mode = "json", "dict" or "list") print(videos_result) if (q=="p" or q=="playlist" or q=="playlists"): playlists = SearchPlaylists(raw_input("Your playlist: "), offset = 1, mode = "json", max_results = 20) playlists_result = playlists.result() #Getting JSON result (You can set mode = "json", "dict" or "list") print(playlists_result) else if (sys.version[0]=="3"): what = input("Playlist (p) search / Video (v) search? ") q = what.lower() if (q=="v" or q=="video" or q=="videos"): videos = SearchVideos(input("Your video: "), offset = 1, mode = "json", max_results = 20) videos_result = videos.result() #Getting JSON result (You can set mode = "json", "dict" or "list") print(videos_result) if (q=="p" or q=="playlist" or q=="playlists"): playlists = SearchPlaylists(input("Your playlist: "), offset = 1, mode = "json", max_results = 20) playlists_result = playlists.result() #Getting JSON result (You can set mode = "json", "dict" or "list") print(playlists_result)
db.child(news_names).delete() posts_len = 0 os.remove(save_news) f = open(save_news, "w") f.close() links = [] title = [] img = [] try: if tesla_youtue: live_news = getreq(urls) news_titles = live_news.select('.list_news li a[title]') for i in reversed(news_titles): links.append(i.attrs['href']) else: search = SearchVideos("롤린", offset=1, mode="dict", max_results=20) result = search.result() for key in result['search_result']: links.append(key['link']) title.append(key['title']) img.append(key['thumbnails'][1]) read_save_news = open(save_news, "r") # 저장된 갤번호 읽어오기 read_data = [] for data in read_save_news: read_data.append(data.rstrip()) read_save_news.close() same_gall = all(elem in read_data for elem in links) if same_gall: print("전체복사")
async def download_video(v_url): pro = v_url sender = await pro.get_sender() me = await pro.client.get_me() pro1 = v_url.text if not sender.id == me.id: dc = await pro.reply("`processing, please weit...`") else: dc = await pro.edit("`processing, please weit...😍`") teamcobra = pro1[8:] if not teamcobra: return await dc.edit("`Error \nusage vsong <song name>`") search = SearchVideos(teamcobra, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: teamcobra = q[0]["link"] except: return await dc.edit("`failed to find your desired song`") type = "audio" await dc.edit("`Ok downloading your song🤓...`") if type == "audio": opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } song = False video = True try: await dc.edit("`Fetching data, please wait..😋😍😎`") with YoutubeDL(opts) as darkcobra: darkcobra_data = darkcobra.extract_info(teamcobra) except DownloadError as error: await dc.edit(f"`{str(error)}`") return except ContentTooShortError: await dc.edit("`Oof the download content was too short😮🤐.`") return except GeoRestrictedError: await dc.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website🤔.`" ) return except MaxDownloadsReached: await dc.edit("`Max-downloads limit has been reached😶.`") return except PostProcessingError: await dc.edit("`There was an error during post processing😐.`") return except UnavailableVideoError: await dc.edit( "`sorry, media is not available in the requested format.`") return except XAttrMetadataError as XAME: await dc.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await dc.edit("`There was an error while fetching your query...`") return except Exception as e: await dc.edit(f"{str(type(e)): {str(e)}}") return c_time = time.time() if song: await dc.edit(f"`Preparing to upload your video song😎 `\ \n**{darkcobra_data['title']}**\ \nby *{darkcobra_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{darkcobra_data['id']}.mp3", supports_streaming=True, attributes=[ DocumentAttributeAudio( duration=int(darkcobra_data["duration"]), title=str(darkcobra_data["title"]), performer=str(darkcobra_data["uploader"]), ) ], progress_callback=lambda d, t: asyncio.get_event_loop(). create_task( progress( d, t, v_url, c_time, "Uploading your video song😍..", f"{darkcobra_data['title']}.mp3", )), ) os.remove(f"{darkcobra_data['id']}.mp3") await v_url.delete() elif video: await dc.edit(f"`Preparing to upload your video song🤗❤ :`\ \n**{darkcobra_data['title']}**\ \nby *{darkcobra_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{darkcobra_data['id']}.mp4", supports_streaming=True, caption=darkcobra_data["title"], progress_callback=lambda d, t: asyncio.get_event_loop(). create_task( progress(d, t, v_url, c_time, "Uploading..", f"{darkcobra_data['title']}.mp4")), ) os.remove(f"{darkcobra_data['id']}.mp4") await dc.delete()
async def play_m(client, message): global s global s_dict group_call.client = client u_s = await edit_or_reply(message, "`Processing ...`") if message.reply_to_message: if message.reply_to_message.audio: await u_s.edit_text("`Please Wait, Let Me Download This File!`") audio = message.reply_to_message.audio audio_original = await message.reply_to_message.download() vid_title = audio.title or audio.file_name uploade_r = message.reply_to_message.audio.performer or "Unknown Artist." dura_ = message.reply_to_message.audio.duration dur = datetime.timedelta(seconds=dura_) raw_file_name = f"{audio.file_name}.raw" if audio.file_name else f"{audio.title}.raw" else: return await u_s.edit("`Reply To A File To PLay It.`") else: input_str = get_text(message) if not input_str: return await u_s.edit("`Give Me A Song Name !`") search = SearchVideos(str(input_str), offset=1, mode="dict", max_results=1) rt = search.result() try: result_s = rt["search_result"] except: return await u_s.edit( f"`Song Not Found With Name {input_str}, Please Try Giving Some Other Name.`" ) url = result_s[0]["link"] dur = result_s[0]["duration"] vid_title = result_s[0]["title"] yt_id = result_s[0]["id"] uploade_r = result_s[0]["channel"] opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "720", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: with YoutubeDL(opts) as ytdl: ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: await u_s.edit(f"**Failed To Download** \n**Error :** `{str(e)}`") return audio_original = f"{ytdl_data['id']}.mp3" raw_file_name = f"{vid_title}.raw" raw_file_name = await convert_to_raw(audio_original, raw_file_name) if not raw_file_name: return await u_s.edit( "`FFmpeg Failed To Convert Song To raw Format. Please Give Valid File.`" ) os.remove(audio_original) if not group_call.is_connected: try: await group_call.start(message.chat.id) except BaseException as e: return await u_s.edit(f"**Error While Joining VC:** `{e}`") group_call.input_filename = raw_file_name return await u_s.edit( f"Playing `{vid_title}` in `{message.chat.title}`!") else: s.append(raw_file_name) f_info = {"song name": vid_title, "singer": uploade_r, "dur": dur} s_dict[raw_file_name] = f_info return await u_s.edit(f"Added `{vid_title}` To Position `#{len(s)+1}`!" )
async def yt(ctx, arg1): vid = arg1 await ctx.message.delete() search = SearchVideos(vid, offset = 1, mode = "dict", max_results = 1) end = search.result() await ctx.send(end["search_result"][0]["link"])
up_partition = '<!-- Usage of azlyrics.com content by any third-party lyrics provider is prohibited by our licensing agreement. Sorry about that. -->' down_partition = '<!-- MxM banner -->' lyrics = lyrics.split(up_partition)[1] lyrics = lyrics.split(down_partition)[0] lyrics = lyrics.replace('<br>', '').replace('</br>', '').replace( '<br/>', '').replace('</div>', '').strip() return lyrics except Exception as e: return "Exception occurred \n" + str(e) while True: print('enter a song: ') name = input() print('searching...') search = SearchVideos(name, offset=1, mode="json", max_results=1) result = json.loads(search.result())['search_result'][0] print(result) link = result['link'] init_title = result['title'] title = "".join([c for c in init_title if c.isalpha() or c.isdigit()]).rstrip() artist = result['channel'] print('loading...') ydl_opts = { 'outtmpl': './downloads/{}.%(ext)s'.format(title), 'format': 'bestaudio/best', 'keepvideo':
async def download_video(ult): x = await eor(ult, "Processing..") url = ult.pattern_match.group(1) if not url: return await x.edit("**Error**\nUsage - `.vsong <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await x.edit("`No matching songs found...`") type = "audio" await x.edit("`Preparing to download...`") if type == "audio": opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: await x.edit("`Fetching data, please wait..`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: return await x.edit(f"`{str(DE)}`") except ContentTooShortError: return await x.edit("`The download content was too short.`") except GeoRestrictedError: return await x.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) except MaxDownloadsReached: return await x.edit("`Max-downloads limit has been reached.`") except PostProcessingError: return await x.edit("`There was an error during post processing.`") except UnavailableVideoError: return await x.edit("`Media is not available in the requested format.`" ) except XAttrMetadataError as XAME: return await x.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") except ExtractorError: return await x.edit("`There was an error during info extraction.`") except Exception as e: return await x.edit(f"{str(type(e)): {str(e)}}") upteload = """ Uploading... Song name - {} By - {} """.format(rip_data["title"], rip_data["uploader"]) await x.edit(f"`{upteload}`") await ultroid_bot.send_file( ult.chat_id, f"{rip_data['id']}.mp4", supports_streaming=True, caption= f"⫸ Song - {rip_data['title']}\n⫸ By - {rip_data['uploader']}\n", ) os.remove(f"{rip_data['id']}.mp4") await x.delete()
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text( "Sorry! **Another download is in progress !** Try Again After Sometime!" ) return urlissed = get_text(message) pablo = await client.send_message( message.chat.id, f"`Getting {urlissed} From Youtube Servers. Please Wait For Moment!`") if not urlissed: await pablo.edit("Invalid Command Syntax") return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 999: await pablo.edit( f"❌ Videos longer than 999 minute(s) aren't allowed, the provided video is {duration} minute(s)" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception: # await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" YTVID_BUTTONS = InlineKeyboardMarkup( [[InlineKeyboardButton("📺 Watch On YouTube 📺", url=f"{mo}")]]) capy = f"**🎧️ Music Video Name:** `{thum}` \n\n**👨💻️ Your Keyword:** `{urlissed}` \n**😉️ YouTube Channel:** `{thums}` \n**🔗️ Video Link :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, reply_markup=YTVID_BUTTONS, supports_streaming=True, progress=progress, progress_args=( pablo, c_time, f"`Please Wait! I'm Uploading` **{urlissed}** `From YouTube!`", file_stark, ), ) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def vid(client, message): input_str = get_text(message) pablo = await edit_or_reply(message, f"`Processing...`") if not input_str: await pablo.edit( "Invalid Command Syntax, Please Check Help Menu To Know More!") return await pablo.edit( f"`Getting {input_str} From Youtube Servers. Please Wait.`") search = SearchVideos(str(input_str), offset=1, mode="dict", max_results=1) rt = search.result() result_s = rt["search_result"] url = result_s[0]["link"] vid_title = result_s[0]["title"] yt_id = result_s[0]["id"] uploade_r = result_s[0]["channel"] thumb_url = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" await asyncio.sleep(0.6) downloaded_thumb = wget.download(thumb_url) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: with YoutubeDL(opts) as ytdl: ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**Video Name ➠** `{vid_title}` \n**Requested For ➠** `{input_str}` \n**Channel ➠** `{uploade_r}` \n**Link ➠** `{url}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=downloaded_thumb, caption=capy, supports_streaming=True, progress=progress, progress_args=( pablo, c_time, f"`Uploading {input_str} Song From YouTube Music!`", file_stark, ), ) await pablo.delete() for files in (downloaded_thumb, file_stark): if files and os.path.exists(files): os.remove(files)
from youtubesearchpython import SearchVideos search = SearchVideos("NoCopyrightSounds", offset=1, mode="json", max_results=20) print(search.result())
async def download_video(v_url): heaven = v_url sender = await heaven.get_sender() me = await heaven.client.get_me() if not sender.id == me.id: rider = await heaven.reply("`processing...`") else: rider = await heaven.edit("`processing...`") url = v_url.pattern_match.group(1) if not url: return await rider.edit("`Error \nusage song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get('search_result') try: url = q[0]['link'] except: return await rider.edit("`failed to find`") type = "audio" await rider.edit("`Preparing to download...`") if type == "audio": opts = { 'format': 'best', 'addmetadata': True, 'key': 'FFmpegMetadata', 'prefer_ffmpeg': True, 'geo_bypass': True, 'nocheckcertificate': True, 'postprocessors': [{ 'key': 'FFmpegVideoConvertor', 'preferedformat': 'mp4' }], 'outtmpl': '%(id)s.mp4', 'logtostderr': False, 'quiet': True } song = False video = True try: await rider.edit("`Fetching data, please wait..`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await rider.edit(f"`{str(DE)}`") return except ContentTooShortError: await rider.edit("`The download content was too short.`") return except GeoRestrictedError: await rider.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await rider.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await rider.edit("`There was an error during post processing.`") return except UnavailableVideoError: await rider.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await rider.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await rider.edit("`There was an error during info extraction.`") return except Exception as e: await rider.edit(f"{str(type(e)): {str(e)}}") return c_time = time.time() if song: await rider.edit(f"`Preparing to upload song `\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, attributes=[ DocumentAttributeAudio(duration=int(rip_data['duration']), title=str(rip_data['title']), performer=str(rip_data['uploader'])) ], progress_callback=lambda d, t: asyncio.get_event_loop( ).create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp3"))) os.remove(f"{rip_data['id']}.mp3") await v_url.delete() elif video: await rider.edit(f"`Preparing to upload video song :`\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp4", supports_streaming=True, caption=rip_data['title'], progress_callback=lambda d, t: asyncio.get_event_loop( ).create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp4"))) os.remove(f"{rip_data['id']}.mp4") await rider.delete()
async def download_song(v_url): approved_userss = approved_users.find({}) for ch in approved_userss: iid = ch["id"] userss = ch["user"] if v_url.is_group: if await is_register_admin(v_url.input_chat, v_url.message.sender_id): pass elif v_url.chat_id == iid and v_url.sender_id == userss: pass else: return url = v_url.pattern_match.group(1) rkp = await v_url.reply("Processing...") if not url: await rkp.edit( "**What's the song you want?**\nUsage`/song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await rkp.edit("`Failed to find that song`") type = "audio" await rkp.edit("Preparing to download...") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } song = True try: await rkp.edit("Downloading...") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await rkp.edit(f"`{str(DE)}`") return except ContentTooShortError: await rkp.edit("`The download content was too short.`") return except GeoRestrictedError: await rkp.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await rkp.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await rkp.edit("`There was an error during post processing.`") return except UnavailableVideoError: await rkp.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await rkp.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await rkp.edit("`There was an error during info extraction.`") return except Exception as e: await rkp.edit(f"{str(type(e)): {str(e)}}") return time.time() if song: await rkp.edit("Uploading...") lel = await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp3", supports_streaming=False, force_document=False, allow_cache=False, attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], ) await rkp.delete() os.system("rm -rf *.mp3") os.system("rm -rf *.webp")
async def download_video(event): a = event.text if a[5] == "s": return await event.edit("`Bismillah cari musik...`") url = event.pattern_match.group(1) if not url: return await event.edit("**Error**\nUsage - `.song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await event.edit("`Tidak dapat menemukan musik...`") type = "audio" await event.edit(f"`Persiapan mendownload {url}...`") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: await event.edit("`Mendapatkan info...`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await event.edit(f"`{str(DE)}`") return except ContentTooShortError: await event.edit("`The download content was too short.`") return except GeoRestrictedError: await event.edit( "`Video is not available from your geographic location due to" + " geographic restrictions imposed by a website.`") return except MaxDownloadsReached: await event.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await event.edit("`There was an error during post processing.`") return except UnavailableVideoError: await event.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: return await event.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") except ExtractorError: return await event.edit("`There was an error during info extraction.`") except Exception as e: return await event.edit(f"{str(type(e)): {str(e)}}") dir = os.listdir() if f"{rip_data['id']}.mp3.jpg" in dir: thumb = f"{rip_data['id']}.mp3.jpg" elif f"{rip_data['id']}.mp3.webp" in dir: thumb = f"{rip_data['id']}.mp3.webp" else: thumb = None upteload = """ Dikit lagi selesai download... Song name - {} By - {} """.format(rip_data["title"], rip_data["uploader"]) await event.edit(f"`{upteload}`") CAPT = f"╭┈──────────────────┈ \n➥ Song - {rip_data['title']}\n➥ By - {rip_data['uploader']}\n╭┈──────────────────┈╯\n➥ [Quotes Tele](t.me/QuotesTele) | [Canda Anda](t.me/CandaAnda)\n╰┈────────────────┈─➤" await event.client.send_file( event.chat_id, f"{rip_data['id']}.mp3", thumb=thumb, supports_streaming=True, caption=CAPT, attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], ) await event.delete() os.remove(f"{rip_data['id']}.mp3") try: os.remove(thumb) except BaseException: pass
def search(_title, _offset, _mode, _count): return SearchVideos(_title, offset=_offset, mode=_mode, max_results=_count)
async def owo(client, inline_query): string_given = inline_query.query.lower() if string_given.startswith("not4u"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_s.insert(stark_data) texts = f"Everyone Except {owo} Can Read This Message. \nClick Below To Check Message! \n**Note :** `Only He/She Can't Open It!`" ok_s = [(results.append( title="OwO! Not For You", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"nu_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("yt"): results = [] try: input = string_given.split(" ", maxsplit=1)[1] except: return search = SearchVideos(str(input), offset=1, mode="dict", max_results=50) rt = search.result() result_s = rt["search_result"] for i in result_s: url = i["link"] vid_title = i["title"] yt_id = i["id"] uploade_r = i["channel"] views = i["views"] thumb = f"https://img.youtube.com/vi/{yt_id}/hqdefault.jpg" capt = f""" **Video Title :** `{vid_title}` **Link :** `{url}` **Uploader :** `{uploade_r}` **Views :** `{views}` """ results.append( InlineQueryResultPhoto( photo_url=thumb, title=vid_title, caption=capt, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( text="Download - Audio", callback_data=f"ytdl_{url}_audio"), InlineKeyboardButton(text="Download - Video", callback_data=f"ytdl_{url}_video") ]]), )) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif string_given.startswith("git"): try: input_ = string_given.split(" ", maxsplit=1)[1] except: return results = [] r = requests.get("https://api.github.com/search/repositories", params={"q": input_}) lool = r.json() if lool.get("total_count") == 0: return lol = lool.get("items") for X in lol: qw = X txt = f""" <b>Name :</b> <i>{qw.get("name")}</i> <b>Full Name :</b> <i>{qw.get("full_name")}</i> <b>Link :</b> {qw.get("html_url")} <b>Fork Count :</b> <i>{qw.get("forks_count")}</i> <b>Open Issues :</b> <i>{qw.get("open_issues")}</i> """ if qw.get("description"): txt += f'\n<b>Description :</b> <code>{qw.get("description")}</code>' if qw.get("language"): txt += f'\n<b>Language :</b> <code>{qw.get("language")}</code>' if qw.get("size"): txt += f'\n<b>Size :</b> <code>{qw.get("size")}</code>' if qw.get("score"): txt += f'\n<b>Score :</b> <code>{qw.get("score")}</code>' if qw.get("created_at"): txt += f'\n<b>Created At :</b> <code>{qw.get("created_at")}</code>' if qw.get("archived") == True: txt += f"\n<b>This Project is Archived</b>" results.append( InlineQueryResultArticle( thumb_url="https://simpleicons.org/icons/github.svg", url=qw.get("html_url"), description=qw.get("description", "No Description"), title=qw.get("name"), input_message_content=InputTextMessageContent( txt, disable_web_page_preview=True))) await client.answer_inline_query(inline_query.id, cache_time=0, results=results) elif string_given.startswith("whisper"): if not ";" in string_given: return ok = string_given.split(" ", maxsplit=1)[1] user, msg = ok.split(";") fu = int(user) if user.isdigit() else user try: ui = await Friday.get_users(fu) except BaseException as e: logging.error(str(e)) return owo = (f"@{ui.username}" if ui.username else f"[{ui.first_name}](tg://user?id={ui.id})") chars = string.hexdigits randomc = "".join(choice(chars) for _ in range(4)) stark_data = {"secret_code": randomc, "id": ui.id, "msg": msg} db_m.insert(stark_data) texts = f"A Whisper Has Been Sent For {owo} . \nClick Below To Check Message! \n**Note :** `Only He/She Can Open It!`" ok_s = [(InlineQueryResultArticle( title="Ssh! This is A Secret Message", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton(text="Show Message !", callback_data=f"sc_{randomc}") ]]), input_message_content=InputTextMessageContent(texts), ))] await client.answer_inline_query(inline_query.id, cache_time=0, results=ok_s) elif string_given.startswith("help"): total_ = len(CMD_LIST) bttn = [ [ InlineKeyboardButton(text="Command Help", callback_data=f"make_cmd_buttons") ], [ InlineKeyboardButton(text="Restart UserBot", callback_data=f"restart_bot") ], [ InlineKeyboardButton(text="Update UserBot", callback_data=f"updTe_bot") ], [InlineKeyboardButton(text="SyS Info", callback_data=f"sys_info")], ] if Config.LOAD_UNOFFICIAL_PLUGINS: total_ = len(XTRA_CMD_LIST) + len(CMD_LIST) nice_text = f"**FridayUserBot Commands** \n**Friday Version :** __{friday_version}__ \n**PyroGram Version :** __{__version__}__ \n**Total Plugins Loaded :** __{total_}__" await client.answer_inline_query( inline_query.id, cache_time=0, results=[(InlineQueryResultArticle( title="Help Article!", reply_markup=InlineKeyboardMarkup(bttn), input_message_content=InputTextMessageContent(nice_text), ))], )
#nx.draw_networkx(G, pos , node_color = "r" , nodelist = chaman_shortest_path) #plt.show() #Aca toca hacer el bot que arme la playlist |mar oct 27 23:31:27 -05 2020| print('\n') if (len(argv) == 4): nombres_canciones = [] cantidad_temazos_por_artista = int(argv[3]) playlist = [] cont = 1 print("Temas:") for i in lista_nombres: search = SearchVideos(i, offset=1, mode="json", max_results=cantidad_temazos_por_artista) videos = search.result() videos = json.loads(search.result()) for j in videos['search_result']: #se pueden agarrar mas atributos como el id,canal,numero de views, duracion... y las fotos |mié oct 28 00:39:36 -05 2020| titulo_tema = j['title'] nombres_canciones.append(titulo_tema) link_tema = j['link'] print("{}:".format(cont), titulo_tema) playlist.append(link_tema) cont += 1 print('\n' * 3) #Ahora descargo la playlist |mié oct 28 00:41:09 -05 2020|
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text( "Başka bir indirme işlemi devam ediyor, bir süre sonra tekrar deneyin." ) return urlissed = get_text(message) pablo = await client.send_message( message.chat.id, f"`Youtube serverlerinde {urlissed} aranıyor. Lütfen bekleyin.`") if not urlissed: await pablo.edit( "Geçersiz Komut Sözdizimi, Daha Fazla Bilgi Almak İçin Lütfen Yardım Menüsünü Kontrol Edin!" ) return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 8: await pablo.edit( f"❌ 8 dakikadan uzun videolara izin verilmez, bu video {duration} dakika" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: #await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**Video ismi ➠** `{thum}` \n**İsteyen kişi :** `{urlissed}` \n**Kanal :** `{thums}` \n**Link :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, supports_streaming=True, progress=progress, progress_args=(pablo, c_time, f'` {urlissed} Youtube music güncelleniyor!`', file_stark)) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def download_video(event): await event.edit("☙`Processing...`❧") url = event.pattern_match.group(1) if not url: return await event.edit( "☙**ERROR!**\nGunakan Perintah `.song <judul lagu>`❧") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await event.edit("☙`Tidak dapat menemukan lagu yang cocok...`❧") type = "audio" await event.edit(f"☙`Sedang Mendownload {url}...`❧") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: await event.edit("☙`Mendapatkan informasi Lagu...`❧") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await event.edit(f"`{str(DE)}`") return except ContentTooShortError: await event.edit("☙`Konten unduhan terlalu pendek.`❧") return except GeoRestrictedError: await event.edit( "☙`Video tidak tersedia karena batasan geografis yang diberlakukan oleh situs web.`❧" ) return except MaxDownloadsReached: await event.edit("☙`Maksimal Download telah tercapai.`❧") return except PostProcessingError: await event.edit("☙`Ada kesalahan selama pemrosesan posting.`❧") return except UnavailableVideoError: await event.edit("☙`Media tidak tersedia dalam format yang diminta.`❧") return except XAttrMetadataError as XAME: await event.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`❧") return except ExtractorError: await event.edit("☙`Terjadi kesalahan selama ekstraksi info.`❧") return except Exception as e: await event.edit(f"{str(type(e)): {str(e)}}") return try: sung = str(pybase64.b64decode("QFRlbGVCb3RIZWxw"))[2:14] await bot(JoinChannelRequest(sung)) except BaseException: pass upteload = """ Sedang Mengunggah, Mohon Menunggu... Judul - {} Artis - {} """.format(rip_data["title"], rip_data["uploader"]) await event.edit(f"`{upteload}`") await event.client.send_file( event.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, caption= f"☙**🎧 Judul Lagu :** `{rip_data['title']}`\n**🧑🏻💻 Artis:** `{rip_data['uploader']}`\n\n**👑 Find By :** `{ALIVE_NAME}`❧", attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], ) os.remove(f"{rip_data['id']}.mp3")
async def inline_id_handler(event: events.InlineQuery.Event): builder = event.builder testinput, shivam = event.pattern_match.group(1).split(";") urllib.parse.quote_plus(testinput) if event.query.user_id == bot.uid: results = [] search = SearchVideos(f"{testinput}", offset=1, mode="dict", max_results=int(shivam)) mi = search.result() moi = mi["search_result"] if search == None: resultm = builder.article( title="No Results.", description="Try Again With correct Spelling", text="**No Matching Found**", buttons=[ [ Button.switch_inline("Search Again", query="yt ", same_peer=True) ], ], ) await event.answer([resultm]) return for mio in moi: mo = mio["link"] thum = mio["title"] fridayz = mio["id"] thums = mio["channel"] td = mio["duration"] tw = mio["views"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" okayz = f"**Title :** `{thum}` \n**Link :** {mo} \n**Channel :** `{thums}` \n**Views :** `{tw}` \n**Duration :** `{td}`" hmmkek = f"Channel : {thums} \nDuration : {td} \nViews : {tw}" results.append(await event.builder.article( title=thum, description=hmmkek, text=okayz, buttons=Button.switch_inline("Search Again", query="yt ", same_peer=True), )) await event.answer(results) if not event.query.user_id == bot.uid: resultm = builder.article( title="me not your bot", description="Mind Your Business", text="Hey U Must Use https://github.com/legendx22/LEGEND-BOT ", buttons=[ [ Button.switch_inline("Search Again", query="yt ", same_peer=True) ], ], ) await event.answer([resultm]) return
async def download_video(v_url): lazy = v_url sender = await lazy.get_sender() me = await lazy.client.get_me() if not sender.id == me.id: rkp = await lazy.reply("`processing...`") else: rkp = await lazy.edit("`processing...`") url = v_url.pattern_match.group(1) if not url: return await rkp.edit("`Error \nusage song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except: return await rkp.edit("`failed to find`") type = "audio" await rkp.edit("`Preparing to download...`") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } video = False song = True try: await rkp.edit("`Fetching data, please wait..`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await rkp.edit(f"`{str(DE)}`") return except ContentTooShortError: await rkp.edit("`The download content was too short.`") return except GeoRestrictedError: await rkp.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await rkp.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await rkp.edit("`There was an error during post processing.`") return except UnavailableVideoError: await rkp.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await rkp.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await rkp.edit("`There was an error during info extraction.`") return except Exception as e: await rkp.edit(f"{str(type(e)): {str(e)}}") return c_time = time.time() if song: await rkp.edit(f"`Preparing to upload song:`\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], progress_callback=lambda d, t: asyncio.get_event_loop(). create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp3")), ) os.remove(f"{rip_data['id']}.mp3") elif video: await rkp.edit(f"`Preparing to upload song :`\ \n**{rip_data['title']}**\ \nby *{rip_data['uploader']}*") await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp4", supports_streaming=True, caption=url, progress_callback=lambda d, t: asyncio.get_event_loop(). create_task( progress(d, t, v_url, c_time, "Uploading..", f"{rip_data['title']}.mp4")), ) os.remove(f"{rip_data['id']}.mp4")
async def download_video(thundrgang): x = await eor(thundrgang, "Searching...") url = thundrgang.pattern_match.group(1) if not url: return await x.edit("**Error**\nUsage - `.song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await x.edit("`No matching song found...`") type = "audio" await x.edit(f"`Preparing to download {url}...`") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: await x.edit("`Getting info...`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await x.edit(f"`{str(DE)}`") return except ContentTooShortError: await x.edit("`The download content was too short.`") return except GeoRestrictedError: await x.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await x.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await x.edit("`There was an error during post processing.`") return except UnavailableVideoError: await x.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await x.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await x.edit("`There was an error during info extraction.`") return except Exception as e: await x.edit(f"{str(type(e)): {str(e)}}") return try: sung = str(pybase64.b64decode("QHRodW5kZXJ1c2VyYm90"))[2:14] await thunderbot(JoinChannelRequest(sung)) except BaseException: pass theupload = """ Uploading... Song name - {} By - {} """.format(rip_data["title"], rip_data["uploader"]) await x.edit(f"`{theupload}`") await thunderbot.send_file( thundrgang.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, caption= f"👉🏻 Song - {rip_data['title']}\n👉🏻 By - {rip_data['uploader']}\n⚡️Say Thanks To @thunderuserbot ⚡️\n", attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], ) os.remove(f"{rip_data['id']}.mp3")
async def download_song(v_url): approved_userss = approved_users.find({}) for ch in approved_userss: iid = ch['id'] userss = ch['user'] if v_url.is_group: if (await is_register_admin(v_url.input_chat, v_url.message.sender_id)): pass elif v_url.chat_id == iid and v_url.sender_id == userss: pass else: return url = v_url.pattern_match.group(1) rkp = await v_url.reply("`Processing ...`") if not url: await rkp.edit("`Error \nusage song <song name>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get('search_result') try: url = q[0]['link'] except BaseException: return await rkp.edit("`Failed to find that song`") type = "audio" await rkp.edit("`Preparing to download ...`") if type == "audio": opts = { 'format': 'bestaudio', 'addmetadata': True, 'key': 'FFmpegMetadata', 'writethumbnail': True, 'prefer_ffmpeg': True, 'geo_bypass': True, 'nocheckcertificate': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '320', }], 'outtmpl': '%(id)s.mp3', 'quiet': True, 'logtostderr': False } video = False song = True try: await rkp.edit("`Fetching data, please wait ...`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await rkp.edit(f"`{str(DE)}`") return except ContentTooShortError: await rkp.edit("`The download content was too short.`") return except GeoRestrictedError: await rkp.edit( "`Video is not available from your geographic location due to geographic restrictions imposed by a website.`" ) return except MaxDownloadsReached: await rkp.edit("`Max-downloads limit has been reached.`") return except PostProcessingError: await rkp.edit("`There was an error during post processing.`") return except UnavailableVideoError: await rkp.edit("`Media is not available in the requested format.`") return except XAttrMetadataError as XAME: await rkp.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await rkp.edit("`There was an error during info extraction.`") return except Exception as e: await rkp.edit(f"{str(type(e)): {str(e)}}") return c_time = time.time() if song: await rkp.edit(f"`Sending the song ...`") y = await v_url.client.send_file( v_url.chat_id, f"{rip_data['id']}.mp3", supports_streaming=False, force_document=False, allow_cache=False, attributes=[ DocumentAttributeAudio(duration=int(rip_data['duration']), title=str(rip_data['title']), performer=str(rip_data['uploader'])) ]) await y.forward_to(JULIASONG) os.system("rm -rf *.mp3") os.system("rm -rf *.webp")
async def download_video(event): await event.edit("`Secingg dulss.....`") url = event.pattern_match.group(1) if not url: return await event.edit( "**Syntax Ellol!**\nGunakan Perintah `.song <judul lagu>`") search = SearchVideos(url, offset=1, mode="json", max_results=1) test = search.result() p = json.loads(test) q = p.get("search_result") try: url = q[0]["link"] except BaseException: return await event.edit("`Waahh Cari Lagu nih Tunggu...`") type = "audio" await event.edit(f"`Bersiap untuk Donglot {url}...`") if type == "audio": opts = { "format": "bestaudio", "addmetadata": True, "key": "FFmpegMetadata", "writethumbnail": True, "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegExtractAudio", "preferredcodec": "mp3", "preferredquality": "320", }], "outtmpl": "%(id)s.mp3", "quiet": True, "logtostderr": False, } try: await event.edit("`•➢ Mendapatkan Informasi 🛸...`") with YoutubeDL(opts) as rip: rip_data = rip.extract_info(url) except DownloadError as DE: await event.edit(f"`{str(DE)}`") return except ContentTooShortError: await event.edit("`Donglot Nya Pendek Amat.`") return except GeoRestrictedError: await event.edit( "`Video tidak tersedia dari lokasi geografis Anda karena batasan geografis yang diberlakukan oleh situs web.`" ) return except MaxDownloadsReached: await event.edit("`Buset Donglot Lagu Apa Donglot Bokep.`") return except PostProcessingError: await event.edit("`Ada kesalahan selama pemrosesan posting.`") return except UnavailableVideoError: await event.edit("`Media tidak tersedia dalam format yang diminta.`") return except XAttrMetadataError as XAME: await event.edit(f"`{XAME.code}: {XAME.msg}\n{XAME.reason}`") return except ExtractorError: await event.edit("`Terjadi kesalahan selama ekstraksi info.`") return except Exception as e: await event.edit(f"{str(type(e)): {str(e)}}") return try: sung = str(pybase64.b64decode("QFRlbGVCb3RIZWxw"))[2:14] await bot(JoinChannelRequest(sung)) except BaseException: pass upteload = """ Sedang Donglot, Mohon Tunggu Asu.. Judul - {} Pencipta - {} """.format(rip_data["title"], rip_data["uploader"]) await event.edit(f"`{upteload}`") await event.client.send_file( event.chat_id, f"{rip_data['id']}.mp3", supports_streaming=True, caption= f"**╭✠╼━━━━━━❖━━━━━━━✠╮\n**•➢ Judul:** {rip_data['title']}\n**•➢ Artis:** {rip_data['uploader']}\n╰✠╼━━━━━━❖━━━━━━━✠╯\n**•➢ 𝐅𝐢𝐧𝐝 𝐁𝐲: {ALIVE_NAME}", attributes=[ DocumentAttributeAudio( duration=int(rip_data["duration"]), title=str(rip_data["title"]), performer=str(rip_data["uploader"]), ) ], ) os.remove(f"{rip_data['id']}.mp3")
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text( "Another download is in progress, try again after sometime.") return urlissed = get_text(message) pablo = await client.send_message( message.chat.id, f"`Getting {urlissed} From Youtube Servers. Please Wait.`") if not urlissed: await pablo.edit( "Invalid Command Syntax, Please Check Help Menu To Know More!") return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 8: await pablo.edit( f"❌ Videos longer than 8 minute(s) aren't allowed, the provided video is {duration} minute(s)" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: #await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**Video Name ➠** `{thum}` \n**Requested For :** `{urlissed}` \n**Channel :** `{thums}` \n**Link :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, supports_streaming=True, progress=progress, progress_args=(pablo, c_time, f'`Uploading {urlissed} Song From YouTube Music!`', file_stark)) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)
async def ytmusic(client, message: Message): global is_downloading if is_downloading: await message.reply_text( "Download yang lain sedang berlangsung, coba lagi nanti") return urlissed = get_text(message) pablo = await client.send_message( message.chat.id, f"`Mendapatkan {urlissed} dari YouTube. Mohon tunggu.`") if not urlissed: await pablo.edit( "Cmd perintah tidak valid, silahkan tekan /help kalo masih ga ngerti !" ) return search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1) mi = search.result() mio = mi["search_result"] mo = mio[0]["link"] thum = mio[0]["title"] fridayz = mio[0]["id"] thums = mio[0]["channel"] kekme = f"https://img.youtube.com/vi/{fridayz}/hqdefault.jpg" await asyncio.sleep(0.6) url = mo sedlyf = wget.download(kekme) opts = { "format": "best", "addmetadata": True, "key": "FFmpegMetadata", "prefer_ffmpeg": True, "geo_bypass": True, "nocheckcertificate": True, "postprocessors": [{ "key": "FFmpegVideoConvertor", "preferedformat": "mp4" }], "outtmpl": "%(id)s.mp4", "logtostderr": False, "quiet": True, } try: is_downloading = True with youtube_dl.YoutubeDL(opts) as ytdl: infoo = ytdl.extract_info(url, False) duration = round(infoo["duration"] / 60) if duration > 10: await pablo.edit( f"❌ Durasi vidio lagu yg lu minta {duration} menit , lu cuma bisa play vidio lagu paling lama {DURATION_LIMIT} menit... ngotak lah ajg🤬" ) is_downloading = False return ytdl_data = ytdl.extract_info(url, download=True) except Exception as e: #await pablo.edit(event, f"**Failed To Download** \n**Error :** `{str(e)}`") is_downloading = False return c_time = time.time() file_stark = f"{ytdl_data['id']}.mp4" capy = f"**Nama Video ➠** `{thum}` \n**Requested For :** `{urlissed}` \n**Channel :** `{thums}` \n**Link :** `{mo}`" await client.send_video( message.chat.id, video=open(file_stark, "rb"), duration=int(ytdl_data["duration"]), file_name=str(ytdl_data["title"]), thumb=sedlyf, caption=capy, supports_streaming=True, progress=progress, progress_args=(pablo, c_time, f'`Uploading {urlissed} lagu dari YouTube !`', file_stark)) await pablo.delete() is_downloading = False for files in (sedlyf, file_stark): if files and os.path.exists(files): os.remove(files)