diff --git a/sonata.py b/sonata.py index 25cfeb37..72fe8338 100644 --- a/sonata.py +++ b/sonata.py @@ -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') @@ -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)