From 9f3e5b28b4d3cbacc5d9f08647ef20d3bbca5084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Fri, 14 Jul 2017 15:31:17 -0400 Subject: [PATCH] output lyrics in HTML, allow skipping the idea here is to format the lyrics output a little better so that it can (for example) be shown as a web page or an ebook. the new skip option allows for faster generation of the output in the (most common) case where not all lyrics are available. --- beetsplug/lyrics.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 113bed104..f90159708 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -595,6 +595,7 @@ class LyricsPlugin(plugins.BeetsPlugin): "76V-uFL5jks5dNvcGCdarqFjDhP9c", 'fallback': None, 'force': False, + 'skip': False, 'sources': self.SOURCES, }) self.config['bing_client_secret'].redact = True @@ -663,18 +664,33 @@ class LyricsPlugin(plugins.BeetsPlugin): action='store_true', default=False, help=u'always re-download lyrics', ) + cmd.parser.add_option( + u'-s', u'--skip', dest='skip_fetched', + action='store_true', default=False, + help=u'skip already fetched lyrics', + ) def func(lib, opts, args): # The "write to files" option corresponds to the # import_write config value. write = ui.should_write() + artist = '' + album = '' for item in lib.items(ui.decargs(args)): - self.fetch_item_lyrics( - lib, item, write, - opts.force_refetch or self.config['force'], - ) + if not opts.skip_fetched and not self.config['skip']: + self.fetch_item_lyrics( + lib, item, write, + opts.force_refetch or self.config['force'], + ) if opts.printlyr and item.lyrics: - ui.print_(item.lyrics) + if artist != item.artist: + artist = item.artist + ui.print_('

' + artist + '

') + if album != item.album: + album = item.album + ui.print_('

' + artist + '

') + ui.print_('

' + item.title + '

') + ui.print_('
' + item.lyrics + '
') cmd.func = func return [cmd]