From 143edbc1d0b88368b1facd4c1b959cc77f045ec2 Mon Sep 17 00:00:00 2001 From: alevis Date: Sun, 14 Apr 2019 02:52:33 -0700 Subject: [PATCH 1/8] No need to encode lyrics in getLyrics function. Prevents false negatives on valid user requests. --- PyLyrics/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index e4c7e19..ce332fb 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -93,7 +93,7 @@ def getLyrics(singer, song): for match in lyrics.findAll(tag): match.replaceWithChildren() #Get output as a string and remove non unicode characters and replace
with newlines - output = str(lyrics).encode('utf-8', errors='replace')[22:-6:].decode("utf-8").replace('\n','').replace('
','\n') + output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').replace('
','\n') try: return output except: @@ -107,4 +107,4 @@ def main(): if __name__=='__main__': - main() \ No newline at end of file + main() From 4ae5187eed161385ff83294d7027ca742de94c02 Mon Sep 17 00:00:00 2001 From: alevis Date: Mon, 15 Apr 2019 14:03:50 -0700 Subject: [PATCH 2/8] Resolve python version inconsistencies --- PyLyrics/functions.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index ce332fb..edf8542 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -1,3 +1,4 @@ +import sys import requests from bs4 import BeautifulSoup, Comment, NavigableString import sys, codecs, json @@ -92,8 +93,15 @@ def getLyrics(singer, song): for tag in ['div','i','b','a']: for match in lyrics.findAll(tag): match.replaceWithChildren() - #Get output as a string and remove non unicode characters and replace
with newlines - output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').replace('
','\n') + #Get output as a string and remove non unicode characters and replace\ + #
with newlines + # Python 3 + if sys.version_info.major > 2: + output = str(lyrics).encode('utf-8', errors='replace')[22:-6:].\ + decode("utf-8").replace('\n','').replace('
','\n') + else:# Python 2 + output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').\ + replace('
','\n') try: return output except: From 74c0033df33a6ef8f4acac00d7bcfc50491a4974 Mon Sep 17 00:00:00 2001 From: alevis Date: Mon, 15 Apr 2019 14:18:37 -0700 Subject: [PATCH 3/8] Fixing indentation issues. --- PyLyrics/functions.py | 184 +++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 92 deletions(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index edf8542..563d066 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -4,96 +4,96 @@ import sys, codecs, json class Track(object): - def __init__(self,trackName,album,artist): - self.name = trackName - self.album = album - self.artist = artist - def __repr__(self): - return self.name - def link(self): - return 'http://lyrics.wikia.com/{0}:{1}'.format(self.artist.replace(' ', '-'),self.name.replace(' ','-')) - def getLyrics(self): - return PyLyrics.getLyrics(self.artist,self.name) + def __init__(self,trackName,album,artist): + self.name = trackName + self.album = album + self.artist = artist + def __repr__(self): + return self.name + def link(self): + return 'http://lyrics.wikia.com/{0}:{1}'.format(self.artist.replace(' ', '-'),self.name.replace(' ','-')) + def getLyrics(self): + return PyLyrics.getLyrics(self.artist,self.name) class Artist(object): - def __init__(self, name): - self.name = name - def getAlbums(self): - return PyLyrics.getAlbums(self.name) - def __repr__(self): - return self.name.encode('utf-8') + def __init__(self, name): + self.name = name + def getAlbums(self): + return PyLyrics.getAlbums(self.name) + def __repr__(self): + return self.name.encode('utf-8') class Album(object): - def __init__(self, name, link,singer): - self.year = name.split(' ')[-1] - self.name = name.replace(self.year,' ').rstrip() - self.url = link - self.singer = singer - def link(self): - return self.url - def __repr__(self): - if sys.version_info[0] == 2: - return self.name.encode('utf-8','replace') - return self.name - def artist(self): - return self.singer - def tracks(self): - return PyLyrics.getTracks(self) + def __init__(self, name, link,singer): + self.year = name.split(' ')[-1] + self.name = name.replace(self.year,' ').rstrip() + self.url = link + self.singer = singer + def link(self): + return self.url + def __repr__(self): + if sys.version_info[0] == 2: + return self.name.encode('utf-8','replace') + return self.name + def artist(self): + return self.singer + def tracks(self): + return PyLyrics.getTracks(self) class PyLyrics: - @staticmethod - def getAlbums(singer): - singer = singer.replace(' ', '_') - s = BeautifulSoup(requests.get('http://lyrics.wikia.com/{0}'.format(singer)).text) - spans = s.findAll('span',{'class':'mw-headline'}) - - als = [] - - for tag in spans: - try: - a = tag.findAll('a')[0] - als.append(Album(a.text,'http://lyrics.wikia.com' + a['href'],singer)) - except: - pass - - if als == []: - raise ValueError("Unknown Artist Name given") - return None - return als - @staticmethod - def getTracks(album): - url = "http://lyrics.wikia.com/api.php?action=lyrics&artist={0}&fmt=xml".format(album.artist()) - soup = BeautifulSoup(requests.get(url).text) + @staticmethod + def getAlbums(singer): + singer = singer.replace(' ', '_') + s = BeautifulSoup(requests.get('http://lyrics.wikia.com/{0}'.format(singer)).text) + spans = s.findAll('span',{'class':'mw-headline'}) + + als = [] + + for tag in spans: + try: + a = tag.findAll('a')[0] + als.append(Album(a.text,'http://lyrics.wikia.com' + a['href'],singer)) + except: + pass + + if als == []: + raise ValueError("Unknown Artist Name given") + return None + return als + @staticmethod + def getTracks(album): + url = "http://lyrics.wikia.com/api.php?action=lyrics&artist={0}&fmt=xml".format(album.artist()) + soup = BeautifulSoup(requests.get(url).text) - for al in soup.find_all('album'): - if al.text.lower().strip() == album.name.strip().lower(): - currentAlbum = al - break - songs =[Track(song.text,album,album.artist()) for song in currentAlbum.findNext('songs').findAll('item')] - return songs + for al in soup.find_all('album'): + if al.text.lower().strip() == album.name.strip().lower(): + currentAlbum = al + break + songs =[Track(song.text,album,album.artist()) for song in currentAlbum.findNext('songs').findAll('item')] + return songs - @staticmethod - def getLyrics(singer, song): - #Replace spaces with _ - singer = singer.replace(' ', '_') - song = song.replace(' ', '_') - r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) - s = BeautifulSoup(r.text) - #Get main lyrics holder - lyrics = s.find("div",{'class':'lyricbox'}) - if lyrics is None: - raise ValueError("Song or Singer does not exist or the API does not have Lyrics") - return None - #Remove Scripts - [s.extract() for s in lyrics('script')] + @staticmethod + def getLyrics(singer, song): + #Replace spaces with _ + singer = singer.replace(' ', '_') + song = song.replace(' ', '_') + r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) + s = BeautifulSoup(r.text) + #Get main lyrics holder + lyrics = s.find("div",{'class':'lyricbox'}) + if lyrics is None: + raise ValueError("Song or Singer does not exist or the API does not have Lyrics") + return None + #Remove Scripts + [s.extract() for s in lyrics('script')] - #Remove Comments - comments = lyrics.findAll(text=lambda text:isinstance(text, Comment)) - [comment.extract() for comment in comments] + #Remove Comments + comments = lyrics.findAll(text=lambda text:isinstance(text, Comment)) + [comment.extract() for comment in comments] - #Remove unecessary tags - for tag in ['div','i','b','a']: - for match in lyrics.findAll(tag): - match.replaceWithChildren() - #Get output as a string and remove non unicode characters and replace\ + #Remove unecessary tags + for tag in ['div','i','b','a']: + for match in lyrics.findAll(tag): + match.replaceWithChildren() + #Get output as a string and remove non unicode characters and replace\ #
with newlines # Python 3 if sys.version_info.major > 2: @@ -102,17 +102,17 @@ def getLyrics(singer, song): else:# Python 2 output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').\ replace('
','\n') - try: - return output - except: - return output.encode('utf-8') + try: + return output + except: + return output.encode('utf-8') def main(): - albums = PyLyrics.getAlbums('OneRepublic') - print (albums) - tracks = PyLyrics.getTracks(albums[-1]) - print (tracks[7].getLyrics()) - + albums = PyLyrics.getAlbums('OneRepublic') + print (albums) + tracks = PyLyrics.getTracks(albums[-1]) + print (tracks[7].getLyrics()) + if __name__=='__main__': - main() + main() From 17595005f7c3bcdaf247723083131090dbd265f6 Mon Sep 17 00:00:00 2001 From: alevis Date: Mon, 15 Apr 2019 17:30:08 -0700 Subject: [PATCH 4/8] Warnings and allowed made it possible for ValueError to be propagated to my app --- PyLyrics/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index 563d066..24b406d 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -76,11 +76,11 @@ def getLyrics(singer, song): singer = singer.replace(' ', '_') song = song.replace(' ', '_') r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) - s = BeautifulSoup(r.text) + s = BeautifulSoup(r.text, features="html.parser") #Get main lyrics holder lyrics = s.find("div",{'class':'lyricbox'}) if lyrics is None: - raise ValueError("Song or Singer does not exist or the API does not have Lyrics") + #raise ValueError("Song or Singer does not exist or the API does not have Lyrics") return None #Remove Scripts [s.extract() for s in lyrics('script')] From 03aa410bbc8801db2bca4b82dcadb8ce1602cde3 Mon Sep 17 00:00:00 2001 From: alevis Date: Tue, 18 Jun 2019 18:25:12 -0700 Subject: [PATCH 5/8] Change return type of getLyrics to a list of a string (album) and the lyrics (string) --- PyLyrics/functions.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index 24b406d..979a336 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -78,9 +78,10 @@ def getLyrics(singer, song): r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) s = BeautifulSoup(r.text, features="html.parser") #Get main lyrics holder + album = str(s.find('i').find('a').text()) lyrics = s.find("div",{'class':'lyricbox'}) if lyrics is None: - #raise ValueError("Song or Singer does not exist or the API does not have Lyrics") + #raise ValueError("Song or Singer does not exist or the API does not have Lyrics") return None #Remove Scripts [s.extract() for s in lyrics('script')] @@ -103,9 +104,9 @@ def getLyrics(singer, song): output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').\ replace('
','\n') try: - return output + return [album, output] except: - return output.encode('utf-8') + return [album, output.encode('utf-8')] def main(): albums = PyLyrics.getAlbums('OneRepublic') From 81c6b34fda3f36eab0f11d31ff867e02238cd227 Mon Sep 17 00:00:00 2001 From: alevis Date: Tue, 18 Jun 2019 18:40:29 -0700 Subject: [PATCH 6/8] Fix typo, should've tested before pushing --- PyLyrics/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index 979a336..5d9ad19 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -78,7 +78,7 @@ def getLyrics(singer, song): r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) s = BeautifulSoup(r.text, features="html.parser") #Get main lyrics holder - album = str(s.find('i').find('a').text()) + album = str(s.find('i').find('a').text) lyrics = s.find("div",{'class':'lyricbox'}) if lyrics is None: #raise ValueError("Song or Singer does not exist or the API does not have Lyrics") From 61c6121368dab4d2e9a2cde9cd4b3e6f6942d6e4 Mon Sep 17 00:00:00 2001 From: alevis Date: Wed, 19 Jun 2019 15:17:04 -0700 Subject: [PATCH 7/8] Catch None albums --- PyLyrics/__init__.pyc | Bin 313 -> 288 bytes PyLyrics/classes.pyc | Bin 206 -> 181 bytes PyLyrics/functions.py | 74 ++++++++++++++++++++++------------------- PyLyrics/functions.pyc | Bin 6038 -> 5838 bytes requirements.txt | 10 ++++++ 5 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 requirements.txt diff --git a/PyLyrics/__init__.pyc b/PyLyrics/__init__.pyc index 38b46660fa478ed72384d8b5643c22f141d68906..e8469b54d8c79a230d67dcf27c31dee6f4210f49 100644 GIT binary patch delta 34 pcmdnVw1A0&`7 delta 58 zcmZ3$w3CU0`7H`2WeH60* diff --git a/PyLyrics/classes.pyc b/PyLyrics/classes.pyc index d2aaa8f46ab158a8ed10b0ac76f1fae2686ad568..2f4050d8078495a9b4c3d9e399ad0e0ebb850b9f 100644 GIT binary patch delta 33 ocmX@dxRsHE`7 with newlines - # Python 3 - if sys.version_info.major > 2: - output = str(lyrics).encode('utf-8', errors='replace')[22:-6:].\ - decode("utf-8").replace('\n','').replace('
','\n') - else:# Python 2 - output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').\ - replace('
','\n') - try: - return [album, output] - except: - return [album, output.encode('utf-8')] + album = str(s.find('i').find('a').text) + lyrics = s.find("div",{'class':'lyricbox'}) + + if lyrics is None: + raise ValueError("API could not find the lyrics to the song.") + return None + + # Remove Scripts + [s.extract() for s in lyrics('script')] + + # Remove Comments + comments = lyrics.findAll(text=lambda text:isinstance(text, Comment)) + [comment.extract() for comment in comments] + + # Remove unecessary tags + for tag in ['div','i','b','a']: + for match in lyrics.findAll(tag): + match.replaceWithChildren() + #Get output as a string and remove non unicode characters and replace\ + #
with newlines + + # Python 3 + if sys.version_info.major > 2: + output = str(lyrics).encode('utf-8', errors='replace')[22:-6:].\ + decode("utf-8").replace('\n','').replace('
','\n') + else: # Python 2 + output = str(lyrics)[22:-6:].decode("utf-8").replace('\n','').\ + replace('
','\n') + try: + return [album, output] + except: + return [album, output.encode('utf-8')] def main(): albums = PyLyrics.getAlbums('OneRepublic') diff --git a/PyLyrics/functions.pyc b/PyLyrics/functions.pyc index 8bd9a139e02d4ff8be4f535023390cc8e706849c..5ea3ce6fb40f9d5222a511a3500617c2f3e7c39a 100644 GIT binary patch literal 5838 zcmbVQ-Etg96+XRx`j>3UmM!9hbvb1=21`j51j<;(jzT3NLAXW%C8{!8qnVL3tJ&H0 zbgwN{q#JDBfCr(92jBuOxS%RL0B^w^H}HL@_s3R6vgNgV)YH>Hr_cG$cTRWtKQohm z{>$W}Ncz7r{@zEi|H322eK^vXZpRvQ?ILMYbx^uF6(b%y*2b$yRMJ z*O+XLNnDm>Ty`)~MV^a16Zv{;LgMP6wKi;>lz42=IzDWjk{I1*B%T~LO-nq*m#rB| zW+k4M{gM>_lw^jpn_M@t(U`@i(*NPN-rz>v3?3gPVb7&Iy=$)+ttaaM$BzJBO z_4V*cx*Kk1$%ZS^eAiXc_GJ-9`w=SoGkAW4Vt<530tr+<6s1J%u~L?}q?HP{&X%eK z8;uGEM0~K6P}WfF_whI~awO73rKAZY5yf28w^!%cwm({Nk`kBfGNG%OjU|a=Y9;bmREaY^HhY znoTOna-^6E{EH~gpy(dh0UKzIW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=z@_D-g&0+RKcKcZ`0W}pALjBZ27Xec-nq**eb(WdGq0EH-wy)W$9LE$m9 z(@Ozpb_;pW)&NLj Date: Wed, 19 Jun 2019 15:32:15 -0700 Subject: [PATCH 8/8] Handle empty bs4.element.Tag object --- PyLyrics/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyLyrics/functions.py b/PyLyrics/functions.py index c93d8fc..ec10f5f 100644 --- a/PyLyrics/functions.py +++ b/PyLyrics/functions.py @@ -78,7 +78,7 @@ def getLyrics(singer, song): r = requests.get('http://lyrics.wikia.com/{0}:{1}'.format(singer,song)) s = BeautifulSoup(r.text, features="html.parser") if s.find('i') is None: - raise ValueError("API could not find the song.") + # raise ValueError("API could not find the song.") return None album = str(s.find('i').find('a').text)