stuff working more

This commit is contained in:
0x01FE committed 2025-01-23 12:14:38 -06:00
1 parent e7f7f70f7b
commit 1d56b5efea
5 files changed
+159 -14

No files matched your search

+13 -1
View File
@@ -177,7 +177,7 @@ class SubpyConn:
return ArtistIndexes(requests.get(url + self._encodePayload(self._getBasePayload())).content)
def _getMusicDirectory(self, id: str):
url = 'https://' + self.base_url + '/rest/getMusicDirectory?'
url = self.base_url + '/rest/getMusicDirectory?'
payload = self._getBasePayload()
payload['id'] = id
@@ -230,6 +230,18 @@ class SubpyConn:
return artists
def getAlbums(self) -> list[Album]:
url = self.base_url + '/rest/getAlbumList?'
payload = self._getBasePayload()
payload['type'] = 'alphabeticalByName'
payload['size'] = 20
r = requests.get(url + self._encodePayload(payload))
with open("albumList.xml" , 'wb') as file:
file.write(r.content)
# Returns a requests Response object, the data stream can be found in Response.content
def stream(self, song_id: str) -> requests.Response:
url = self.base_url + '/rest/stream?'
+3 -1
View File
@@ -89,7 +89,9 @@ class SubPyPlayer:
def exit_program(self, button: urwid.Button) -> None:
raise urwid.ExitMainLoop()
player = SubPyPlayer(conn)
# player = SubPyPlayer(conn)
conn.getAlbums()
# player.play_song(echidna_id)
+142
View File
@@ -0,0 +1,142 @@
import logging
import os
from enum import Enum
LOG_FILE = 'textual.log'
LOGGING_LEVEL = logging.DEBUG
LOG_FORMAT = '[%(asctime)s] %(levelname)s in %(module)s: %(message)s'
# Clear Log File
os.remove(LOG_FILE)
logging.basicConfig(filename=LOG_FILE, level=LOGGING_LEVEL, format=LOG_FORMAT)
import SubSonic
from textual import on, events
from textual.app import App, ComposeResult
from textual.widgets import Footer, Header, OptionList, DataTable, Tabs, Tab, TabbedContent, TabPane
from textual.screen import Screen
from textual.widgets.option_list import Option
u = 'pseudo'
p = 'telegram9dock-MICHEL'
conn = SubSonic.SubpyConn(u, p, "https://music.0x01fe.net")
class AlbumSongs(Screen):
BINDINGS = [
('escape', 'die()', "Back")
]
def __init__(self, album_id: str):
self.album_id = album_id
super().__init__()
def compose(self) -> ComposeResult:
yield DataTable(id="albumSongs")
yield Footer()
def on_mount(self) -> None:
songs = conn.getAlbumSongs(self.album_id)
songsTable: DataTable = self.query_one(DataTable)
songsTable.cursor_type = 'row'
songsTable.add_columns("#", "Title", "Artist", "Duration", "Bitrate")
for song in songs:
songsTable.add_row(song.trackNumber, song.title, song.artist, song.duration, song.bitRate, key=song.id)
# Pops and uninstalls self
def action_die(self) -> None:
app.pop_screen()
app.uninstall_screen("albumSongs")
class ArtistAlbums(Screen):
BINDINGS = [
('escape', 'die()', "Back")
]
def __init__(self, artist_id: str):
self.artist_id = artist_id
super().__init__()
def compose(self) -> ComposeResult:
yield DataTable(id="Albums")
yield Footer()
def on_mount(self) -> None:
albums = conn.getArtistAlbums(self.artist_id)
albumTable: DataTable = self.query_one(DataTable)
albumTable.cursor_type = 'row'
albumTable.add_columns("Title", "Songs")
for album in albums:
albumTable.add_row(album.title, album.songCount, key=album.id)
@on(DataTable.RowSelected)
async def album_selected(self, event: DataTable.RowSelected) -> None:
app.install_screen(AlbumSongs(event.row_key.value), "albumSongs")
app.push_screen("albumSongs")
# Pops and uninstalls self
def action_die(self) -> None:
app.pop_screen()
app.uninstall_screen("artistAlbums")
class Artists(Screen):
BINDINGS = [
('escape', 'app.pop_screen', "Back")
]
def compose(self) -> ComposeResult:
yield OptionList(id="Artists")
yield Footer()
def on_mount(self) -> None:
artists = conn.getArtists()
artistList = self.query_one(OptionList)
for artist in artists:
artistList.add_option(Option(artist.name, artist.id))
@on(OptionList.OptionSelected)
def artist_selected(self, event: OptionList.OptionSelected) -> None:
app.install_screen(ArtistAlbums(event.option_id), 'artistAlbums')
app.push_screen('artistAlbums')
class Albums(Screen):
BINDINGS = [
('escape', 'app.pop_screen', "Back")
]
def compose(self) -> ComposeResult:
yield DataTable()
yield Footer()
def on_mount(self) -> None:
albums = conn.getAlbums()
class TextualSubpyPlayer(App):
BINDINGS = [
("f1", "push_screen('artists')", "Artists"),
("f2", "push_screen('albums')", "Albums")
]
def compose(self) -> ComposeResult:
yield Footer()
def on_mount(self) -> None:
self.install_screen(Artists(), name="artists")
def on_key(self, event: events.Key) -> None:
logging.debug(f'Key Pressed {event.name}')
if __name__ == '__main__':
app = TextualSubpyPlayer()
app.run()
-2
View File
@@ -23,8 +23,6 @@ from textual.widgets.option_list import Option
u = 'pseudo'
p = 'telegram9dock-MICHEL'
conn = SubSonic.SubpyConn(u, p, "music.0x01fe.net")
class Menus(Enum):
MAIN = "MAIN"
ARTISTS = "Artists"
+1 -10
View File
@@ -1,10 +1 @@
[2025-01-23 11:19:08,906] DEBUG in selector_events: Using selector: EpollSelector
[2025-01-23 11:19:08,964] DEBUG in textual-test: Artists tab selected
[2025-01-23 11:19:08,966] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-23 11:19:09,267] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=dff0ee3a818ed4cd4b15e1d30972b9de&s=419LM0NL&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-23 11:19:10,298] DEBUG in textual-test: Key Pressed right
[2025-01-23 11:19:10,307] DEBUG in textual-test: Albums tab selected
[2025-01-23 11:19:11,009] DEBUG in textual-test: Key Pressed left
[2025-01-23 11:19:11,015] DEBUG in textual-test: Artists tab selected
[2025-01-23 11:19:11,017] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-23 11:19:11,338] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getIndexes?u=pseudo&t=df38529ec337b09026c038ea4ed94b26&s=C0ADXZ3M&v=1.16.1&c=testing HTTP/1.1" 200 None
[2025-01-23 12:06:54,543] DEBUG in selector_events: Using selector: EpollSelector