From f58d4e838a22f46a300098887edf95a34c81b5a3 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sat, 16 Apr 2016 21:25:49 -0300 Subject: [PATCH 01/15] Query data from items and export the json Based on the ``info`` plugin --- beetsplug/export.py | 145 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 beetsplug/export.py diff --git a/beetsplug/export.py b/beetsplug/export.py new file mode 100644 index 000000000..a92e57265 --- /dev/null +++ b/beetsplug/export.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +# This file is part of beets. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +"""Exports data from beets +""" + +from __future__ import division, absolute_import, print_function + +import json +import codecs + +from datetime import datetime, date +from beets.plugins import BeetsPlugin +from beets import ui +from beets import mediafile +from beetsplug.info import make_key_filter, library_data, tag_data + +json.JSONEncoder.default = lambda self, obj: \ + (obj.isoformat() if isinstance(obj, datetime) or isinstance(obj, date) + else None) + + +class ExportPlugin(BeetsPlugin): + + def __init__(self): + super(ExportPlugin, self).__init__() + + self.config.add({ + 'default_format': 'json', + 'json': { + # json module formatting options + 'formatting': { + 'ensure_ascii': False, + 'indent': 4, + 'separators': (',', ': '), + } + }, + # TODO: Use something like the edit plugin + # 'item_fields': [] + }) + + def commands(self): + # TODO: Add option to use albums + + cmd = ui.Subcommand('export', help=u'export data from beets') + cmd.func = self.run + cmd.parser.add_option( + u'-l', u'--library', action='store_true', + help=u'show library fields instead of tags', + ) + cmd.parser.add_option( + u'--append', action='store_true', default=False, + help=u'if should append data to the file', + ) + cmd.parser.add_option( + u'-i', u'--include-keys', default=[], + action='append', dest='included_keys', + help=u'comma separated list of keys to show', + ) + cmd.parser.add_option( + u'-p', u'--path', + help=u'path for the output file. If not given, will print the data' + ) + return [cmd] + + def run(self, lib, opts, args): + + file_path = opts.path + file_format = self.config['default_format'].get(str) + file_mode = 'a' if opts.append else 'w' + format_options = self.config[file_format]['formatting'].get(dict) + + export_format = ExportFormat.factory( + file_format, **{ + 'file_path': file_path, + 'file_mode': file_mode + } + ) + + items = [] + data_collector = library_data if opts.library else tag_data + + included_keys = [] + for keys in opts.included_keys: + included_keys.extend(keys.split(',')) + key_filter = make_key_filter(included_keys) + + for data_emitter in data_collector(lib, ui.decargs(args)): + try: + data, item = data_emitter() + except (mediafile.UnreadableFileError, IOError) as ex: + self._log.error(u'cannot read file: {0}', ex) + continue + + data = key_filter(data) + items += [data] + + export_format.export(items, **format_options) + + +class ExportFormat(object): + """The output format type""" + + @classmethod + def factory(self, type, **kwargs): + if type == "json": + if kwargs['file_path']: + return JsonFileFormat(**kwargs) + else: + return JsonPrintFormat() + raise NotImplemented("") + + def export(self, data, **kwargs): + raise NotImplemented("") + + +class JsonPrintFormat(ExportFormat): + """Outputs to the console""" + + def export(self, data, **kwargs): + ui.print_(json.dumps(data, **kwargs)) + + +class JsonFileFormat(ExportFormat): + """Saves in a json file""" + + def __init__(self, file_path, file_mode=u'w', encoding=u'utf-8'): + self.path = file_path + self.mode = file_mode + self.encoding = encoding + + def export(self, data, **kwargs): + with codecs.open(self.path, self.mode, self.encoding) as f: + json.dump(data, f, **kwargs) From 6cbbba7daeb6546991b681bceb15d5a6d17d901a Mon Sep 17 00:00:00 2001 From: wordofglass Date: Mon, 18 Apr 2016 01:47:39 +0200 Subject: [PATCH 02/15] initial work on allowing slightly non-square images in fetchart --- beetsplug/fetchart.py | 56 ++++++++++++++++++++++++++++++++++++------- test/test_art.py | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 9 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 1f6605608..e8d3e3438 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -30,6 +30,7 @@ from beets import ui from beets import util from beets import config from beets.util.artresizer import ArtResizer +from beets.util import confit try: import itunes @@ -91,6 +92,9 @@ class Candidate(object): u'`enforce_ratio` may be violated.') return self.CANDIDATE_EXACT + short_edge = min(self.size) + long_edge = max(self.size) + # Check minimum size. if extra['minwidth'] and self.size[0] < extra['minwidth']: self._log.debug(u'image too small ({} < {})', @@ -98,10 +102,23 @@ class Candidate(object): return self.CANDIDATE_BAD # Check aspect ratio. - if extra['enforce_ratio'] and self.size[0] != self.size[1]: - self._log.debug(u'image is not square ({} != {})', - self.size[0], self.size[1]) - return self.CANDIDATE_BAD + edge_diff = long_edge - short_edge + if extra['enforce_ratio']: + if extra['margin_px'] and edge_diff > extra['margin_px']: + self._log.debug(u'image is notblablapxsquare ({} != {})', + self.size[0], self.size[1]) + return self.CANDIDATE_BAD + elif extra['margin_percent'] and \ + edge_diff > extra['margin_percent'] * long_edge: + self._log.debug(u'image is notblablapercentsquare ({} != {})', + self.size[0], self.size[1]) + return self.CANDIDATE_BAD + elif not extra['margin_px'] and not extra['margin_percent'] and \ + edge_diff: + # also reached for margin_px == 0 and margin_percent == 0.0 + self._log.debug(u'image is not square ({} != {})', + self.size[0], self.size[1]) + return self.CANDIDATE_BAD # Check maximum size. if extra['maxwidth'] and self.size[0] > extra['maxwidth']: @@ -634,9 +651,16 @@ SOURCE_NAMES = {v: k for k, v in ART_SOURCES.items()} class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): + PAT_PX = r"(0|[1-9][0-9]*)px" + PAT_PERCENT = r"(100(\.00?)?|[1-9]?[0-9](\.[0-9]{1,2})?)%" + def __init__(self): super(FetchArtPlugin, self).__init__() + # Holds paths to downloaded images between fetching them and + # placing them in the filesystem. + self.art_paths = {} + self.config.add({ 'auto': True, 'minwidth': 0, @@ -653,13 +677,25 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): self.config['google_key'].redact = True self.config['fanarttv_key'].redact = True - # Holds paths to downloaded images between fetching them and - # placing them in the filesystem. - self.art_paths = {} - self.minwidth = self.config['minwidth'].get(int) self.maxwidth = self.config['maxwidth'].get(int) - self.enforce_ratio = self.config['enforce_ratio'].get(bool) + + # allow both pixel and percentage-based margin specifications + self.enforce_ratio = self.config['enforce_ratio'].get( + confit.OneOf([bool, + confit.String(pattern=self.PAT_PX), + confit.String(pattern=self.PAT_PERCENT)])) + self.margin_px = None + self.margin_percent = None + if type(self.enforce_ratio) is unicode: + if self.enforce_ratio[-1] == u'%': + self.margin_percent = float(self.enforce_ratio[:-1]) / 100 + elif self.enforce_ratio[-2:] == u'px': + self.margin_px = int(self.enforce_ratio[:-2]) + else: + # shouldn't happen + raise confit.ConfigValueError() + self.enforce_ratio = True cover_names = self.config['cover_names'].as_str_seq() self.cover_names = map(util.bytestring_path, cover_names) @@ -765,6 +801,8 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): 'cover_names': self.cover_names, 'cautious': self.cautious, 'enforce_ratio': self.enforce_ratio, + 'margin_px': self.margin_px, + 'margin_percent': self.margin_percent, 'minwidth': self.minwidth, 'maxwidth': self.maxwidth} diff --git a/test/test_art.py b/test/test_art.py index e52eb6772..2e7db8439 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -33,6 +33,7 @@ from beets import importer from beets import logging from beets import util from beets.util.artresizer import ArtResizer, WEBPROXY +from beets.util import confit logger = logging.getLogger('beets.test_art') @@ -534,6 +535,26 @@ class ArtForAlbumTest(UseThePlugin): self.plugin.enforce_ratio = False self._assertImageIsValidArt(self.IMG_500x490, True) + def test_respect_enforce_ratio_px_above(self): + self.plugin.enforce_ratio = True + self.plugin.margin_px = 5 + self._assertImageIsValidArt(self.IMG_500x490, False) + + def test_respect_enforce_ratio_px_below(self): + self.plugin.enforce_ratio = True + self.plugin.margin_px = 15 + self._assertImageIsValidArt(self.IMG_500x490, True) + + def test_respect_enforce_ratio_percent_above(self): + self.plugin.enforce_ratio = True + self.plugin.margin_percent = (500 - 490) / 500 * 0.5 + self._assertImageIsValidArt(self.IMG_500x490, False) + + def test_respect_enforce_ratio_percent_below(self): + self.plugin.enforce_ratio = True + self.plugin.margin_percent = (500 - 490) / 500 * 1.5 + self._assertImageIsValidArt(self.IMG_500x490, True) + def test_resize_if_necessary(self): self._require_backend() self.plugin.maxwidth = 300 @@ -559,6 +580,29 @@ class DeprecatedConfigTest(_common.TestCase): self.assertEqual(type(self.plugin.sources[-1]), fetchart.FileSystem) +class EnforceRatioConfigTest(_common.TestCase): + """Throw some data at the regexes.""" + + def _load_with_config(self, values, should_raise): + if should_raise: + for v in values: + config['fetchart']['enforce_ratio'] = v + with self.assertRaises(confit.ConfigValueError): + fetchart.FetchArtPlugin() + else: + for v in values: + config['fetchart']['enforce_ratio'] = v + fetchart.FetchArtPlugin() + + def test_px(self): + self._load_with_config(u'0px 4px 12px 123px'.split(), False) + self._load_with_config(u'00px stuff5px'.split(), True) + + def test_percent(self): + self._load_with_config(u'0% 0.00% 5.1% 5% 100%'.split(), False) + self._load_with_config(u'00% 1.234% foo5% 100.1%'.split(), True) + + def suite(): return unittest.TestLoader().loadTestsFromName(__name__) From c211aabd72b63cfd049808a90b8791630255d7ac Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sun, 17 Apr 2016 21:39:53 -0300 Subject: [PATCH 03/15] simplify json printing --- beetsplug/export.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/export.py b/beetsplug/export.py index a92e57265..ec90332b4 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -17,6 +17,7 @@ from __future__ import division, absolute_import, print_function +import sys import json import codecs @@ -129,7 +130,7 @@ class JsonPrintFormat(ExportFormat): """Outputs to the console""" def export(self, data, **kwargs): - ui.print_(json.dumps(data, **kwargs)) + json.dump(data, sys.stdout, **kwargs) class JsonFileFormat(ExportFormat): From 1e3704a27e11d1e5caae4ea6cf89edc25f28cb91 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sun, 17 Apr 2016 21:52:09 -0300 Subject: [PATCH 04/15] fix NotImplementedError() --- beetsplug/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beetsplug/export.py b/beetsplug/export.py index ec90332b4..46776354f 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -120,10 +120,10 @@ class ExportFormat(object): return JsonFileFormat(**kwargs) else: return JsonPrintFormat() - raise NotImplemented("") + raise NotImplementedError() def export(self, data, **kwargs): - raise NotImplemented("") + raise NotImplementedError() class JsonPrintFormat(ExportFormat): From 10acea4efd7b3a4b36ebab407eb799fcb6374ac9 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sun, 17 Apr 2016 22:17:56 -0300 Subject: [PATCH 05/15] Remove json monkey-patching and use encoder subclassing --- beetsplug/export.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/beetsplug/export.py b/beetsplug/export.py index 46776354f..379bb708e 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -27,9 +27,13 @@ from beets import ui from beets import mediafile from beetsplug.info import make_key_filter, library_data, tag_data -json.JSONEncoder.default = lambda self, obj: \ - (obj.isoformat() if isinstance(obj, datetime) or isinstance(obj, date) - else None) + +class ExportEncoder(json.JSONEncoder): + """Deals with dates because JSON doesn't have a standard""" + def default(self, o): + if isinstance(o, datetime) or isinstance(o, date): + return o.isoformat() + return json.JSONEncoder.default(self, o) class ExportPlugin(BeetsPlugin): @@ -130,7 +134,7 @@ class JsonPrintFormat(ExportFormat): """Outputs to the console""" def export(self, data, **kwargs): - json.dump(data, sys.stdout, **kwargs) + json.dump(data, sys.stdout, cls=ExportEncoder, **kwargs) class JsonFileFormat(ExportFormat): @@ -143,4 +147,4 @@ class JsonFileFormat(ExportFormat): def export(self, data, **kwargs): with codecs.open(self.path, self.mode, self.encoding) as f: - json.dump(data, f, **kwargs) + json.dump(data, f, cls=ExportEncoder, **kwargs) From 5e3c65d32e36c91f70ec2534f7035098c3072eb1 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sun, 17 Apr 2016 23:37:51 -0300 Subject: [PATCH 06/15] change option letter --- beetsplug/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beetsplug/export.py b/beetsplug/export.py index 379bb708e..b66b549c7 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -74,14 +74,14 @@ class ExportPlugin(BeetsPlugin): help=u'comma separated list of keys to show', ) cmd.parser.add_option( - u'-p', u'--path', + u'-o', u'--output', help=u'path for the output file. If not given, will print the data' ) return [cmd] def run(self, lib, opts, args): - file_path = opts.path + file_path = opts.output file_format = self.config['default_format'].get(str) file_mode = 'a' if opts.append else 'w' format_options = self.config[file_format]['formatting'].get(dict) From 228ffc91beb1ae78f2d27c757a34d017bb373e81 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Sun, 17 Apr 2016 23:47:12 -0300 Subject: [PATCH 07/15] use `sort_keys` to make the data more "predictable" --- beetsplug/export.py | 1 + 1 file changed, 1 insertion(+) diff --git a/beetsplug/export.py b/beetsplug/export.py index b66b549c7..93362550f 100644 --- a/beetsplug/export.py +++ b/beetsplug/export.py @@ -49,6 +49,7 @@ class ExportPlugin(BeetsPlugin): 'ensure_ascii': False, 'indent': 4, 'separators': (',', ': '), + 'sort_keys': True } }, # TODO: Use something like the edit plugin From 20235264a412abdc07a1f0a7289b2170d6ace81e Mon Sep 17 00:00:00 2001 From: wordofglass Date: Mon, 18 Apr 2016 15:23:38 +0200 Subject: [PATCH 08/15] rewire logic a bit; reasonable debug messages --- beetsplug/fetchart.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index e8d3e3438..7bfc5bc23 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -104,17 +104,20 @@ class Candidate(object): # Check aspect ratio. edge_diff = long_edge - short_edge if extra['enforce_ratio']: - if extra['margin_px'] and edge_diff > extra['margin_px']: - self._log.debug(u'image is notblablapxsquare ({} != {})', - self.size[0], self.size[1]) - return self.CANDIDATE_BAD - elif extra['margin_percent'] and \ - edge_diff > extra['margin_percent'] * long_edge: - self._log.debug(u'image is notblablapercentsquare ({} != {})', - self.size[0], self.size[1]) - return self.CANDIDATE_BAD - elif not extra['margin_px'] and not extra['margin_percent'] and \ - edge_diff: + if extra['margin_px']: + if edge_diff > extra['margin_px']: + self._log.debug(u'image is not close enough to being ' + u'square, ({} - {} > {})', + long_edge, short_edge, extra['margin_px']) + return self.CANDIDATE_BAD + elif extra['margin_percent']: + margin_px = extra['margin_percent'] * long_edge + if edge_diff > margin_px: + self._log.debug(u'image is not close enough to being ' + u'square, ({} - {} > {})', + long_edge, short_edge, margin_px) + return self.CANDIDATE_BAD + elif edge_diff: # also reached for margin_px == 0 and margin_percent == 0.0 self._log.debug(u'image is not square ({} != {})', self.size[0], self.size[1]) From 93267639e4019bd8b4e0cd31ca8c188303bc4841 Mon Sep 17 00:00:00 2001 From: wordofglass Date: Mon, 18 Apr 2016 15:32:09 +0200 Subject: [PATCH 09/15] update docs for enforce_ratio --- docs/plugins/fetchart.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/plugins/fetchart.rst b/docs/plugins/fetchart.rst index 863a4996c..591dbc4b4 100644 --- a/docs/plugins/fetchart.rst +++ b/docs/plugins/fetchart.rst @@ -42,7 +42,11 @@ file. The available options are: too big. The resize operation reduces image width to at most ``maxwidth`` pixels. The height is recomputed so that the aspect ratio is preserved. - **enforce_ratio**: Only images with a width:height ratio of 1:1 are - considered as valid album art candidates. Default: ``no``. + considered as valid album art candidates if set to ``yes``. + It is also possible to specify a certain deviation to the exact ratio to + still be considered valid. This can be done either in pixels + (``enforce_ratio: 10px``) or as a percentage of the longer edge + (``enforce_ratio: 0.5%``). Default: ``no``. - **sources**: List of sources to search for images. An asterisk `*` expands to all available sources. Default: ``filesystem coverart itunes amazon albumart``, i.e., everything but From 1644f7117a5f7cd29154a091b6bea017eeb0a06b Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Mon, 18 Apr 2016 11:54:22 -0300 Subject: [PATCH 10/15] documentation for export plugin --- docs/plugins/export.rst | 70 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 docs/plugins/export.rst diff --git a/docs/plugins/export.rst b/docs/plugins/export.rst new file mode 100644 index 000000000..abf56c29c --- /dev/null +++ b/docs/plugins/export.rst @@ -0,0 +1,70 @@ +Export Plugin +============= + +The ``export`` plugin lets you get data from the items and export the content to +a ``json`` file. + +Configuration +------------- +To configure the plugin, make a ``export:`` section in your configuration +file. The default options are:: + + export: + default_format: json + json: + formatting: + ensure_ascii: False + indent: 4 + separators: [',' , ': '] + sort_keys: true + +- **default_format**: Choose the format of the exported content. + Supports json only for now. + +Each format have their own options. + +The ``json`` formatting uses the `json`_ standard library options. +Using custom options overwrites all options at the same level. +The default options used here are: + +- **ensure_ascii**: All non-ASCII characters are escaped with `\uXXXX`, if true. + +- **indent**: The number of spaces for indentation. + +- **separators**: A ``(item_separator, dict_separator)`` tuple + +- **sort_keys**: Sorts the keys of the json + +.. _json: https://docs.python.org/2/library/json.html#basic-usage + +Using +----- + +Enable the ``export`` plugin (see :ref:`using-plugins` for help) and then add a +``export`` section to your :doc:`configuration file ` + +To use, you can enter a :doc:`query ` to get the data from +your library:: + + $ beet export beatles + +If you just want to see specific properties you can use the +``--include-keys`` option to filter them. The argument is a +comma-separated list of simple glob patterns where ``*`` matches any +string. For example:: + + $ beet export -i 'title,mb*' beatles + +Will only show the ``title`` property and all properties starting with +``mb``. You can add the ``-i`` option multiple times to the command +line. + +Additional command-line options include: + +* ``--library`` or ``-l``: Show data from the library database instead of the + files' tags. + +* ``--output`` or ``-o``: Path for an output file. If not informed, will print + the data in the console. + +* ``--append``: Appends the data to the file instead of writing. From 806f4908613f3227e6e3f15ff50b0f87c96d8bee Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Mon, 18 Apr 2016 11:59:48 -0300 Subject: [PATCH 11/15] add export plugin to index.rst --- docs/plugins/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/plugins/index.rst b/docs/plugins/index.rst index 7d6313d7f..260eb7d49 100644 --- a/docs/plugins/index.rst +++ b/docs/plugins/index.rst @@ -44,6 +44,7 @@ Each plugin has its own set of options that can be defined in a section bearing edit embedart embyupdate + export fetchart fromfilename ftintitle @@ -161,6 +162,7 @@ Miscellaneous * :doc:`convert`: Transcode music and embed album art while exporting to a different directory. * :doc:`duplicates`: List duplicate tracks or albums. +* :doc:`export`: Export data from queries to a format. * :doc:`fuzzy`: Search albums and tracks with fuzzy string matching. * :doc:`ihate`: Automatically skip albums and tracks during the import process. * :doc:`info`: Print music files' tags to the console. From 5817c6578ab17e25eb539d41ba7517c2713a8ee7 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Mon, 18 Apr 2016 12:05:16 -0300 Subject: [PATCH 12/15] Add changelog --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 600bc4cb7..5e9fa21e6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,8 @@ New features: for a Microsoft Azure Marketplace free account. Thanks to :user:`Kraymer`. * :doc:`/plugins/fetchart`: Album art can now be fetched from `fanart.tv`_. Albums are matched using the ``mb_releasegroupid`` tag. +* :doc:`/plugins/export`: A new plugin to export the data from queries to a + json format. Thanks to :user:`GuilhermeHideki`. .. _fanart.tv: https://fanart.tv/ From 019d7cd2e67c945fd33b5b1f7bdbc0f928ef9d46 Mon Sep 17 00:00:00 2001 From: Guilherme Danno Date: Mon, 18 Apr 2016 12:36:42 -0300 Subject: [PATCH 13/15] fix some typos --- beetsplug/convert.py | 2 +- docs/plugins/index.rst | 2 +- test/test_edit.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 303a9e149..dd57918d6 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -51,7 +51,7 @@ def replace_ext(path, ext): def get_format(fmt=None): - """Return the command tempate and the extension from the config. + """Return the command template and the extension from the config. """ if not fmt: fmt = config['convert']['format'].get(unicode).lower() diff --git a/docs/plugins/index.rst b/docs/plugins/index.rst index 260eb7d49..24f261963 100644 --- a/docs/plugins/index.rst +++ b/docs/plugins/index.rst @@ -101,7 +101,7 @@ Metadata * :doc:`bpm`: Measure tempo using keystrokes. * :doc:`echonest`: Automatically fetch `acoustic attributes`_ from `the Echo Nest`_ (tempo, energy, danceability, ...). -* :doc:`edit`: Edit metadata from a texteditor. +* :doc:`edit`: Edit metadata from a text editor. * :doc:`embedart`: Embed album art images into files' metadata. * :doc:`fetchart`: Fetch album cover art from various sources. * :doc:`ftintitle`: Move "featured" artists from the artist field to the title diff --git a/test/test_edit.py b/test/test_edit.py index e756f99a2..ab0ae046a 100644 --- a/test/test_edit.py +++ b/test/test_edit.py @@ -31,7 +31,7 @@ class ModifyFileMocker(object): """ def __init__(self, contents=None, replacements=None): - """ `self.contents` and `self.replacements` are initalized here, in + """ `self.contents` and `self.replacements` are initialized here, in order to keep the rest of the functions of this class with the same signature as `EditPlugin.get_editor()`, making mocking easier. - `contents`: string with the contents of the file to be used for From 12c6cbaeee89de56389d972d5930dcbbf7c2f9c4 Mon Sep 17 00:00:00 2001 From: wordofglass Date: Mon, 18 Apr 2016 18:44:20 +0200 Subject: [PATCH 14/15] update changelog --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 600bc4cb7..ed1f17833 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -15,6 +15,9 @@ New features: for a Microsoft Azure Marketplace free account. Thanks to :user:`Kraymer`. * :doc:`/plugins/fetchart`: Album art can now be fetched from `fanart.tv`_. Albums are matched using the ``mb_releasegroupid`` tag. +* :doc:`/plugins/fetchart`: The ``enforce_ratio`` option was enhanced and now + allows specifying a certain deviation that a valid image may have from being + exactly square. .. _fanart.tv: https://fanart.tv/ From c3be244109b4b5eea67cec5b17ffcffdd6dbc379 Mon Sep 17 00:00:00 2001 From: wordofglass Date: Mon, 18 Apr 2016 18:52:18 +0200 Subject: [PATCH 15/15] remove the personal key warning altogether; it's also in the docs and rather obtrusive --- beetsplug/fetchart.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 43da905fd..62a43474e 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -681,13 +681,6 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): available_sources.remove(u'google') sources_name = plugins.sanitize_choices( self.config['sources'].as_str_seq(), available_sources) - if not self.config['fanarttv_key'].get() and \ - u'fanarttv' in sources_name: - self._log.warn( - u'fanart.tv source enabled, but no personal API given. This ' - u'works as of now, however, fanart.tv prefers users to ' - u'register a personal key. Additionaly this makes new art ' - u'available shorter after its upload. See the documentation.') if 'remote_priority' in self.config: self._log.warning( u'The `fetch_art.remote_priority` configuration option has '