Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Plugin: Added dont_convert Option #2751

Merged
merged 5 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions beetsplug/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
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.
Expand Down Expand Up @@ -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).
"""
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
if config['convert']['never_convert_lossy_files'] and \
not (item.format.lower() in LOSSLESS_FORMATS):
return False
Expand Down Expand Up @@ -133,6 +141,7 @@ def __init__(self):
u'quiet': False,
u'embed': True,
u'paths': {},
u'no_convert': u'',
u'never_convert_lossy_files': False,
u'copy_album_art': False,
u'album_art_maxwidth': 0,
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 3 additions & 0 deletions docs/plugins/convert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- **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
as mp3, ogg vorbis, etc.---makes little sense as they will decrease quality
even further. If set to ``yes``, lossy files are always copied.
Expand Down