From 7265077e75e7f8c5ebb3bb42b3f85c5868ff43e0 Mon Sep 17 00:00:00 2001 From: Aaron Jubbal Date: Wed, 29 Nov 2017 16:13:38 -0800 Subject: [PATCH 1/5] `dont_convert` option implemented. Local testing indicates success. --- beetsplug/convert.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index ec4d7c62e..639741dc3 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -31,6 +31,8 @@ from beets.plugins import BeetsPlugin from beets.util.confit import ConfigTypeError from beets import art from beets.util.artresizer import ArtResizer +from beets.library import parse_query_string +from beets.library import Item _fs_lock = threading.Lock() _temp_files = [] # Keep track of temporary transcoded files for deletion. @@ -92,6 +94,12 @@ def should_transcode(item, fmt): """Determine whether the item should be transcoded as part of conversion (i.e., its bitrate is high or it has the wrong format). """ + dont_convert_queries = config['convert']['dont_convert'].as_str_seq() + if dont_convert_queries: + for query_string in dont_convert_queries: + query, _ = parse_query_string(query_string, Item) + if query.match(item): + return False if config['convert']['never_convert_lossy_files'] and \ not (item.format.lower() in LOSSLESS_FORMATS): return False From e5d782a3b1e79ff99512e1d3043e3871f5f258cf Mon Sep 17 00:00:00 2001 From: Aaron Jubbal Date: Wed, 29 Nov 2017 16:41:27 -0800 Subject: [PATCH 2/5] Added docs for dont_convert option. --- docs/plugins/convert.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/plugins/convert.rst b/docs/plugins/convert.rst index 59036a38b..527bc5d01 100644 --- a/docs/plugins/convert.rst +++ b/docs/plugins/convert.rst @@ -73,6 +73,9 @@ file. The available options are: this does not guarantee that all converted files will have a lower bitrate---that depends on the encoder and its configuration. Default: none. +- **dont_convert**: Does not transcode items matching provided query string + (see :doc:`/reference/query`). (i.e. ``format:AAC, format:WMA`` or + ``path::\.(m4a|wma)$``) - **never_convert_lossy_files**: Cross-conversions between lossy codecs---such as mp3, ogg vorbis, etc.---makes little sense as they will decrease quality even further. If set to ``yes``, lossy files are always copied. From 0998d9f8ef5215f00db1e34562715833c2548a77 Mon Sep 17 00:00:00 2001 From: Aaron Jubbal Date: Wed, 29 Nov 2017 17:53:50 -0800 Subject: [PATCH 3/5] Added default value for dont_convert option, addressing crashes. --- beetsplug/convert.py | 1 + 1 file changed, 1 insertion(+) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 639741dc3..bb2aeae24 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -141,6 +141,7 @@ class ConvertPlugin(BeetsPlugin): u'quiet': False, u'embed': True, u'paths': {}, + u'dont_convert': u'', u'never_convert_lossy_files': False, u'copy_album_art': False, u'album_art_maxwidth': 0, From e24f732014b2ec8e00d3b79719052b4f5782f159 Mon Sep 17 00:00:00 2001 From: Aaron Jubbal Date: Wed, 29 Nov 2017 20:08:50 -0800 Subject: [PATCH 4/5] Changed `dont_convert` to `no_convert`. --- beetsplug/convert.py | 8 ++++---- docs/plugins/convert.rst | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index bb2aeae24..380061248 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -94,9 +94,9 @@ def should_transcode(item, fmt): """Determine whether the item should be transcoded as part of conversion (i.e., its bitrate is high or it has the wrong format). """ - dont_convert_queries = config['convert']['dont_convert'].as_str_seq() - if dont_convert_queries: - for query_string in dont_convert_queries: + no_convert_queries = config['convert']['no_convert'].as_str_seq() + if no_convert_queries: + for query_string in no_convert_queries: query, _ = parse_query_string(query_string, Item) if query.match(item): return False @@ -141,7 +141,7 @@ class ConvertPlugin(BeetsPlugin): u'quiet': False, u'embed': True, u'paths': {}, - u'dont_convert': u'', + u'no_convert': u'', u'never_convert_lossy_files': False, u'copy_album_art': False, u'album_art_maxwidth': 0, diff --git a/docs/plugins/convert.rst b/docs/plugins/convert.rst index 527bc5d01..a631f7891 100644 --- a/docs/plugins/convert.rst +++ b/docs/plugins/convert.rst @@ -73,7 +73,7 @@ file. The available options are: this does not guarantee that all converted files will have a lower bitrate---that depends on the encoder and its configuration. Default: none. -- **dont_convert**: Does not transcode items matching provided query string +- **no_convert**: Does not transcode items matching provided query string (see :doc:`/reference/query`). (i.e. ``format:AAC, format:WMA`` or ``path::\.(m4a|wma)$``) - **never_convert_lossy_files**: Cross-conversions between lossy codecs---such From 7138cae1083cf77c3b8e26795480d737f9cc8396 Mon Sep 17 00:00:00 2001 From: Aaron Jubbal Date: Wed, 29 Nov 2017 20:09:06 -0800 Subject: [PATCH 5/5] Updated changelog. --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index fe19403f0..9fba6392b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,9 @@ New features: * :doc:`/plugins/lyrics`: The plugin can now produce reStructuredText files for beautiful, readable books of lyrics. Thanks to :user:`anarcat`. :bug:`2628` +* :doc:`/plugins/convert`: Adds ``no_convert`` option which ignores transcoding + items matching provided query string. Thanks to :user:`Stunner`. + :bug:`2732` :bug:`2751` * :doc:`/plugins/fetchart`: The plugin has now a quiet switch that will only display missing album arts. Thanks to :user:`euri10`. :bug:`2683`