working with reactive stuff

This commit is contained in:
JISAUAY committed 2025-01-29 17:02:38 -06:00
1 parent 7ad56fa4be
commit 6c4e9c40b1
4 files changed
+280 -62

No files matched your search

+18 -18
View File
@@ -77,24 +77,24 @@ class Song:
samplingRate: int samplingRate: int
playCount: int | None playCount: int | None
def __init__(self, song_info: dict): def __init__(self, info: dict | None = {}):
self.id = song_info['id'] self.id = info['id'] if 'id' in info else ""
self.title = song_info['title'] self.title = info['title'] if 'title' in info else ""
self.album = song_info['album'] self.album = info['album'] if 'album' in info else ""
self.artist = song_info['artist'] self.artist = info['artist'] if 'artist' in info else ""
self.trackNumber = int(song_info['track']) if 'track' in song_info else None self.trackNumber = int(info['track']) if 'track' in info else ""
self.contentType = song_info['contentType'] self.contentType = info['contentType'] if 'contentType' in info else ""
self.suffix = song_info['suffix'] self.suffix = info['suffix'] if 'suffix' in info else ""
self.duration = int(song_info['duration']) self.duration = int(info['duration']) if 'duration' in info else ""
self.bitRate = int(song_info['bitRate']) self.bitRate = int(info['bitRate']) if 'bitRate' in info else ""
self.path = song_info['path'] self.path = info['path'] if 'path' in info else ""
self.discNumber = int(song_info['discNumber']) if 'discNumber' in song_info else None self.discNumber = int(info['discNumber']) if 'discNumber' in info else ""
self.albumId = song_info['albumId'] self.albumId = info['albumId'] if 'albumId' in info else ""
self.artistId = song_info['artistId'] if 'artistId' in song_info else None self.artistId = info['artistId'] if 'artistId' in info else ""
self.comment = song_info['comment'] self.comment = info['comment'] if 'comment' in info else ""
self.channelCount = int(song_info['channelCount']) self.channelCount = int(info['channelCount']) if 'channelCount' in info else ""
self.samplingRate = int(song_info['samplingRate']) self.samplingRate = int(info['samplingRate']) if 'samplingRate' in info else ""
self.playCount = int(song_info['playCount']) if 'playCount' in song_info else None self.playCount = int(info['playCount']) if 'playCount' in info else ""
class Artist: class Artist:
id: str id: str
+189 -1
View File
@@ -1 +1,189 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.16.1" type="navidrome" serverVersion="0.54.3 (734eb30a)" openSubsonic="true"><albumList><album id="47e9412a4c73816e0d8411fddf5ac071" parent="5cd6da7549d3b2f7d486e823403179d9" isDir="true" title="%NAME%" name="%NAME%" album="%NAME%" artist="Madoi The Maid" year="2022" coverArt="al-47e9412a4c73816e0d8411fddf5ac071_677f0728" duration="1034" playCount="11" created="2025-01-09T01:44:52.036289708Z" artistId="5cd6da7549d3b2f7d486e823403179d9" songCount="5" isVideo="false" played="2025-01-22T17:30:25.733688541Z" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="46d39a2668849161633175dfb1109ebf" parent="dc7bcc78207dc2cc8476da519fb9be62" isDir="true" title="1000 gecs" name="1000 gecs" album="1000 gecs" artist="100 gecs" year="2019" genre="Bubblegum Bass" coverArt="al-46d39a2668849161633175dfb1109ebf_67869cab" duration="1385" playCount="1" created="2025-01-14T17:51:48.047329609Z" artistId="dc7bcc78207dc2cc8476da519fb9be62" songCount="10" isVideo="false" played="2025-01-15T14:13:39.450407291Z" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="6cddb1f1-d7c4-4932-b080-fe9a0968eb75" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="6413f9f9de4566a42a35820e0330c00e" parent="5cd6da7549d3b2f7d486e823403179d9" isDir="true" title="30355375" name="30355375" album="30355375" artist="Madoi The Maid" year="2021" coverArt="al-6413f9f9de4566a42a35820e0330c00e_677f07ec" duration="1061" created="2025-01-09T01:53:52.055553494Z" artistId="5cd6da7549d3b2f7d486e823403179d9" songCount="4" isVideo="false" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="d6f2e67009217f02d8478bb0b35d0c03" parent="d1fb0b96a0a51a3f73fbf777ca44f6fb" isDir="true" title="[Unknown Album]" name="[Unknown Album]" album="[Unknown Album]" artist="[Unknown Artist]" coverArt="al-d6f2e67009217f02d8478bb0b35d0c03_65afdea5" duration="1090" created="2025-01-09T00:29:52.080283967Z" artistId="d1fb0b96a0a51a3f73fbf777ca44f6fb" songCount="4" isVideo="false" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="0e5b2f2a2e88f81f184d955225e807ce" parent="db88716c9e3f99bee680fa2f09d3a341" isDir="true" title="[Unknown Album]" name="[Unknown Album]" album="[Unknown Album]" artist="Nfract" year="2021" coverArt="al-0e5b2f2a2e88f81f184d955225e807ce_65afe471" duration="1211" created="2025-01-13T16:07:49.056650918Z" artistId="db88716c9e3f99bee680fa2f09d3a341" songCount="4" isVideo="false" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="d8c1f6207254951d1c93735623d6141f" parent="c0dabaa054d44941aedfb1314ad0db0e" isDir="true" title="And Justice For None [Deluxe]" name="And Justice For None [Deluxe]" album="And Justice For None [Deluxe]" artist="Five Finger Death Punch" year="2018" genre="Metal" coverArt="al-d8c1f6207254951d1c93735623d6141f_678fd3d2" duration="3479" playCount="2" created="2025-01-21T17:59:53.055692164Z" artistId="c0dabaa054d44941aedfb1314ad0db0e" songCount="16" isVideo="false" played="2025-01-22T20:35:45.509Z" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="ed00f28740a9c5216c2541cca1c06860" parent="cd596686c16da5c34ebc2e26f5e81e67" isDir="true" title="Another Light" name="Another Light" album="Another Light" artist="Red Vox" year="2017" coverArt="al-ed00f28740a9c5216c2541cca1c06860_677cc436" duration="2937" playCount="5" created="2025-01-07T06:21:03.118167048Z" artistId="cd596686c16da5c34ebc2e26f5e81e67" songCount="13" isVideo="false" played="2025-01-13T18:48:10.232Z" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="b6b8cff3e0911c416e4c2a148998d267" parent="0975b4f6e62c566fea75ee400e45ac7b" isDir="true" title="ap2" name="ap2" album="ap2" artist="goreshit" year="2021" coverArt="al-b6b8cff3e0911c416e4c2a148998d267_677f0b2f" duration="3045" created="2025-01-09T01:57:52.047375693Z" artistId="0975b4f6e62c566fea75ee400e45ac7b" songCount="8" isVideo="false" bpm="0" comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0" samplingRate="0"><replayGain></replayGain></album><album id="2f435628fa8eb04c3a7a1be14f9f1af0" parent="c9c92840fdb77d2e2dab9ae5fbd34d43" isDir="true" title="Army of Mushrooms" name="Army of Mushrooms" album="Army of Mushrooms" artist="Infected Mushroom" year="2012" genre="Psytrance" coverArt="al-2f435628fa8eb04c3a7a1be14f9f1af0_677ccd0f" duration="4796" playCount="3" created="2025-01-07T08:21:03.068117618Z" artistId="c9c92840fdb77d2e2dab9ae5fbd34d43" songCount="12" isVideo="fLine truncated <subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.16.1" type="navidrome"
serverVersion="0.54.3 (734eb30a)" openSubsonic="true">
<albumList>
<album id="47e9412a4c73816e0d8411fddf5ac071" parent="5cd6da7549d3b2f7d486e823403179d9"
isDir="true" title="%NAME%" name="%NAME%" album="%NAME%" artist="Madoi The Maid"
year="2022" coverArt="al-47e9412a4c73816e0d8411fddf5ac071_677f0728" duration="1034"
playCount="11" created="2025-01-09T01:44:52.036289708Z"
artistId="5cd6da7549d3b2f7d486e823403179d9" songCount="5" isVideo="false"
played="2025-01-22T17:30:25.733688541Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="46d39a2668849161633175dfb1109ebf" parent="dc7bcc78207dc2cc8476da519fb9be62"
isDir="true" title="1000 gecs" name="1000 gecs" album="1000 gecs" artist="100 gecs"
year="2019" genre="Bubblegum Bass"
coverArt="al-46d39a2668849161633175dfb1109ebf_67869cab" duration="1385" playCount="1"
created="2025-01-14T17:51:48.047329609Z" artistId="dc7bcc78207dc2cc8476da519fb9be62"
songCount="10" isVideo="false" played="2025-01-15T14:13:39.450407291Z" bpm="0"
comment="" sortName="" mediaType="album"
musicBrainzId="6cddb1f1-d7c4-4932-b080-fe9a0968eb75" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="6413f9f9de4566a42a35820e0330c00e" parent="5cd6da7549d3b2f7d486e823403179d9"
isDir="true" title="30355375" name="30355375" album="30355375" artist="Madoi The Maid"
year="2021" coverArt="al-6413f9f9de4566a42a35820e0330c00e_677f07ec" duration="1061"
created="2025-01-09T01:53:52.055553494Z" artistId="5cd6da7549d3b2f7d486e823403179d9"
songCount="4" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="d6f2e67009217f02d8478bb0b35d0c03" parent="d1fb0b96a0a51a3f73fbf777ca44f6fb"
isDir="true" title="[Unknown Album]" name="[Unknown Album]" album="[Unknown Album]"
artist="[Unknown Artist]" coverArt="al-d6f2e67009217f02d8478bb0b35d0c03_65afdea5"
duration="1090" created="2025-01-09T00:29:52.080283967Z"
artistId="d1fb0b96a0a51a3f73fbf777ca44f6fb" songCount="4" isVideo="false" bpm="0"
comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0"
samplingRate="0">
<replayGain></replayGain>
</album>
<album id="0e5b2f2a2e88f81f184d955225e807ce" parent="db88716c9e3f99bee680fa2f09d3a341"
isDir="true" title="[Unknown Album]" name="[Unknown Album]" album="[Unknown Album]"
artist="Nfract" year="2021" coverArt="al-0e5b2f2a2e88f81f184d955225e807ce_65afe471"
duration="1211" created="2025-01-13T16:07:49.056650918Z"
artistId="db88716c9e3f99bee680fa2f09d3a341" songCount="4" isVideo="false" bpm="0"
comment="" sortName="" mediaType="album" musicBrainzId="" channelCount="0"
samplingRate="0">
<replayGain></replayGain>
</album>
<album id="d8c1f6207254951d1c93735623d6141f" parent="c0dabaa054d44941aedfb1314ad0db0e"
isDir="true" title="And Justice For None [Deluxe]" name="And Justice For None [Deluxe]"
album="And Justice For None [Deluxe]" artist="Five Finger Death Punch" year="2018"
genre="Metal" coverArt="al-d8c1f6207254951d1c93735623d6141f_678fd3d2" duration="3479"
playCount="2" created="2025-01-21T17:59:53.055692164Z"
artistId="c0dabaa054d44941aedfb1314ad0db0e" songCount="16" isVideo="false"
played="2025-01-22T20:35:45.509Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="ed00f28740a9c5216c2541cca1c06860" parent="cd596686c16da5c34ebc2e26f5e81e67"
isDir="true" title="Another Light" name="Another Light" album="Another Light"
artist="Red Vox" year="2017" coverArt="al-ed00f28740a9c5216c2541cca1c06860_677cc436"
duration="2937" playCount="5" created="2025-01-07T06:21:03.118167048Z"
artistId="cd596686c16da5c34ebc2e26f5e81e67" songCount="13" isVideo="false"
played="2025-01-13T18:48:10.232Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="b6b8cff3e0911c416e4c2a148998d267" parent="0975b4f6e62c566fea75ee400e45ac7b"
isDir="true" title="ap2" name="ap2" album="ap2" artist="goreshit" year="2021"
coverArt="al-b6b8cff3e0911c416e4c2a148998d267_677f0b2f" duration="3045"
created="2025-01-09T01:57:52.047375693Z" artistId="0975b4f6e62c566fea75ee400e45ac7b"
songCount="8" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="2f435628fa8eb04c3a7a1be14f9f1af0" parent="c9c92840fdb77d2e2dab9ae5fbd34d43"
isDir="true" title="Army of Mushrooms" name="Army of Mushrooms"
album="Army of Mushrooms" artist="Infected Mushroom" year="2012" genre="Psytrance"
coverArt="al-2f435628fa8eb04c3a7a1be14f9f1af0_677ccd0f" duration="4796" playCount="3"
created="2025-01-07T08:21:03.068117618Z" artistId="c9c92840fdb77d2e2dab9ae5fbd34d43"
songCount="12" isVideo="false" played="2025-01-22T20:39:34.814Z" bpm="0" comment=""
sortName="" mediaType="album" musicBrainzId="47b6f635-d38b-434c-8cef-81e936d85920"
channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="0862b448d1af4f40602dea9d0e37894c" parent="1bd222373c64674d749b318511a64bfd"
isDir="true" title="Atlanta Millionaires Club" name="Atlanta Millionaires Club"
album="Atlanta Millionaires Club" artist="Faye Webster" year="2019" genre="Alternative"
coverArt="al-0862b448d1af4f40602dea9d0e37894c_677f5a52" duration="1909"
created="2025-01-09T06:04:52.190240048Z" artistId="1bd222373c64674d749b318511a64bfd"
songCount="10" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="1d2749574810ce63fa1c47b57e8e3e73" parent="0371f111b9d8391a4b669a4199809186"
isDir="true" title="Automated Refrains" name="Automated Refrains"
album="Automated Refrains" artist="Dan Terminus" year="2017" genre="Electronic"
coverArt="al-1d2749574810ce63fa1c47b57e8e3e73_678fdf31" duration="1317"
created="2025-01-21T17:53:53.046342896Z" artistId="0371f111b9d8391a4b669a4199809186"
songCount="4" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="1574db21-9e3c-4429-a64e-a46adb842931" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="06e75c5a2dadb55a9071f52196da3846" parent="e3a642b6f67ac1f4683882ad9118312d"
isDir="true" title="Back To Earth" name="Back To Earth" album="Back To Earth"
artist="Golemm" year="2023" coverArt="al-06e75c5a2dadb55a9071f52196da3846_677cc2f8"
duration="165" playCount="1" created="2025-01-07T06:20:03.048260207Z"
artistId="e3a642b6f67ac1f4683882ad9118312d" songCount="1" isVideo="false"
played="2025-01-09T17:27:34.978Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="48976a6cf6f6cac0a29772a4dce103fe" parent="955a5787540a074d8732ad9962aefaca"
isDir="true" title="Basement Popstar" name="Basement Popstar" album="Basement Popstar"
artist="GNB CHILI" year="2021" coverArt="al-48976a6cf6f6cac0a29772a4dce103fe_677c7fc9"
duration="4197" playCount="6" created="2025-01-07T01:36:13.02318597Z"
artistId="955a5787540a074d8732ad9962aefaca" songCount="26" isVideo="false"
played="2025-01-21T22:56:16.312531561Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="98e13ac9e58288efbd93a261225d1a5b" parent="db88716c9e3f99bee680fa2f09d3a341"
isDir="true" title="Bleeding Reflection" name="Bleeding Reflection"
album="Bleeding Reflection" artist="Nfract" year="2020"
coverArt="al-98e13ac9e58288efbd93a261225d1a5b_678675e6" duration="412"
created="2025-01-13T16:07:49.08422529Z" artistId="db88716c9e3f99bee680fa2f09d3a341"
songCount="1" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="85c79ce0-dbb8-4554-97a1-511798aa1f64" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="a880dcf07c4c886175cec0ffb4968ed6" parent="0f51c7454c088cab6c7c965bbea9791d"
isDir="true" title="blight" name="blight" album="blight" artist="purity://filter"
year="2021" coverArt="al-a880dcf07c4c886175cec0ffb4968ed6_677f0a65" duration="836"
playCount="2" created="2025-01-09T01:48:52.04606921Z"
artistId="0f51c7454c088cab6c7c965bbea9791d" songCount="6" isVideo="false"
played="2025-01-15T22:54:40.187Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="3d60ef6028532c45fd59554fe861397a" parent="0975b4f6e62c566fea75ee400e45ac7b"
isDir="true" title="blue girl on sunday" name="blue girl on sunday"
album="blue girl on sunday" artist="goreshit" year="2011"
coverArt="al-3d60ef6028532c45fd59554fe861397a_677f16f7" duration="2471"
created="2025-01-09T01:57:52.069784029Z" artistId="0975b4f6e62c566fea75ee400e45ac7b"
songCount="7" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="78f9621af89b8184278ef7821c6cff89" parent="b56870783b82e1413af57d4cbde24f31"
isDir="true" title="BRAT" name="BRAT" album="BRAT" artist="Charli xcx" year="2024"
genre="Club" coverArt="al-78f9621af89b8184278ef7821c6cff89_6786fdf5"
starred="2025-01-15T21:37:49.500009424Z" duration="2490" playCount="7"
created="2025-01-14T17:55:48.042982684Z" artistId="b56870783b82e1413af57d4cbde24f31"
songCount="15" isVideo="false" played="2025-01-22T17:23:55.631096876Z" bpm="0"
comment="" sortName="" mediaType="album"
musicBrainzId="97b69f53-5b37-4b94-856b-8fa32063310a" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="622532ca446558d45ce006e4264abf69" parent="ab255ac1a3606a016e598f4f6674e51a"
isDir="true" title="Changes" name="Changes" album="Changes"
artist="King Gizzard &amp; the Lizard Wizard" year="2022" genre="Psychedelic Rock"
coverArt="al-622532ca446558d45ce006e4264abf69_677c73b3"
starred="2025-01-07T20:15:02.583375374Z" duration="2403" playCount="3"
created="2025-01-07T00:41:13.214313142Z" artistId="ab255ac1a3606a016e598f4f6674e51a"
songCount="7" isVideo="false" played="2025-01-16T18:55:56.099535351Z" bpm="0" comment=""
sortName="" mediaType="album" musicBrainzId="3fe553cd-5e38-4b55-8052-656821f6d113"
channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="d7f4db94acce29a5811d80cc1394f005" parent="7decc729670767718e65266f1def027f"
isDir="true" title="chaotic solutions" name="chaotic solutions"
album="chaotic solutions" artist="Kobaryo" year="2014"
coverArt="al-d7f4db94acce29a5811d80cc1394f005_678fd9c3" duration="2849"
created="2025-01-21T18:11:53.264694258Z" artistId="7decc729670767718e65266f1def027f"
songCount="14" isVideo="false" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="64adb258-9c2e-4746-b994-3506d7b6840e" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
<album id="9c451436790418adbe4053e8acc4be1f" parent="545d81e9329d136f3f25bc1e367fadd7"
isDir="true" title="CHASER" name="CHASER" album="CHASER" artist="Femtanyl" year="2023"
genre="Breakcore" coverArt="al-9c451436790418adbe4053e8acc4be1f_677c80d7" duration="824"
playCount="3" created="2025-01-07T01:40:13.185825129Z"
artistId="545d81e9329d136f3f25bc1e367fadd7" songCount="6" isVideo="false"
played="2025-01-19T23:04:45.888978139Z" bpm="0" comment="" sortName="" mediaType="album"
musicBrainzId="" channelCount="0" samplingRate="0">
<replayGain></replayGain>
</album>
</albumList>
</subsonic-response>
+72 -31
View File
@@ -16,10 +16,14 @@ import SubSonic
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame import pygame
from rich.table import Table
from textual import on, events, work from textual import on, events, work
from textual.reactive import reactive
from textual.app import App, ComposeResult, RenderResult from textual.app import App, ComposeResult, RenderResult
from textual.widgets import Footer, Header, OptionList, DataTable, ProgressBar, Label from textual.widgets import Footer, Header, OptionList, DataTable, ProgressBar, Label
from textual.containers import Horizontal, Vertical, Container from textual.widget import Widget
from textual.containers import Horizontal, Vertical, Container, VerticalScroll
from textual.screen import Screen from textual.screen import Screen
from textual.widgets.option_list import Option from textual.widgets.option_list import Option
from textual.timer import Timer from textual.timer import Timer
@@ -310,6 +314,43 @@ class CoverArtPixels(Container):
image = Image.open(io.BytesIO(conn.getCoverArtRaw(self.cover_art_id))) image = Image.open(io.BytesIO(conn.getCoverArtRaw(self.cover_art_id)))
return Pixels().from_image(image, resize=(width, height)) return Pixels().from_image(image, resize=(width, height))
class QueueTable(Widget):
def render(self) -> RenderResult:
table = Table()
table.add_column("Title")
table.add_column("Album")
table.add_column("Artist")
table.add_column("Plays")
table.add_column("Duration")
table.add_column("Bitrate")
queue: list[SubSonic.Song] = app.user_queue
queue.extend(app.song_queue)
for song in queue:
table.add_row(song.title, song.album, song.artist, str(song.playCount), str(song.duration), str(song.bitRate))
return table
class PlayingInfo(Widget):
def render(self) -> RenderResult:
table = Table()
table.add_column("")
table.add_column("")
if app.currently_playing:
song = app.currently_playing
table.add_row("Title", song.title)
table.add_row("Artist", song.artist)
table.add_row("Album", song.album)
table.add_row("Plays", str(song.playCount) if song.playCount else "0")
table.add_row("Duration", str(song.duration))
table.add_row("Track Number", str(song.trackNumber))
table.add_row("Bit Rate", str(song.bitRate))
class MainView(Screen): class MainView(Screen):
CSS_PATH = 'main.tcss' CSS_PATH = 'main.tcss'
@@ -318,50 +359,50 @@ class MainView(Screen):
with Horizontal(): with Horizontal():
with Vertical(classes="info", id='info'): with Vertical(classes="info", id='info'):
yield Label("Playing") yield Label("Playing")
yield DataTable(id="currently_playing") yield PlayingInfo()
yield ProgressBar() yield ProgressBar()
yield CoverArtPixels() yield CoverArtPixels()
with Vertical(classes="column"): # with Vertical(classes="column"):
yield Label("Queue") # yield Label("Queue")
yield DataTable(id="queue") yield VerticalScroll(QueueTable())
yield Footer() yield Footer()
def on_mount(self) -> None: def on_mount(self) -> None:
app.sub_title = "Overview" app.sub_title = "Overview"
queueTable: DataTable = self.query_one("#queue") # queueTable: DataTable = self.query_one("#queue")
queueTable.cursor_type = "row" # queueTable.cursor_type = "row"
queueTable.add_columns("Title", "Album", "Artist", "Plays", "Duration", "Bitrate") # queueTable.add_columns("Title", "Album", "Artist", "Plays", "Duration", "Bitrate")
currentlyPlaying: DataTable = self.query_one('#currently_playing') # currentlyPlaying: DataTable = self.query_one('#currently_playing')
currentlyPlaying.cursor_type = "row" # currentlyPlaying.cursor_type = "row"
currentlyPlaying.add_columns("", "") # currentlyPlaying.add_columns("", "")
@on(events.ScreenResume) @on(events.ScreenResume)
def screen_resumed(self, event: events.ScreenResume) -> None: def screen_resumed(self, event: events.ScreenResume) -> None:
app.sub_title = "Overview" app.sub_title = "Overview"
# Update Queue Table # Update Queue Table
queueTable: DataTable = self.query_one('#queue') # queueTable: DataTable = self.query_one('#queue')
self._clear_table('#queue') # self._clear_table('#queue')
queue: list[SubSonic.Song] = [] # queue: list[SubSonic.Song] = []
queue.extend(app.user_queue) # queue.extend(app.user_queue)
queue.extend(app.song_queue) # queue.extend(app.song_queue)
for song in queue: # for song in queue:
queueTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate) # queueTable.add_row(song.title, song.album, song.artist, song.playCount, song.duration, song.bitRate)
# Update Currently Playing Table # Update Currently Playing Table
self._clear_table('#currently_playing') # self._clear_table('#currently_playing')
if app.currently_playing: if app.currently_playing:
song = app.currently_playing # song = app.currently_playing
currentlyPlaying: DataTable = self.query_one('#currently_playing') # currentlyPlaying: DataTable = self.query_one('#currently_playing')
currentlyPlaying.add_row("Title", song.title) # currentlyPlaying.add_row("Title", song.title)
currentlyPlaying.add_row("Artist", song.artist) # currentlyPlaying.add_row("Artist", song.artist)
currentlyPlaying.add_row("Album", song.album) # currentlyPlaying.add_row("Album", song.album)
currentlyPlaying.add_row("Plays", song.playCount if song.playCount else 0) # currentlyPlaying.add_row("Plays", song.playCount if song.playCount else 0)
currentlyPlaying.add_row("Duration", song.duration) # currentlyPlaying.add_row("Duration", song.duration)
currentlyPlaying.add_row("Track Number", song.trackNumber) # currentlyPlaying.add_row("Track Number", song.trackNumber)
currentlyPlaying.add_row("Bit Rate", song.bitRate) # currentlyPlaying.add_row("Bit Rate", song.bitRate)
self.query_one(CoverArtPixels).set_cover_art(app.currently_playing.id) self.query_one(CoverArtPixels).set_cover_art(app.currently_playing.id)
@@ -396,9 +437,9 @@ class TextualSubpyPlayer(App):
"playlists" : Playlists "playlists" : Playlists
} }
currently_playing: SubSonic.Song | None = None currently_playing: SubSonic.Song | None = reactive(SubSonic.Song())
song_queue: list[SubSonic.Song] = [] song_queue: list[SubSonic.Song] = reactive([])
user_queue: list[SubSonic.Song] = [] user_queue: list[SubSonic.Song] = reactive([])
play_history: list[SubSonic.Song] = [] play_history: list[SubSonic.Song] = []
is_paused: bool = False is_paused: bool = False
place: int = 0 place: int = 0
+1 -12
View File
@@ -1,12 +1 @@
[2025-01-24 21:34:24,903] DEBUG in selector_events: Using selector: EpollSelector [2025-01-29 17:02:16,865] DEBUG in selector_events: Using selector: EpollSelector
[2025-01-24 21:34:26,609] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-24 21:34:26,646] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getPlaylists?u=pseudo&t=117b12afec7228071d8e5423a81373a8&s=K6WPAIKV&v=1.16.1&c=testing&f=json HTTP/1.1" 200 705
[2025-01-24 21:34:28,309] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-24 21:34:28,345] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getPlaylist?u=pseudo&t=93ebc246f6838084d07ac50c4bf787be&s=Z3D6WNNK&v=1.16.1&c=testing&f=json&id=9d76a86b-901f-4727-a2ec-01210157ff01 HTTP/1.1" 200 None
[2025-01-24 21:34:30,632] DEBUG in screens-test: Playing song Midian by Yakui the Maid.
[2025-01-24 21:34:30,633] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-24 21:34:30,662] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/stream?u=pseudo&t=d515d35181a76782a65a285398a605ea&s=WT0U93U8&v=1.16.1&c=testing&id=a57e00930bb5a1b50dcaf7c573f4ba66 HTTP/1.1" 200 20522391
[2025-01-24 21:34:31,867] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-24 21:34:31,899] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getCoverArt?u=pseudo&t=74f61a986314858ae80b67755cbb79cf&s=28V8171Q&v=1.16.1&c=testing&id=a57e00930bb5a1b50dcaf7c573f4ba66 HTTP/1.1" 200 None
[2025-01-24 21:34:37,182] DEBUG in connectionpool: Starting new HTTPS connection (1): music.0x01fe.net:443
[2025-01-24 21:34:37,216] DEBUG in connectionpool: https://music.0x01fe.net:443 "GET /rest/getCoverArt?u=pseudo&t=d113293159ba7ab8bddc4749fe099c7c&s=8EL8LGE3&v=1.16.1&c=testing&id=a57e00930bb5a1b50dcaf7c573f4ba66 HTTP/1.1" 200 None