convert: Add some comments

This commit is contained in:
Adrian Sampson 2015-11-01 11:01:40 -08:00
parent 5f5a8946c3
commit c617033476

View file

@ -396,15 +396,22 @@ class ConvertPlugin(BeetsPlugin):
fmt = self.config['format'].get(unicode).lower()
if should_transcode(item, fmt):
command, ext = get_format()
# Create a temporary file for the conversion.
tmpdir = self.config['tmpdir'].get()
fd, dest = tempfile.mkstemp('.' + ext, dir=tmpdir)
dest = util.bytestring_path(dest)
os.close(fd)
dest = util.bytestring_path(dest)
_temp_files.append(dest) # Delete the transcode later.
# Convert.
try:
self.encode(command, item.path, dest)
except subprocess.CalledProcessError:
return
# Change the newly-imported database entry to point to the
# converted file.
item.path = dest
item.write()
item.read() # Load new audio information data.