mirror of
https://github.com/beetbox/beets.git
synced 2025-12-28 19:42:42 +01:00
clean up old files and remove pdb
This commit is contained in:
parent
e49ca34f3c
commit
27b1d6d7cc
1 changed files with 10 additions and 2 deletions
|
|
@ -17,7 +17,6 @@
|
|||
import logging
|
||||
import os
|
||||
import threading
|
||||
import pdb
|
||||
from subprocess import Popen
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -28,6 +27,7 @@ from beets import config
|
|||
log = logging.getLogger('beets')
|
||||
DEVNULL = open(os.devnull, 'wb')
|
||||
_fs_lock = threading.Lock()
|
||||
_convert_tmp = []
|
||||
|
||||
|
||||
def _destination(lib, dest_dir, item, keep_new):
|
||||
|
|
@ -127,6 +127,7 @@ def convert_on_import(lib, item):
|
|||
if item.format != 'MP3' or item.bitrate >= 1000 * maxbr:
|
||||
# Transcoding necessary
|
||||
dest = os.path.splitext(item.path)[0] + '.mp3'
|
||||
_convert_tmp.append(dest)
|
||||
encode(item.path, dest)
|
||||
item.path = dest
|
||||
item.write()
|
||||
|
|
@ -188,9 +189,16 @@ class ConvertPlugin(BeetsPlugin):
|
|||
|
||||
def auto_convert(self, config, task):
|
||||
if self.config['auto_convert'].get():
|
||||
pdb.set_trace()
|
||||
if not task.is_album:
|
||||
convert_on_import(config.lib, task.item)
|
||||
else:
|
||||
for item in task.items:
|
||||
convert_on_import(config.lib, item)
|
||||
|
||||
|
||||
@ConvertPlugin.listen('import_task_files')
|
||||
def _cleanup(task, session):
|
||||
for path in task.old_paths:
|
||||
if path in _convert_tmp and os.path.isfile(path):
|
||||
util.remove(path)
|
||||
_convert_tmp.remove(path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue