Added popup on import where the user can configure how the tracks get imported.

This commit is contained in:
The Wobbler 2025-03-08 17:50:45 +01:00
parent 31b2e3bf41
commit fd34476d00
12 changed files with 289 additions and 28 deletions

View file

@ -2,16 +2,16 @@
import os
import threading
from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QAbstractItemView
from .track import Track, TrackMetadata
from ..wobuzzm3u import WobuzzM3U, WBZM3UData
from ..types import Types
class Playlist:
def __init__(self, app, title: str, load_from=None, import_tracks: bool=False):
def __init__(self, app, title: str, load_from=None, import_options: Types.ImportOptions=None):
self.app = app
self.title = title # playlist title
@ -20,7 +20,7 @@ class Playlist:
# if None, playlist should be already in the library and will be loaded from a .wbz.m3u
self.load_from = load_from
self.import_tracks = import_tracks
self.import_options = import_options
# add to unique names so if the playlist is loaded from disk,
# no other playlist can be created using the same name
@ -96,9 +96,9 @@ class Playlist:
self.loading = False
if self.import_tracks:
if self.import_options is not None:
for track in self.tracks:
self.app.library.import_track(track)
self.app.library.import_track(track, self.import_options)
for dock_id in self.views: # enable drag and drop on every view
view = self.views[dock_id]

View file

@ -1,11 +1,15 @@
#!/usr/bin/python3
import os
import shutil
from pydub import AudioSegment
from pygame.mixer import Sound
from tinytag import TinyTag
from tinytag.tinytag import Images as TTImages
from dataclasses import dataclass
from ..types import Types
@dataclass
class TrackMetadata:
@ -163,3 +167,18 @@ class Track:
self.items.remove(item)
self.occurrences.pop(playlist)
def copy(self, dest: str, copy_type: int=Types.CopyType.symlink, moved: bool=True):
match copy_type:
case Types.CopyType.symlink:
os.symlink(self.path, dest)
case Types.CopyType.copy:
shutil.copyfile(self.path, dest)
case Types.CopyType.move:
shutil.move(self.path, dest)
if moved: # update path variables
self.path = dest
self.metadata.path = dest