diff --git a/wobuzz/command_line.py b/wobuzz/command_line.py index 1b9ab75..c6c631c 100644 --- a/wobuzz/command_line.py +++ b/wobuzz/command_line.py @@ -51,6 +51,7 @@ def main(): app.library.temporary_playlist = playlist app.library.load_playlist_views() + sys.exit(app.qt_app.exec()) diff --git a/wobuzz/player/playlist.py b/wobuzz/player/playlist.py index f01be81..49ac134 100644 --- a/wobuzz/player/playlist.py +++ b/wobuzz/player/playlist.py @@ -7,10 +7,15 @@ from .track import Track class Playlist: - def __init__(self, app, title: str): + def __init__(self, app, title: str, load_from=None): self.app = app self.title = title # playlist title + # if the playlist is imported and not already in the library, this variable will contain the playlist path or + # track path from which the playlist will get imported + # if None, playlist should be already in the library and will be loaded from a .wbz.m3u + self.load_from = load_from + # add to unique names so if the playlist is loaded from disk, # no other playlist can be created using the same name self.app.utils.unique_names.append(self.title) @@ -48,9 +53,16 @@ class Playlist: self.tracks = [] def load(self): - loading_thread = threading.Thread(target=self.load_from_m3u, args=(self.path,)) + loading_thread = threading.Thread(target=self.loading_thread) loading_thread.start() + def loading_thread(self): + if self.load_from is None: # if the playlist is in the library + self.load_from_wbz(self.path) + + elif self.load_from is list: + pass + def load_from_m3u(self, path): file = open(path, "r") m3u = file.read() @@ -83,7 +95,7 @@ class Playlist: self.loaded = True def load_from_wbz(self, path): - pass + self.load_from_m3u(path) # placeholder def has_tracks(self): return len(self.tracks) > 0 diff --git a/wobuzz/ui/playlist_tabs/tab_bar.py b/wobuzz/ui/playlist_tabs/tab_bar.py index 38ffaec..4bee5d8 100644 --- a/wobuzz/ui/playlist_tabs/tab_bar.py +++ b/wobuzz/ui/playlist_tabs/tab_bar.py @@ -42,8 +42,7 @@ class PlaylistTabBar(QTabBar): playlist = playlist_view.playlist - if playlist.has_tracks(): # dont crash when playlist is empty - self.app.player.start_playlist(playlist) + self.app.player.start_playlist(playlist) def contextMenuEvent(self, event: QContextMenuEvent, title=None): # get title by self.tabAt() if the event is called from PyQt, else its executed from the tab title and getting