forked from Wobbl/Wobuzz
Made the tracks get copied into the library on import.
This commit is contained in:
parent
259b453358
commit
4ae398c6aa
3 changed files with 43 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from PyQt6.QtWidgets import QTabWidget, QAbstractItemView
|
||||
|
||||
from ..player.playlist import Playlist
|
||||
|
@ -114,6 +115,30 @@ class Library:
|
|||
|
||||
playlist.load()
|
||||
|
||||
def import_tracks(self, tracks: list[str]):
|
||||
playlist = Playlist(self.app, "Temporary Playlist", tracks, True)
|
||||
|
||||
self.replace_temporary_playlist(playlist)
|
||||
|
||||
self.load_playlist_views()
|
||||
playlist.load()
|
||||
|
||||
def import_track(self, track):
|
||||
artist_path = os.path.expanduser(f"{self.app.settings.library_path}/artists/{track.metadata.artist}")
|
||||
|
||||
if not os.path.exists(artist_path):
|
||||
os.makedirs(artist_path)
|
||||
|
||||
new_track_path = f"{artist_path}/{track.path.split("/")[-1]}"
|
||||
|
||||
if track.path == new_track_path or os.path.exists(new_track_path): # track is already in the library
|
||||
return
|
||||
|
||||
shutil.copyfile(track.path, new_track_path)
|
||||
|
||||
track.path = new_track_path
|
||||
track.metadata.path = new_track_path
|
||||
|
||||
def open_playlist(self, playlist_path: str):
|
||||
playlist = Playlist(self.app, "Temporary Playlist", playlist_path)
|
||||
|
||||
|
@ -124,7 +149,13 @@ class Library:
|
|||
playlist.load()
|
||||
|
||||
def import_playlist(self, playlist_path: str):
|
||||
self.open_playlist(playlist_path)
|
||||
playlist = Playlist(self.app, "Temporary Playlist", playlist_path, import_tracks=True)
|
||||
|
||||
self.replace_temporary_playlist(playlist)
|
||||
|
||||
self.load_playlist_views()
|
||||
|
||||
playlist.load()
|
||||
|
||||
def loaded_track(self, track_path: str):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue