From c617033476f455ef1578238087097e8e732f08fd Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 1 Nov 2015 11:01:40 -0800 Subject: [PATCH] convert: Add some comments --- beetsplug/convert.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 3183f80f5..ca28d7ffd 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -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.