mirror of
https://github.com/beetbox/beets.git
synced 2026-01-16 05:02:28 +01:00
add option to convert items after import
convert items after imports but also keep original files intact
This commit is contained in:
parent
1bc00105bd
commit
18e8b73c33
1 changed files with 30 additions and 1 deletions
|
|
@ -138,6 +138,7 @@ class ConvertPlugin(BeetsPlugin):
|
|||
},
|
||||
'max_bitrate': 500,
|
||||
'auto': False,
|
||||
'auto_keep': False,
|
||||
'tmpdir': None,
|
||||
'quiet': False,
|
||||
'embed': True,
|
||||
|
|
@ -148,7 +149,7 @@ class ConvertPlugin(BeetsPlugin):
|
|||
'album_art_maxwidth': 0,
|
||||
'delete_originals': False,
|
||||
})
|
||||
self.early_import_stages = [self.auto_convert]
|
||||
self.early_import_stages = [self.auto_convert, self.auto_convert_keep]
|
||||
|
||||
self.register_listener('import_task_files', self._cleanup)
|
||||
|
||||
|
|
@ -184,6 +185,34 @@ class ConvertPlugin(BeetsPlugin):
|
|||
par_map(lambda item: self.convert_on_import(config.lib, item),
|
||||
task.imported_items())
|
||||
|
||||
def auto_convert_keep(self, config, task):
|
||||
if self.config['auto_keep']:
|
||||
fmt = self.config['format'].as_str().lower()
|
||||
|
||||
dest = self.config['dest'].get()
|
||||
if not dest:
|
||||
raise ui.UserError('no convert destination set')
|
||||
dest = util.bytestring_path(dest)
|
||||
|
||||
path_formats = ui.get_path_formats(self.config['paths'] or None)
|
||||
|
||||
hardlink = self.config['hardlink'].get(bool)
|
||||
link = self.config['link'].get(bool)
|
||||
|
||||
threads = self.config['threads'].get(int)
|
||||
|
||||
items = task.imported_items()
|
||||
convert = [self.convert_item(dest,
|
||||
False,
|
||||
path_formats,
|
||||
fmt,
|
||||
False,
|
||||
link,
|
||||
hardlink)
|
||||
for _ in range(threads)]
|
||||
pipe = util.pipeline.Pipeline([iter(items), convert])
|
||||
pipe.run_parallel()
|
||||
|
||||
# Utilities converted from functions to methods on logging overhaul
|
||||
|
||||
def encode(self, command, source, dest, pretend=False):
|
||||
|
|
|
|||
Loading…
Reference in a new issue