Skip to content

Commit 28cb79b

Browse files
authored
Merge pull request #2751 from Stunner/dont-convert
Convert Plugin: Added dont_convert Option
2 parents e2defe9 + 7138cae commit 28cb79b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

beetsplug/convert.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from beets.util.confit import ConfigTypeError
3232
from beets import art
3333
from beets.util.artresizer import ArtResizer
34+
from beets.library import parse_query_string
35+
from beets.library import Item
3436

3537
_fs_lock = threading.Lock()
3638
_temp_files = [] # Keep track of temporary transcoded files for deletion.
@@ -92,6 +94,12 @@ def should_transcode(item, fmt):
9294
"""Determine whether the item should be transcoded as part of
9395
conversion (i.e., its bitrate is high or it has the wrong format).
9496
"""
97+
no_convert_queries = config['convert']['no_convert'].as_str_seq()
98+
if no_convert_queries:
99+
for query_string in no_convert_queries:
100+
query, _ = parse_query_string(query_string, Item)
101+
if query.match(item):
102+
return False
95103
if config['convert']['never_convert_lossy_files'] and \
96104
not (item.format.lower() in LOSSLESS_FORMATS):
97105
return False
@@ -133,6 +141,7 @@ def __init__(self):
133141
u'quiet': False,
134142
u'embed': True,
135143
u'paths': {},
144+
u'no_convert': u'',
136145
u'never_convert_lossy_files': False,
137146
u'copy_album_art': False,
138147
u'album_art_maxwidth': 0,

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ New features:
1313
* :doc:`/plugins/lyrics`: The plugin can now produce reStructuredText files
1414
for beautiful, readable books of lyrics. Thanks to :user:`anarcat`.
1515
:bug:`2628`
16+
* :doc:`/plugins/convert`: Adds ``no_convert`` option which ignores transcoding
17+
items matching provided query string. Thanks to :user:`Stunner`.
18+
:bug:`2732` :bug:`2751`
1619
* :doc:`/plugins/fetchart`: The plugin has now a quiet switch that will only
1720
display missing album arts. Thanks to :user:`euri10`.
1821
:bug:`2683`

docs/plugins/convert.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ file. The available options are:
7373
this does not guarantee that all converted files will have a lower
7474
bitrate---that depends on the encoder and its configuration.
7575
Default: none.
76+
- **no_convert**: Does not transcode items matching provided query string
77+
(see :doc:`/reference/query`). (i.e. ``format:AAC, format:WMA`` or
78+
``path::\.(m4a|wma)$``)
7679
- **never_convert_lossy_files**: Cross-conversions between lossy codecs---such
7780
as mp3, ogg vorbis, etc.---makes little sense as they will decrease quality
7881
even further. If set to ``yes``, lossy files are always copied.

0 commit comments

Comments
 (0)