removing the artist bio and adding artist paging

This commit is contained in:
JISAUAY committed 2025-09-17 14:25:11 -05:00
1 parent 3a07071284
commit b1a6285ce6
2 files changed
+59 -24

No files matched your search

+54 -24
View File
@@ -2,6 +2,7 @@ import configparser
import logging import logging
import asyncio import asyncio
import random import random
import math
import os import os
import re import re
import io import io
@@ -152,22 +153,6 @@ class ArtistAlbums(Screen):
app.pop_screen() app.pop_screen()
app.uninstall_screen("artistAlbums") app.uninstall_screen("artistAlbums")
class ArtistInfoPanel(Widget):
artist: SubSonic.Artist
def compose(self) -> ComposeResult:
with Horizontal():
yield ArtistArt(classes="artistInfoArt")
yield Placeholder(classes="artistInfoTextbox")
yield Rule()
def set_artist(self, artist: SubSonic.Artist) -> None:
self.artist = artist
artist_art = self.query_one(ArtistArt)
artist_art.get_artist_image(self.artist.id)
class AlbumPanel(Widget, can_focus=True, can_focus_children=True): class AlbumPanel(Widget, can_focus=True, can_focus_children=True):
album: SubSonic.Album album: SubSonic.Album
@@ -204,7 +189,8 @@ class ArtistAlbums2(Screen):
yield Label(Text("F3 ", style="bold orange").append_text(Text("Albums", style="white")), classes="headerb") yield Label(Text("F3 ", style="bold orange").append_text(Text("Albums", style="white")), classes="headerb")
yield Label(Text("F4 ", style="bold orange").append_text(Text("Favourites", style="white")), classes="headerb") yield Label(Text("F4 ", style="bold orange").append_text(Text("Favourites", style="white")), classes="headerb")
yield Label(Text("F5 ", style="bold orange").append_text(Text("Playlists", style="white")), classes="headerb") yield Label(Text("F5 ", style="bold orange").append_text(Text("Playlists", style="white")), classes="headerb")
yield ArtistInfoPanel(classes="artistInfo") yield Label(classes='artistNameHeader')
yield Rule()
with Horizontal(): with Horizontal():
yield AlbumPanel(classes="albumPanel") yield AlbumPanel(classes="albumPanel")
yield AlbumPanel(classes="albumPanel") yield AlbumPanel(classes="albumPanel")
@@ -220,8 +206,8 @@ class ArtistAlbums2(Screen):
def on_mount(self) -> None: def on_mount(self) -> None:
self.albums = conn.getArtistAlbums(self.artist.id) self.albums = conn.getArtistAlbums(self.artist.id)
artist_info_panel = self.query_one(ArtistInfoPanel) artist_header = self.query_one(Label)
artist_info_panel.set_artist(self.artist) artist_header.update(self.artist.name)
albums_displayed = 0 albums_displayed = 0
album_panels = self.query(AlbumPanel) album_panels = self.query(AlbumPanel)
@@ -292,7 +278,6 @@ class ArtistArt(Static):
def render(self) -> RenderResult: def render(self) -> RenderResult:
if self.art: if self.art:
width, height = self.size width, height = self.size
logging.debug(f'{width=}, {height=}')
height *= 2 height *= 2
@@ -301,7 +286,10 @@ class ArtistArt(Static):
elif height > width: elif height > width:
height = width height = width
return Pixels.from_image(self.art, resize=(width, height)) try:
return Pixels.from_image(self.art, resize=(width, height))
except Exception as e:
logging.error(f'Couldn\'t load image {e}')
return '' return ''
@@ -357,7 +345,14 @@ class ArtistPanel(Widget, can_focus=True, can_focus_children=True):
class Artists2(Screen): class Artists2(Screen):
BINDINGS = [
Binding('d', "page_forward()", "Next Page"),
Binding('a', "page_backward()", "Prev. Page")
]
artists: list[SubSonic.Artist] artists: list[SubSonic.Artist]
artists_displayed: int = 0
page: int = 1
def compose(self) -> ComposeResult: def compose(self) -> ComposeResult:
yield Header(icon='') yield Header(icon='')
@@ -385,17 +380,52 @@ class Artists2(Screen):
yield ArtistPanel(classes="artistPanel") yield ArtistPanel(classes="artistPanel")
yield ArtistPanel(classes="artistPanel") yield ArtistPanel(classes="artistPanel")
yield ArtistPanel(classes="artistPanel") yield ArtistPanel(classes="artistPanel")
yield Label(id="page-counter")
yield Footer() yield Footer()
def on_mount(self) -> None: def on_mount(self) -> None:
app.sub_title = 'Artists2' app.sub_title = 'Artists2'
self.artists = conn.getArtists() self.artists = conn.getArtists()
artists_displayed = 0 self.artists_displayed = 0
self.update_pager()
artist_panels = self.query(ArtistPanel) artist_panels = self.query(ArtistPanel)
for artist_panel in artist_panels: for artist_panel in artist_panels:
artist_panel.set_artist(self.artists[artists_displayed]) if self.artists_displayed >= len(self.artists) - 1:
artists_displayed += 1 return
artist_panel.set_artist(self.artists[self.artists_displayed])
self.artists_displayed += 1
def update_pager(self) -> None:
pager = self.query_one("#page-counter", Label)
pager.update(f"{self.page} ... {math.ceil(len(self.artists)/15)}")
def action_page_forward(self) -> None:
artist_panels = self.query(ArtistPanel)
self.page += 1
self.update_pager()
for artist_panel in artist_panels:
if self.artists_displayed >= len(self.artists) - 1:
return
artist_panel.set_artist(self.artists[self.artists_displayed])
self.artists_displayed += 1
def action_page_backward(self) -> None:
artist_panels = self.query(ArtistPanel)
self.page -= 1
self.update_pager()
self.artists_displayed -= 30
for artist_panel in artist_panels:
artist_panel.set_artist(self.artists[self.artists_displayed])
self.artists_displayed += 1
class Albums(Screen): class Albums(Screen):
+5
View File
@@ -82,3 +82,8 @@
text-align: center; text-align: center;
width: 100%; width: 100%;
} }
.artistNameHeader {
width: 100%;
text-align: center;
}