diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index a6d5b7e7a..78eb819b1 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -396,12 +396,15 @@ class LyricsPlugin(BeetsPlugin): cmd.parser.add_option('-p', '--print', dest='printlyr', action='store_true', default=False, help='print lyrics to console') + cmd.parser.add_option('-f', '--force', dest='force_refetch', + action='store_true', default=False, + help='forces the plugin to redownload lyrics') def func(lib, opts, args): # The "write to files" option corresponds to the # import_write config value. write = config['import']['write'].get(bool) for item in lib.items(ui.decargs(args)): - self.fetch_item_lyrics(lib, logging.INFO, item, write) + self.fetch_item_lyrics(lib, logging.INFO, item, write, opts.force_refetch) if opts.printlyr and item.lyrics: ui.print_(item.lyrics) cmd.func = func @@ -411,9 +414,9 @@ class LyricsPlugin(BeetsPlugin): def imported(self, session, task): if self.config['auto']: for item in task.imported_items(): - self.fetch_item_lyrics(session.lib, logging.DEBUG, item, False) + self.fetch_item_lyrics(session.lib, logging.DEBUG, item, False, False) - def fetch_item_lyrics(self, lib, loglevel, item, write): + def fetch_item_lyrics(self, lib, loglevel, item, write, force): """Fetch and store lyrics for a single item. If ``write``, then the lyrics will also be written to the file itself. The ``loglevel`` parameter controls the visibility of the function's status log @@ -422,10 +425,11 @@ class LyricsPlugin(BeetsPlugin): fallback = self.config['fallback'].get() # Skip if the item already has lyrics. - if item.lyrics: - log.log(loglevel, u'lyrics already present: %s - %s' % - (item.artist, item.title)) - return + if not force: + if item.lyrics: + log.log(loglevel, u'lyrics already present: %s - %s' % + (item.artist, item.title)) + return # Fetch lyrics. lyrics = self.get_lyrics(item.artist, item.title) diff --git a/docs/plugins/lyrics.rst b/docs/plugins/lyrics.rst index 325d398fa..fc67624b1 100644 --- a/docs/plugins/lyrics.rst +++ b/docs/plugins/lyrics.rst @@ -36,6 +36,9 @@ embedded into files' metadata. The ``-p`` option to the ``lyrics`` command makes it print lyrics out to the console so you can view the fetched (or previously-stored) lyrics. +The ``-f`` option to the ``lyrics`` command forces it to fetch previously +downloaded lyrics. + Configuring -----------