async def youtube_search(client, message): args = message.text.split(None, 1) if len(args) == 1: await message.edit("Write any args here!") return teks = args[1] responce = requests.get('https://www.youtube.com/results?search_query=' + teks.replace(" ", "%20")) soup = BeautifulSoup(responce.content, "html.parser") divs = soup.find_all("div", {"class": "yt-lockup"}) yutub = "<b>Results of {}</b>\n".format(teks) nomor = 0 for i in divs: title = cleanhtml( str(i.find('h3', { 'class': "yt-lockup-title" }).a.span)) url = i.find('h3', {'class': "yt-lockup-title"}).a['href'] vidtime = i.find("span", {"class": "video-time"}) if vidtime: vidtime = str("(" + cleanhtml(str(vidtime)) + ")") else: vidtime = "" nomor += 1 yutub += '<b>{}.</b> <a href="{}">{}</a> {}\n'.format( nomor, "https://www.youtube.com" + url, title, vidtime) await message.edit(yutub, disable_web_page_preview=True, parse_mode="html")
async def get_driveinfo(driveid): getdrivename = BeautifulSoup( requests.get( "https://drive.google.com/file/d/{}/view".format(driveid), allow_redirects=False, ).content) return cleanhtml(str(getdrivename.find("title"))).split(" - ")[0]
async def youtube_downloader(client, message): args = message.text.split(None, 1) if len(args) == 1: await message.edit("Write any args here!") return teks = args[1] await message.edit("Checking...") if "youtu.be" in teks: ytid = teks.split("youtu.be/")[1] if "&" in ytid: ytid = ytid.split("&")[0] elif "watch?" in teks: ytid = teks.split("watch?v=")[1] if "&" in ytid: ytid = ytid.split("&")[0] else: await message.edit("URL not supported!") return yt = requests.get( "https://api.unblockvideos.com/youtube_downloader?id={}&selector=mp4". format(ytid)).json() thumb = "https://i1.ytimg.com/vi/{}/mqdefault.jpg".format(ytid) title = cleanhtml( str( BeautifulSoup( requests.get('https://www.youtube.com/watch?v={}'.format( ytid)).content).find('span', {"class": "watch-title"}))) capt = "**{}**\nDownloads:".format(title) for x in yt: capt += "\n-> [{}]({})".format(x['format'], x['url']) try: await client.send_photo(message.chat.id, photo=thumb, caption=capt, reply_to_message_id=message.message_id, parse_mode='markdown') except: await message.edit(capt + "[]({})".format(thumb), disable_web_page_preview=True)