testing out a new TUI lib
This commit is contained in:
1 parent
a04dcc85fd
commit
c0986f8d2d
3 files changed
+63
-8
No files matched your search
+5
-5
@@ -2,7 +2,7 @@ import random
|
|||||||
import string
|
import string
|
||||||
import hashlib
|
import hashlib
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import time
|
# import time
|
||||||
|
|
||||||
import xml.etree
|
import xml.etree
|
||||||
import xml.etree.ElementTree
|
import xml.etree.ElementTree
|
||||||
@@ -10,11 +10,11 @@ import xml.etree.ElementTree
|
|||||||
import requests
|
import requests
|
||||||
# import libsonic
|
# import libsonic
|
||||||
# import simpleaudio
|
# import simpleaudio
|
||||||
import pyaudio
|
# import pyaudio
|
||||||
|
|
||||||
|
|
||||||
u = 'pseudo'
|
# u = 'pseudo'
|
||||||
p = 'telegram9dock-MICHEL'
|
# p = 'telegram9dock-MICHEL'
|
||||||
|
|
||||||
class Artist:
|
class Artist:
|
||||||
id: str
|
id: str
|
||||||
@@ -250,7 +250,7 @@ class SubpyConn:
|
|||||||
if item.tag == '{http://subsonic.org/restapi}song':
|
if item.tag == '{http://subsonic.org/restapi}song':
|
||||||
return Song(dict(item.items()))
|
return Song(dict(item.items()))
|
||||||
|
|
||||||
conn = SubpyConn(u, p, "https://music.0x01fe.net")
|
# conn = SubpyConn(u, p, "https://music.0x01fe.net")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class SubPyPlayer:
|
|||||||
urwid.MainLoop(top, palette=[("reversed", "standout", "")]).run()
|
urwid.MainLoop(top, palette=[("reversed", "standout", "")]).run()
|
||||||
|
|
||||||
# Currently Blocking
|
# Currently Blocking
|
||||||
def play_song(song_id: str):
|
def play_song(self, song_id: str):
|
||||||
r = conn.stream(song_id)
|
r = self.conn.stream(song_id)
|
||||||
|
|
||||||
# convert stream to bytes io thing
|
# convert stream to bytes io thing
|
||||||
audio_data = io.BytesIO(r.content)
|
audio_data = io.BytesIO(r.content)
|
||||||
@@ -89,5 +89,7 @@ class SubPyPlayer:
|
|||||||
def exit_program(self, button: urwid.Button) -> None:
|
def exit_program(self, button: urwid.Button) -> None:
|
||||||
raise urwid.ExitMainLoop()
|
raise urwid.ExitMainLoop()
|
||||||
|
|
||||||
SubPyPlayer(conn)
|
player = SubPyPlayer(conn)
|
||||||
|
|
||||||
|
# player.play_song(echidna_id)
|
||||||
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import TermTk as ttk
|
||||||
|
|
||||||
|
import SubSonic
|
||||||
|
|
||||||
|
u = 'pseudo'
|
||||||
|
p = 'telegram9dock-MICHEL'
|
||||||
|
conn = SubSonic.SubpyConn(u, p, "https://music.0x01fe.net")
|
||||||
|
|
||||||
|
echidna_id = "937004317800a879f0cddd471fb82387"
|
||||||
|
|
||||||
|
|
||||||
|
artists = conn.getArtists()
|
||||||
|
selected_artist = None
|
||||||
|
|
||||||
|
root = ttk.TTk(layout=ttk.TTkHBoxLayout())
|
||||||
|
|
||||||
|
# window = ttk.TTkWindow(parent=root, pos=(1, 1), size=(100, 30), title="Testing", border=True)
|
||||||
|
|
||||||
|
# ttk.TTkLabel(parent=window, pos=(5,2), text='hello world')
|
||||||
|
# artistMenu = ttk.TTkMenu(title="Artists", parent=root, border=True, size=(100, 30))
|
||||||
|
# for artist in artists:
|
||||||
|
# newButton = ttk.TTkMenuButton(text=artist.name, parent=artistMenu)
|
||||||
|
# artistMenu.addMenuItem(newButton)
|
||||||
|
|
||||||
|
artistList = ttk.TTkList(
|
||||||
|
name="Artists",
|
||||||
|
parent=root,
|
||||||
|
items=[artist.name for artist in artists]
|
||||||
|
)
|
||||||
|
|
||||||
|
albumList = ttk.TTkList(
|
||||||
|
name="ArtistAlbums",
|
||||||
|
parent=root
|
||||||
|
)
|
||||||
|
|
||||||
|
@ttk.pyTTkSlot(ttk.TTkWidgets.listwidget.TTkAbstractListItem)
|
||||||
|
def clickArtist(v: ttk.TTkWidgets.listwidget.TTkAbstractListItem):
|
||||||
|
# ttk.TTkLog.debug('test')
|
||||||
|
# print(v.text())
|
||||||
|
|
||||||
|
artist_name = v.text()
|
||||||
|
for artist in artists:
|
||||||
|
if artist.name == artist_name:
|
||||||
|
selected_artist = artist.id
|
||||||
|
|
||||||
|
albumList.removeItems(albumList.items())
|
||||||
|
albumList.addItems([album.name for album in conn.getArtistAlbums(selected_artist)])
|
||||||
|
|
||||||
|
|
||||||
|
artistList.itemClicked.connect(clickArtist)
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
Reference in new issue
Block a user