Skip to content

Commit

Permalink
convert: Add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo committed Nov 1, 2015
1 parent 5f5a894 commit c617033
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion beetsplug/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,22 @@ def convert_on_import(self, lib, item):
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.
Expand Down

0 comments on commit c617033

Please sign in to comment.