From fcf5ec0b689debae4bca634ae54e652481d46814 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 12 Oct 2012 22:19:27 -0700 Subject: [PATCH] convert: low-level tweaks Mainly adding some careful handling of paths (pass through displayable_path before logging, etc.). --- beetsplug/convert.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index c148a2bf3..5a466aca7 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -19,8 +19,6 @@ import os import shutil from subprocess import Popen, PIPE -import imghdr - from beets.plugins import BeetsPlugin from beets import ui, library, util from beetsplug.embedart import _embed @@ -63,20 +61,24 @@ def convert_item(lib, dest_dir): while True: item = yield if item.format != 'FLAC' and item.format != 'MP3': - log.info('Skipping {0} : not supported format'.format(item.path)) + log.info('Skipping {0} (unsupported format)'.format( + util.displayable_path(item.path) + )) continue dest = os.path.join(dest_dir, lib.destination(item, fragment=True)) dest = os.path.splitext(dest)[0] + '.mp3' if os.path.exists(dest): - log.info('Skipping {0} : target file exists'.format(item.path)) + log.info('Skipping {0} (target file exists)'.format( + util.displayable_path(item.path) + )) continue util.mkdirall(dest) if item.format == 'MP3' and item.bitrate < 1000 * conf['max_bitrate']: - log.info('Copying {0}'.format(item.path)) - shutil.copy(item.path, dest) + log.info('Copying {0}'.format(util.displayable_path(item.path))) + util.copy(item.path, dest) dest_item = library.Item.from_path(dest) else: encode(item.path, dest) @@ -92,8 +94,7 @@ def convert_item(lib, dest_dir): def convert_func(lib, config, opts, args): dest = opts.dest if opts.dest is not None else conf['dest'] if not dest: - log.error('No destination set') - return + raise ui.UserError('no convert destination set') threads = opts.threads if opts.threads is not None else conf['threads'] fmt = '$albumartist - $album' if opts.album \