Exemplo n.º 1
0
 def getlyrics(self, url):
     try:
         lyrics = pylyrics3.get_lyrics_from_url(url)
         lyrics = re.sub('(?<!\.|\!|\?)\s\\n', '.', lyrics).replace(" \n", "")
     except Exception:
         lyrics = pylyrics3.get_lyrics_from_url(url)
         lyrics = re.sub('(?<!\.|\!|\?)\s\\n', '.', lyrics).replace(" \n", "")
     else:
         return lyrics
Exemplo n.º 2
0
    def getlyrics(self, query):
        lyrics = None
        if "lyrics.fandom.com/wiki/" in query:
            try:
                log.debug("Lyrics: requesting {0}".format(query))
                lyrics = pylyrics3.get_lyrics_from_url(query)
            except Exception:
                pass
        else:
            try:
                log.debug("Lyrics: requesting {0}".format(query))
                query = query.split(",", 1)
                lyrics = pylyrics3.get_song_lyrics(query[0].strip(),
                                                   query[1].strip())
            except Exception:
                pass
        if lyrics:
            lyrics = re.sub(r"(?<!\.|\!|\?)\s+\n", ".", lyrics)
            lyrics = re.sub(r"\s+\n", "", lyrics)

            return lyrics
        else:
            return
Exemplo n.º 3
0
 def getlyrics(self, query, retries=0):
     lyrics = None
     while retries < 3:
         try:
             if "lyrics.fandom.com/wiki/" in query:
                 log.debug("Lyrics: requesting {0}".format(query))
                 lyrics = pylyrics3.get_lyrics_from_url(query)
             else:
                 log.debug("Lyrics: requesting {0}".format(query))
                 query = query.split(",", 1)
                 lyrics = pylyrics3.get_song_lyrics(query[0].strip(),
                                                    query[1].strip())
         except:
             pass
         if lyrics:
             lyrics = re.sub(r"(?<!\.|\!|\?)\s+\n", ".", lyrics)
             lyrics = re.sub(r"\s+\n", "", lyrics)
             break
         else:
             log.debug("Lyrics: Failed to get lyrics. Retrying...")
             retries += 1
     if not lyrics and retries > 2:
         log.info("Lyrics: maximum number of retries (3) reached.")
     return lyrics