From b262781f77df498a409c8c97c1698a1c076088eb Mon Sep 17 00:00:00 2001 From: JISAUAY Date: Wed, 15 Jan 2025 17:12:30 -0600 Subject: [PATCH] init --- SubSonic.py | 84 ++++++++++ artist_response.xml | 382 ++++++++++++++++++++++++++++++++++++++++++++ main.py | 8 + 3 files changed, 474 insertions(+) create mode 100644 SubSonic.py create mode 100644 artist_response.xml create mode 100644 main.py diff --git a/SubSonic.py b/SubSonic.py new file mode 100644 index 0000000..89bf358 --- /dev/null +++ b/SubSonic.py @@ -0,0 +1,84 @@ +import random +import string +import hashlib +import urllib.parse + +import xml.etree +import xml.etree.ElementTree + +import requests + + +u = 'pseudo' +p = 'telegram9dock-MICHEL' + + +def saltGenerator() -> str: + return ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(8)) + +salt = saltGenerator() +t = hashlib.md5((p + salt).encode('utf-8')).hexdigest() + +payload = { + "u" : u, + "t" : t, + "s" : salt, + "v" : '1.16.1', + "c" : 'testing' +} + +url = 'https://music.0x01fe.net/rest/getArtists?' + +url = url + urllib.parse.urlencode(payload, quote_via=urllib.parse.quote_plus) + +# print(url) +# response = requests.get(url) + +# with open("artist_response.xml", 'wb') as file: +# file.write(response.content) + + + +class Artist: + + id: str + imageUrl: str + name: str + albumCount: int + + def __init__(self): + pass + + def fromDict(self, d: dict): + self.id = d['id'] + self.imageUrl = d['artistImageUrl'] + self.name = d['name'] + self.albumCount = d['albumCount'] + +def getArtists() -> list[Artist]: + tree = xml.etree.ElementTree.parse("artist_response.xml") + root = tree.getroot() + + artists: list[Artist] = [] + + if root.get('status') != 'ok': + return [] + + for item in root.iter(): + print(item.tag, dict(item.items())) + + if item.tag == '{http://subsonic.org/restapi}artist': + a = Artist() + a.fromDict(dict(item.items())) + + artists.append(a) + + + + return artists + +artists = getArtists() + +for artist in artists: + print(artist.name) + diff --git a/artist_response.xml b/artist_response.xml new file mode 100644 index 0000000..fa0272e --- /dev/null +++ b/artist_response.xml @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..269f625 --- /dev/null +++ b/main.py @@ -0,0 +1,8 @@ +import urwid + +txt = urwid.Text("hello world") +fill = urwid.Filler(txt, "top") +loop = urwid.MainLoop(fill) +loop.run() + +