mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 20:13:37 +01:00
Changes given feedback on https://github.com/beetbox/beets/pull/3554 and trimmed sample html
This commit is contained in:
parent
b7ecf32f28
commit
9ec0d725e5
3 changed files with 229 additions and 1081 deletions
|
|
@ -373,13 +373,14 @@ class Genius(Backend):
|
|||
|
||||
# At least Genius is nice and has a tag called 'lyrics'!
|
||||
# Updated css where the lyrics are based in HTML.
|
||||
try:
|
||||
lyrics = html.find("div", class_="lyrics").get_text()
|
||||
except AttributeError as exc:
|
||||
# html is a NoneType cannot retrieve lyrics
|
||||
self._log.debug(u'Genius lyrics for {0} not found: {1}',
|
||||
page_url, exc)
|
||||
lyrics_div = html.find("div", class_="lyrics")
|
||||
|
||||
# nullcheck
|
||||
if lyrics_div is None:
|
||||
self._log.debug(u'Genius lyrics for {0} not found',
|
||||
page_url)
|
||||
return None
|
||||
lyrics = lyrics_div.get_text()
|
||||
|
||||
return lyrics
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -453,12 +453,8 @@ class LyricsGeniusScrapTest(LyricsGeniusBaseTest):
|
|||
"""
|
||||
# https://github.com/beetbox/beets/issues/3535
|
||||
# expected return value None
|
||||
try:
|
||||
self.assertEqual(genius.lyrics_from_song_api_path('/nolyric'),
|
||||
None)
|
||||
except AttributeError:
|
||||
# if AttributeError we aren't doing a null check
|
||||
self.assertTrue(False)
|
||||
self.assertEqual(genius.lyrics_from_song_api_path('/nolyric'),
|
||||
None)
|
||||
|
||||
|
||||
class SlugTests(unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue