v0.75.0: Preferences › General › Compress lossless imports to MP3

FLAC, WAV, AIFF and Apple Lossless files being imported are converted by
ffmpeg to an MP3 at 320/256/192/160/128 kbps (off by default) and the MP3
goes in the library, tags and cover art copied over. The original file is
only ever read. One song shows its progress in the status bar; more get a
window with a bar per song and Cancel / Done. Cancel takes back every song
the import added, finished ones included: the copies it made go to the
trash, and a file imported in place is never trashed.
This commit is contained in:
2026-10-21 22:28:49 -07:00
parent a43f0be9d8
commit fc1cd80d35
10 changed files with 1082 additions and 13 deletions
+31 -2
View File
@@ -303,7 +303,11 @@ class LibraryManager(QObject):
# ---- playlist contents ----
def add_tracks_to_playlist(self, pid: str, track_ids: list[int],
position: int | None = None):
position: int | None = None,
undoable: bool = True):
"""``undoable=False`` is for a compressing import, whose Cancel is
its undo: an undo step left behind would put back ids Cancel
removed."""
playlist = self.library.playlists.get(pid)
if not playlist or playlist.playlist_type == PlaylistType.FOLDER \
or playlist.is_smart:
@@ -318,7 +322,8 @@ class LibraryManager(QObject):
else:
after[position:position] = track_ids
self._set_track_ids(pid, after)
self._push_track_ids("Add to Playlist", pid, before, after)
if undoable:
self._push_track_ids("Add to Playlist", pid, before, after)
def remove_tracks_from_playlist(self, pid: str, rows: list[int]):
playlist = self.library.playlists.get(pid)
@@ -471,6 +476,30 @@ class LibraryManager(QObject):
undo=undo, redo=redo))
return [t.track_id for t in tracks], failures
def discard_imports(self, track_ids: list[int], trash_files: set[int]):
"""Take back tracks an import just added (Cancel on a compressing
import). Files of the ids in ``trash_files`` — the copies and MP3s
that import made — go to the desktop trash; any other file (one
imported by reference from inside the music folder) is left alone.
Not an undo step: adding them wasn't one either. Returns the
``(name, error)`` of files that couldn't be trashed; those tracks
are removed from the library anyway, since the file is a copy."""
tracks = [self.library.tracks[tid] for tid in dict.fromkeys(track_ids)
if tid in self.library.tracks]
failures = []
for track in tracks:
if track.track_id not in trash_files:
continue
try:
self._trash_file(track)
except trash.TrashError as e:
log.warning("Could not trash %s: %s", track.location, e)
failures.append((track.name or str(track.location), str(e)))
if tracks:
self._remove_tracks(
tracks, self._playlist_snapshots([t.track_id for t in tracks]))
return failures
def _trash_file(self, track) -> Path:
"""Send a track's file to the trash and tidy up the folders it emptied."""
if not track.location: