From 6897b684eefbbef42f9b58e597cc018e70998a0f Mon Sep 17 00:00:00 2001 From: JISAUAY Date: Thu, 16 Jan 2025 16:32:30 -0600 Subject: [PATCH] idk what im doing at this point with the audio shit --- .gitignore | 1 + SubSonic.py | 42 +++++++++++++++++++++++------------------- echidna.wav | 0 main.py | 48 +++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 .gitignore create mode 100644 echidna.wav diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/SubSonic.py b/SubSonic.py index cb0cf03..cbbef87 100644 --- a/SubSonic.py +++ b/SubSonic.py @@ -8,9 +8,9 @@ import xml.etree import xml.etree.ElementTree import requests -import libsonic -import simpleaudio -# import pyaudio +# import libsonic +# import simpleaudio +import pyaudio u = 'pseudo' @@ -215,7 +215,17 @@ class SubpyConn: return songs - def stream(self, song_id: str): + def getArtists(self) -> list[Artist]: + artistIndexes: ArtistIndexes = self.getIndexes() + + artists: list[Artist] = [] + for artistIndex in artistIndexes.indexes: + artists.extend(artistIndex.artists) + + return artists + + # 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?' payload = self._getBasePayload() @@ -243,25 +253,19 @@ yakui_id = "7f6ca9951af294420382442061a2d6ee" # for album in yakui_albums: # print(album.name) -helios_songs = conn.getAlbumSongs(helios_id) -for song in helios_songs: - print(song.trackNumber, song.title) +# helios_songs = conn.getAlbumSongs(helios_id) +# for song in helios_songs: +# print(song.trackNumber, song.title) -# class Artist: +# artists = conn.getArtists() -# id: str -# imageUrl: str -# name: str -# albumCount: int +# for artist in artists: +# print(artist.name) -# def __init__(self): -# pass +echidna_id = "937004317800a879f0cddd471fb82387" + +# print(conn.stream(echidna_id).content) -# 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") diff --git a/echidna.wav b/echidna.wav new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py index 269f625..79561e8 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,46 @@ -import urwid +# import urwid -txt = urwid.Text("hello world") -fill = urwid.Filler(txt, "top") -loop = urwid.MainLoop(fill) -loop.run() +# txt = urwid.Text("hello world") +# fill = urwid.Filler(txt, "top") +# loop = urwid.MainLoop(fill) +# loop.run() + +import wave + +import SubSonic +import pyaudio + +u = 'pseudo' +p = 'telegram9dock-MICHEL' +conn = SubSonic.SubpyConn(u, p, "https://music.0x01fe.net") + +echidna_id = "937004317800a879f0cddd471fb82387" + +def play_song(song_id: str): + r = conn.stream(song_id) + + # print(len(r.content)) + + stream_data: bytes = r.content + + def callback(in_data, frame_count, time_info, status): + + return (stream_data, pyaudio.paContinue) + + audio = pyaudio.PyAudio() + + stream = audio.open(format=audio.get_format_from_width(2), + channels=2, + rate=44100, + output=True, + stream_callback=callback) + + # r.content. + + # def stream_callback(in_data) + + + +play_song(echidna_id)