Error in fetching lyrics for a song
udiboy1209 opened this issue · comments
Meet Udeshi commented
Hello,
Traceback (most recent call last):
File "//home/udiboy1209/bin/rhythmRemote.py", line 291, in <module>
main(sys.argv[1:])
File "//home/udiboy1209/bin/rhythmRemote.py", line 259, in main
printLyrics()
File "//home/udiboy1209/bin/rhythmRemote.py", line 90, in printLyrics
lyrics = p.html.body.getlyricresult.lyric.text
AttributeError: 'NoneType' object has no attribute 'body'
I get this error when running ./rhythmRemote.py l
I think p.html is set to None
for some reason
Meet Udeshi commented
OK I found the problem.
Its because api.chartlyrics.com sends an XML page with as the root tag, while line 86 and 87 are trying to parse an HTML file assuming the root tag to be .
Original Code:
# Parse the xml
p = bs4.BeautifulSoup(res)
lyrics = p.html.body.getlyricresult.lyric.text
Modified Code to parse XML:
# Parse the xml
p = bs4.BeautifulSoup(res,"xml")
lyrics = p.GetLyricResult.Lyric.text
Ahmed Azaan commented
Closed, Fixed in #2 by @udiboy1209