Playlists now get loaded when they are started and removed debug prints.
This commit is contained in:
parent
0879575882
commit
0c2c91389d
5 changed files with 12 additions and 30 deletions
|
@ -23,9 +23,7 @@ def main():
|
||||||
app.post_init()
|
app.post_init()
|
||||||
|
|
||||||
if arguments.playlist:
|
if arguments.playlist:
|
||||||
playlist = Playlist(app, "Temporary Playlist")
|
playlist = Playlist(app, "Temporary Playlist", arguments.playlist)
|
||||||
|
|
||||||
playlist.load_from_m3u(arguments.playlist)
|
|
||||||
|
|
||||||
app.library.playlists.append(playlist)
|
app.library.playlists.append(playlist)
|
||||||
|
|
||||||
|
@ -34,15 +32,7 @@ def main():
|
||||||
app.library.temporary_playlist = playlist
|
app.library.temporary_playlist = playlist
|
||||||
|
|
||||||
if arguments.track:
|
if arguments.track:
|
||||||
# make track paths absolute
|
playlist = Playlist(app, "Temporary Playlist", arguments.track)
|
||||||
tracks = []
|
|
||||||
|
|
||||||
for track in arguments.track:
|
|
||||||
tracks.append(os.path.abspath(track))
|
|
||||||
|
|
||||||
playlist = Playlist(app, "Temporary Playlist")
|
|
||||||
|
|
||||||
playlist.load_from_paths(tracks)
|
|
||||||
|
|
||||||
app.library.playlists.append(playlist)
|
app.library.playlists.append(playlist)
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ class Library:
|
||||||
|
|
||||||
def on_exit(self, event):
|
def on_exit(self, event):
|
||||||
for playlist in self.playlists:
|
for playlist in self.playlists:
|
||||||
|
if playlist.loaded: # only save loaded playlists, unloaded are empty
|
||||||
playlist.save()
|
playlist.save()
|
||||||
|
|
||||||
if self.app.player.current_playlist is not None:
|
if self.app.player.current_playlist is not None:
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
from .track import Track
|
from .track import Track
|
||||||
|
|
||||||
|
@ -44,14 +45,10 @@ class Playlist:
|
||||||
path = paths[i]
|
path = paths[i]
|
||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
self.tracks.append(Track(self.app, path, cache=i==0)) # first track is cached
|
self.append_track(Track(self.app, path, cache=i==0)) # first track is cached
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
self.tracks = []
|
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
loading_thread = threading.Thread(target=self.loading_thread)
|
loading_thread = threading.Thread(target=self.loading_thread)
|
||||||
loading_thread.start()
|
loading_thread.start()
|
||||||
|
@ -60,8 +57,11 @@ class Playlist:
|
||||||
if self.load_from is None: # if the playlist is in the library
|
if self.load_from is None: # if the playlist is in the library
|
||||||
self.load_from_wbz(self.path)
|
self.load_from_wbz(self.path)
|
||||||
|
|
||||||
elif self.load_from is list:
|
elif isinstance(self.load_from, str):
|
||||||
pass
|
self.load_from_m3u(self.load_from)
|
||||||
|
|
||||||
|
elif isinstance(self.load_from, list):
|
||||||
|
self.load_from_paths(self.load_from)
|
||||||
|
|
||||||
def load_from_m3u(self, path):
|
def load_from_m3u(self, path):
|
||||||
file = open(path, "r")
|
file = open(path, "r")
|
||||||
|
@ -86,8 +86,6 @@ class Playlist:
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
print("kolupp")
|
|
||||||
|
|
||||||
# set current track to the first track if there is no currently playing track
|
# set current track to the first track if there is no currently playing track
|
||||||
if self.current_track is None and self.has_tracks():
|
if self.current_track is None and self.has_tracks():
|
||||||
self.current_track = self.tracks[0]
|
self.current_track = self.tracks[0]
|
||||||
|
@ -177,9 +175,6 @@ class Playlist:
|
||||||
|
|
||||||
self.tracks.append(track)
|
self.tracks.append(track)
|
||||||
|
|
||||||
print(track.tags.title)
|
|
||||||
|
|
||||||
|
|
||||||
def h_last_track(self):
|
def h_last_track(self):
|
||||||
# get last track in history (only gets used in player.history)
|
# get last track in history (only gets used in player.history)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Track:
|
||||||
self.app = app
|
self.app = app
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
self.tags = TinyTag.get(self.path, ignore_errors=False, duration=False)
|
self.tags = TinyTag.get(self.path, ignore_errors=True, duration=False)
|
||||||
|
|
||||||
self.cached = False
|
self.cached = False
|
||||||
self.audio = None
|
self.audio = None
|
||||||
|
|
|
@ -41,8 +41,6 @@ class PlaylistView(QTreeWidget):
|
||||||
|
|
||||||
self.setHeaderLabels(headers)
|
self.setHeaderLabels(headers)
|
||||||
|
|
||||||
#self.load_tracks()
|
|
||||||
|
|
||||||
self.itemActivated.connect(self.on_track_activation)
|
self.itemActivated.connect(self.on_track_activation)
|
||||||
|
|
||||||
def on_user_sort(self):
|
def on_user_sort(self):
|
||||||
|
@ -143,8 +141,6 @@ class PlaylistView(QTreeWidget):
|
||||||
if track:
|
if track:
|
||||||
playlist_tabs.setTabIcon(index, self.playing_mark) # mark this playlist
|
playlist_tabs.setTabIcon(index, self.playing_mark) # mark this playlist
|
||||||
|
|
||||||
print(self.app.player.current_playlist.current_track_index)
|
|
||||||
|
|
||||||
# mark the current track in this playlist
|
# mark the current track in this playlist
|
||||||
item = self.topLevelItem(self.app.player.current_playlist.current_track_index)
|
item = self.topLevelItem(self.app.player.current_playlist.current_track_index)
|
||||||
item.setIcon(0, self.playing_mark)
|
item.setIcon(0, self.playing_mark)
|
||||||
|
|
Loading…
Add table
Reference in a new issue