mirror of
https://github.com/beetbox/beets.git
synced 2025-12-30 12:32:33 +01:00
convert: low-level tweaks
Mainly adding some careful handling of paths (pass through displayable_path before logging, etc.).
This commit is contained in:
parent
d8433f977c
commit
fcf5ec0b68
1 changed files with 9 additions and 8 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
Loading…
Reference in a new issue