geekpradd / PyLyrics

A Pythonic Implementation of lyrics.wikia.com for getting lyrics of songs
72 stars 27 forks source link

Error with the script given in description #22

Open lachhebo opened 4 years ago

lachhebo commented 4 years ago

When :

from PyLyrics import *

albums = PyLyrics.getAlbums(singer='Eminem')
myalbum = albums[4] #Select your album based on Index

tracks = myalbum.tracks() #or PyLyrics.getTracks(myalbum)
for track in tracks:
    print (track) #Each track is a track object
    print (track.getLyrics()) #Get the lyrics

Then :

  soup = BeautifulSoup(requests.get(url).text)
Traceback (most recent call last):
  File "crawler.py", line 31, in <module>
    tracks = myalbum.tracks() #or PyLyrics.getTracks(myalbum)
  File "/home/isma/.local/lib/python3.7/site-packages/PyLyrics/functions.py", line 38, in tracks
    return PyLyrics.getTracks(self)
  File "/home/isma/.local/lib/python3.7/site-packages/PyLyrics/functions.py", line 69, in getTracks
    songs =[Track(song.text,album,album.artist()) for song in currentAlbum.findNext('songs').findAll('item')]
UnboundLocalError: local variable 'currentAlbum' referenced before assignment
➜  LyricsGenerator