Ejemplo n.º 1
0
 async def getlyrics(self,song,channel,user):
     await self.bot.wait_until_ready()
     get_request_search = requests.get(self.link + song+ "&w=songs&p=1" , headers=self.headers)
     soup_search = BeautifulSoup(get_request_search.content,'html.parser')
     try:
         link_from_search  = soup_search.find('td',{'class':'text-left visitedlyr'}).find('a')
         get_request_lyrics = requests.get(link_from_search['href'],headers=self.headers)
         soup_lyrics = BeautifulSoup(get_request_lyrics.content,'html.parser')
         
         lyrics_text = soup_lyrics.find('div',{'class':'col-xs-12 col-lg-8 text-center'}).find('div',None).text
         header_text = soup_lyrics.find('div',{'class':'lyricsh'}).text       
         log.debug('header : ' + header_text)
         log.debug('lryics : ' + lyrics_text)
         if(len(lyrics_text)>500):
             await self.bot.send_message(channel,user.mention+" friend i got the lyrics but its too long so  will write it in a file and send as pm")
             f = open(song+'.txt','w')
             f.write('\t\t'+header_text+'\n\n'+lyrics_text)
             f.close()
             await self.bot.send_file(user,song+'.txt')
             os.remove(song+'.txt')
         else:                
             await self.bot.send_message(channel,'```*\t\t'+header_text+'*\n\n'+lyrics_text+'```')
     except Exception as e:
         log.exception(str(e))
         await self.bot.send_message(channel,"Sorry :( i can't find it")
Ejemplo n.º 2
0
    async def search(self, channel):
        await self.bot.wait_until_ready()
        try:
            response = requests.get('https://api.imgflip.com/get_memes')
            data = response.json()
            memes = data['data']['memes']
            random_meme = random.choice(memes)['url']
            log.info("Meme url is " + random_meme)
            meme_file = self.download_file(random_meme)
            await self.bot.send_file(channel, meme_file)
            os.remove(meme_file)

        except Exception as e:
            await self.bot.send_message(channel, "OOps can't get the meme")
            log.exception(str(e))
Ejemplo n.º 3
0
 async def convert(self,ctx,link:str):
     try:
         conv_idx = link.index('?v=')+3
     
     except ValueError:
         await self.bot.say("Stop trolling kid provide valid youtube link!!")
         pass
     except Exception as e:
         log.exception(str(e))
     converted_name = link[conv_idx:]+'.mp3'
     await self.bot.say("Please wait while till i convert your video")
     
     try:
         self.bot.loop.create_task(self.start_conversion(ctx.message.author,link,converted_name))
         
     except Exception as e:
         await self.bot.say("Make sure your provided a valid link ")
         log.exception(str(e))
Ejemplo n.º 4
0
    async def getlyrics(self, song, channel, user):
        await self.bot.wait_until_ready()
        get_request_search = requests.get(self.link + song + "&w=songs&p=1",
                                          headers=self.headers)
        soup_search = BeautifulSoup(get_request_search.content, 'html.parser')

        try:
            link_from_search = soup_search.find('td', {
                'class': 'text-left visitedlyr'
            }).find('a')
            get_request_lyrics = requests.get(link_from_search['href'],
                                              headers=self.headers)
            soup_lyrics = BeautifulSoup(get_request_lyrics.content,
                                        'html.parser')

            lyrics_text = soup_lyrics.find(
                'div', {
                    'class': 'col-xs-12 col-lg-8 text-center'
                }).find('div', None).text
            header_text = soup_lyrics.find('div', {'class': 'lyricsh'}).text
            log.debug('header : ' + header_text)
            log.debug('lryics : ' + lyrics_text)

            await self.bot.send_message(
                channel, user.mention +
                " friend i got the lyrics..here is it and also i send a copy as a file in pm"
            )
            song_replace = song.replace("+", " ")
            f = open(song_replace + '.txt', 'w')
            f.write('\t\t' + header_text + '\n\n' + lyrics_text)
            f.close()
            await self.bot.send_file(user, song_replace + '.txt')
            os.remove(song_replace + '.txt')
            embed = discord.Embed(title=header_text,
                                  description=lyrics_text,
                                  color=0xa500ff)
            await self.bot.send_message(channel, embed=embed)

        except discord.errors.HTTPException:
            log.exception(str(e))

        except Exception as e:
            log.exception(str(e))
            await self.bot.send_message(channel, "Sorry :( i can't find it")
Ejemplo n.º 5
0
    async def search(self, name, channel, user):
        await self.bot.wait_until_ready()
        try:
            res = requests.get("https://thepiratebay-proxylist.org")
            soup = BeautifulSoup(res.content, 'html.parser')
            proxy = soup.find('td', {'class': 'url'})['data-href']
            payload = proxy + '/s/?q=' + name + '&page=0&orderby=99'
            res = requests.get(payload)
            soup = BeautifulSoup(res.content, 'html.parser')
            payload = proxy + soup.find('a', {'class': 'detLink'})['href']
            res = requests.get(payload)
            soup = BeautifulSoup(res.content, 'html.parser')
            magnet = soup.find(
                'a', {
                    'style':
                    "background-image: url('/static/img/icons/icon-magnet.gif');"
                })['href']
            about = soup.find('div', {'class': 'nfo'}).text

            if magnet is not None:
                await self.bot.send_message(channel,
                                            "Got your torrent's magnet link")
                await self.bot.send_message(channel, "```" + magnet + "```")
                if len(about) > 10:
                    embed = discord.Embed(title=name.replace("+", " "),
                                          description=about[:6000],
                                          color=0xff4c00)
                    await self.bot.send_message(channel, embed=embed)

            else:
                await self.bot.send_message(
                    channel, "Ehh can't find anything with that name")

        except Exception as e:
            await self.bot.send_message(
                channel,
                "Eww i think something got me there or what i'm searchin is not right"
            )
            log.exception(str(e))