Skip to content

Commit

Permalink
don't save 'not found' lyrics status.. too ugly if there is a bug som…
Browse files Browse the repository at this point in the history
…ewhere that prevents lyrics from being fetched
  • Loading branch information
Scott Horowitz committed Jan 6, 2008
1 parent 3d7f961 commit 7486b44
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sonata.py
Expand Up @@ -2879,6 +2879,17 @@ def info_get_lyrics(self, search_artist, search_title, filename_artist, filename
filename_title = strip_all_slashes(filename_title)
filename = self.info_check_for_local_lyrics(filename_artist, filename_title)
search_str = link_markup(_("search"), True, True, self.linkcolor)
if filename:
# If the lyrics only contain "not found", delete the file and try to
# fetch new lyrics. If there is a bug in Sonata/SZI/LyricWiki that
# prevents lyrics from being found, storing the "not found" will
# prevent a future release from correctly fetching the lyrics.
f = open(filename, 'r')
lyrics = f.read()
f.close()
if lyrics == _("Lyrics not found"):
os.remove(filename)
filename = self.info_check_for_local_lyrics(filename_artist, filename_title)
if filename:
# Re-use lyrics from file:
f = open(filename, 'r')
Expand Down Expand Up @@ -2933,14 +2944,6 @@ def info_get_lyrics(self, search_artist, search_title, filename_artist, filename
else:
lyrics = _("Lyrics not found")
gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
# Save error to file so that we don't retry the lyrics over and over:
self.create_dir_if_not_existing('~/.lyrics/')
f = open(filename, 'w')
try:
f.write(lyrics.decode(self.enc).encode('utf8'))
except:
f.write(lyrics)
f.close()
except:
lyrics = _("Fetching lyrics failed")
gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
Expand Down

0 comments on commit 7486b44

Please sign in to comment.