convert do not delete originals if conversion is started from cli
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
In config I have:
```
convert:
auto: no
dest: /home/ander/Music
extension: mp3
command: lame -V0 $source $dest
copy_album_art: yes
delete_originals: yes
```
Currently originals are only deleted on import when `auto: yes`.
Did quick hack:
```diff
diff --git a/beetsplug/convert.py b/beetsplug/convert.py
index 51312d77..748eb179 100644
--- a/beetsplug/convert.py
+++ b/beetsplug/convert.py
@@ -423,6 +423,20 @@ class ConvertPlugin(BeetsPlugin):
else:
util.copy(original, converted)
+ if not keep_new and not linked and self.config["delete_originals"]:
+ if pretend:
+ self._log.info(
+ "rm {0}",
+ util.displayable_path(original)
+ )
+ else:
+ self._log.log(
+ logging.DEBUG if self.config["quiet"] else logging.INFO,
+ "Removing original file {0}",
+ util.displayable_path(original),
+ )
+ util.remove(original, False)
+
if pretend:
continue
@@ -433,7 +447,7 @@ class ConvertPlugin(BeetsPlugin):
# Write tags from the database to the converted file.
item.try_write(path=converted, id3v23=id3v23)
- if keep_new:
+ if keep_new or self.config["delete_originals"]:
# If we're keeping the transcoded file, read it again (after
# writing) to get new bitrate, duration, etc.
item.path = converted
```
It does the job, but maybe I'm missing something?
Contributor guide
Research direction
Start in beetsplug/convert.py and trace the conversion path used by the CLI when auto is disabled, comparing it with the existing auto-conversion behavior. Reproduce the issue with the shown convert configuration and verify that delete_originals has the intended effect without breaking pretend mode or converted-file metadata handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100