switched screens to be modes so resume event would work for main screen
This commit is contained in:
1 parent
c4cba2af4e
commit
98ab8cb755
2 files changed
+75
-60
No files matched your search
+66
-54
@@ -74,7 +74,6 @@ class AlbumSongs(Screen):
|
|||||||
if song.id == self.selected_song_id:
|
if song.id == self.selected_song_id:
|
||||||
return song
|
return song
|
||||||
|
|
||||||
|
|
||||||
# Pops and uninstalls self
|
# Pops and uninstalls self
|
||||||
def action_die(self) -> None:
|
def action_die(self) -> None:
|
||||||
app.pop_screen()
|
app.pop_screen()
|
||||||
@@ -115,9 +114,6 @@ class ArtistAlbums(Screen):
|
|||||||
app.uninstall_screen("artistAlbums")
|
app.uninstall_screen("artistAlbums")
|
||||||
|
|
||||||
class Artists(Screen):
|
class Artists(Screen):
|
||||||
BINDINGS = [
|
|
||||||
('escape', 'app.pop_screen', "Back")
|
|
||||||
]
|
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield OptionList(id="Artists")
|
yield OptionList(id="Artists")
|
||||||
@@ -136,9 +132,6 @@ class Artists(Screen):
|
|||||||
app.push_screen('artistAlbums')
|
app.push_screen('artistAlbums')
|
||||||
|
|
||||||
class Albums(Screen):
|
class Albums(Screen):
|
||||||
BINDINGS = [
|
|
||||||
('escape', 'app.pop_screen', "Back")
|
|
||||||
]
|
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield DataTable()
|
yield DataTable()
|
||||||
@@ -160,10 +153,6 @@ class Albums(Screen):
|
|||||||
app.push_screen('albumSongs')
|
app.push_screen('albumSongs')
|
||||||
|
|
||||||
class Playlists(Screen):
|
class Playlists(Screen):
|
||||||
BINDINGS = [
|
|
||||||
('escape', 'app.pop_screen', "Back")
|
|
||||||
]
|
|
||||||
|
|
||||||
playlists: list[SubSonic.Playlist] | None = None
|
playlists: list[SubSonic.Playlist] | None = None
|
||||||
selected_playlist_id: str = None
|
selected_playlist_id: str = None
|
||||||
|
|
||||||
@@ -197,7 +186,6 @@ class Playlists(Screen):
|
|||||||
if playlist.id == self.selected_playlist_id:
|
if playlist.id == self.selected_playlist_id:
|
||||||
return playlist
|
return playlist
|
||||||
|
|
||||||
|
|
||||||
class PlaylistSongs(Screen):
|
class PlaylistSongs(Screen):
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
('escape', 'die()', "Back"),
|
('escape', 'die()', "Back"),
|
||||||
@@ -249,10 +237,6 @@ class PlaylistSongs(Screen):
|
|||||||
return song
|
return song
|
||||||
|
|
||||||
class Favourites(Screen):
|
class Favourites(Screen):
|
||||||
BINDINGS = [
|
|
||||||
('escape', 'app.pop_screen', "Back")
|
|
||||||
]
|
|
||||||
|
|
||||||
songs: list[SubSonic.Song] | None = None
|
songs: list[SubSonic.Song] | None = None
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
@@ -271,62 +255,90 @@ class Favourites(Screen):
|
|||||||
for song in self.songs:
|
for song in self.songs:
|
||||||
songTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate, key=song.id)
|
songTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate, key=song.id)
|
||||||
|
|
||||||
|
class MainView(Screen):
|
||||||
|
|
||||||
|
def compose(self) -> ComposeResult:
|
||||||
|
yield Header(icon="")
|
||||||
|
with Horizontal():
|
||||||
|
with Vertical(classes="column"):
|
||||||
|
yield Label("Playing")
|
||||||
|
yield DataTable(id="currently_playing")
|
||||||
|
yield ProgressBar()
|
||||||
|
with Vertical(classes="column"):
|
||||||
|
yield Label("Queue")
|
||||||
|
yield DataTable(id="queue")
|
||||||
|
yield Footer()
|
||||||
|
|
||||||
|
def on_mount(self) -> None:
|
||||||
|
queueTable: DataTable = self.query_one("#queue")
|
||||||
|
queueTable.cursor_type = "row"
|
||||||
|
queueTable.add_columns("Title", "Album", "Artist", "Plays", "Duration", "Bitrate")
|
||||||
|
|
||||||
|
currentlyPlaying: DataTable = self.query_one('#currently_playing')
|
||||||
|
currentlyPlaying.cursor_type = "row"
|
||||||
|
currentlyPlaying.add_columns("", "")
|
||||||
|
|
||||||
|
@on(events.ScreenSuspend)
|
||||||
|
def sus(self, event: events.ScreenSuspend) -> None:
|
||||||
|
logging.debug('sus')
|
||||||
|
|
||||||
|
@on(events.ScreenResume)
|
||||||
|
def screen_resumed(self, event: events.ScreenResume) -> None:
|
||||||
|
|
||||||
|
# Update Queue Table
|
||||||
|
queueTable: DataTable = self.query_one(DataTable)
|
||||||
|
for row_key, row in queueTable.rows.items():
|
||||||
|
queueTable.remove_row(row_key)
|
||||||
|
|
||||||
|
for song in app.song_queue:
|
||||||
|
queueTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate)
|
||||||
|
|
||||||
|
# Update Currently Playing Table
|
||||||
|
if app.currently_playing:
|
||||||
|
song = app.currently_playing
|
||||||
|
currentlyPlaying: DataTable = self.query_one('#currently_playing')
|
||||||
|
currentlyPlaying.add_row("Title", song.title)
|
||||||
|
currentlyPlaying.add_row("Artist", song.artist)
|
||||||
|
currentlyPlaying.add_row("Album", song.album)
|
||||||
|
currentlyPlaying.add_row("Plays", song.playCount if song.playCount else 0)
|
||||||
|
currentlyPlaying.add_row("Duration", song.duration)
|
||||||
|
currentlyPlaying.add_row("Track Number", song.trackNumber)
|
||||||
|
currentlyPlaying.add_row("Bit Rate", song.bitRate)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TextualSubpyPlayer(App):
|
class TextualSubpyPlayer(App):
|
||||||
BINDINGS = [
|
BINDINGS = [
|
||||||
("space", "play_pause_song()", "⏯️"),
|
("space", "play_pause_song()", "⏯️"),
|
||||||
("f1", "push_screen('artists')", "Artists"),
|
("f1", "switch_mode('main')", "Overview"),
|
||||||
("f2", "push_screen('albums')", "Albums"),
|
("f2", "switch_mode('artists')", "Artists"),
|
||||||
("f3", "push_screen('favourites')", "Favourites"),
|
("f3", "switch_mode('albums')", "Albums"),
|
||||||
("f4", "push_screen('playlists')", "Playlists")
|
("f4", "switch_mode('favourites')", "Favourites"),
|
||||||
|
("f5", "switch_mode('playlists')", "Playlists")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
MODES = {
|
||||||
|
"main" : MainView,
|
||||||
|
"artists" : Artists,
|
||||||
|
"albums" : Albums,
|
||||||
|
"favourites" : Favourites,
|
||||||
|
"playlists" : Playlists
|
||||||
|
}
|
||||||
|
|
||||||
currently_playing: SubSonic.Song | None = None
|
currently_playing: SubSonic.Song | None = None
|
||||||
song_queue: list[SubSonic.Song] = []
|
song_queue: list[SubSonic.Song] = []
|
||||||
isPlaying: bool = False
|
isPlaying: bool = False
|
||||||
place: int = 0
|
place: int = 0
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
|
||||||
yield Header(icon="")
|
|
||||||
with Horizontal():
|
|
||||||
with Vertical(classes="column"):
|
|
||||||
yield Label(id="playing")
|
|
||||||
yield ProgressBar()
|
|
||||||
yield DataTable()
|
|
||||||
yield Footer()
|
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
logging.debug("mount called")
|
|
||||||
self.title = "SubPy"
|
self.title = "SubPy"
|
||||||
self.install_screen(Artists(), name="artists")
|
self.switch_mode('main')
|
||||||
self.install_screen(Albums(), name="albums")
|
|
||||||
self.install_screen(Favourites(), name="favourites")
|
|
||||||
self.install_screen(Playlists(), name="playlists")
|
|
||||||
|
|
||||||
queueTable: DataTable = self.query_one(DataTable)
|
|
||||||
queueTable.cursor_type = "row"
|
|
||||||
queueTable.add_columns("Title", "Album", "Artist", "Plays", "Duration", "Bitrate")
|
|
||||||
|
|
||||||
def on_key(self, event: events.Key) -> None:
|
def on_key(self, event: events.Key) -> None:
|
||||||
# logging.debug(f'Key Pressed {event.name}')
|
# logging.debug(f'Key Pressed {event.name}')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@on(events.ScreenSuspend)
|
|
||||||
def sus(self, event: events.ScreenSuspend) -> None:
|
|
||||||
logging.debug('sus')
|
|
||||||
|
|
||||||
def on_screen_suspend(self, event: events.ScreenSuspend) -> None:
|
|
||||||
logging.debug('sus3')
|
|
||||||
|
|
||||||
@on(events.ScreenResume)
|
|
||||||
def screen_resumed(self, event: events.ScreenResume) -> None:
|
|
||||||
logging.debug('Main screen resumed')
|
|
||||||
queueTable: DataTable = self.query_one(DataTable)
|
|
||||||
for row_key, row in queueTable.rows.items():
|
|
||||||
queueTable.remove_row(row_key)
|
|
||||||
|
|
||||||
for song in self.song_queue:
|
|
||||||
queueTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate)
|
|
||||||
|
|
||||||
def play_song(self, song: SubSonic.Song) -> None:
|
def play_song(self, song: SubSonic.Song) -> None:
|
||||||
self.currently_playing = song
|
self.currently_playing = song
|
||||||
self.isPlaying = True
|
self.isPlaying = True
|
||||||
|
|||||||
+9
-6
@@ -1,6 +1,9 @@
|
|||||||
[2025-01-24 13:28:35,298] DEBUG in selector_events: Using selector: EpollSelector
|
[2025-01-24 14:13:51,689] DEBUG in selector_events: Using selector: EpollSelector
|
||||||
[2025-01-24 13:28:35,327] DEBUG in screens-test: mount called
|
[2025-01-24 14:13:53,465] DEBUG in screens-test: sus
|
||||||
[2025-01-24 13:28:36,853] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
|
[2025-01-24 14:13:53,503] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
|
||||||
[2025-01-24 13:28:37,082] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=af331bf0765ef34694c1b437cd1be620&s=QURWEGZ9&v=1.16.1&c=testing HTTP/1.1" 200 None
|
[2025-01-24 14:13:53,724] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getPlaylists?u=pseudo&t=2906549f2dd426cd73b88e461d73472b&s=6D4FZXTN&v=1.16.1&c=testing&f=json HTTP/1.1" 200 705
|
||||||
[2025-01-24 13:28:39,679] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
|
[2025-01-24 14:13:54,681] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
|
||||||
[2025-01-24 13:28:39,872] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getMusicDirectory?u=pseudo&t=ed6bdeb43a72d180720f3cb2091dfb5b&s=0AUHHE1K&v=1.16.1&c=testing&id=0371f111b9d8391a4b669a4199809186 HTTP/1.1" 200 983
|
[2025-01-24 14:13:54,852] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getPlaylist?u=pseudo&t=4caaa96b81eab5329f9b063d7ac830ff&s=9WROPV8Z&v=1.16.1&c=testing&f=json&id=e6e8ff27-2a60-4e33-8aa1-09586191166a HTTP/1.1" 200 None
|
||||||
|
[2025-01-24 14:13:56,439] DEBUG in screens-test: Playing song Chang’e by King Gizzard & The Lizard Wizard.
|
||||||
|
[2025-01-24 14:13:56,441] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
|
||||||
|
[2025-01-24 14:13:56,647] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/stream?u=pseudo&t=6e30cb84d1ae2aaa3bb12c9461150982&s=3EEVNYDL&v=1.16.1&c=testing&id=d926c1f739d868662d17a5e3fa1cfd09 HTTP/1.1" 200 9563445
|
||||||
Reference in new issue
Block a user