Skip to content

Commit ab3db08

Browse files
committed
feat: sort libraries alphabetically in dashboard and update_libraries command
1 parent cc28772 commit ab3db08

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cogs/jellyfin_core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,14 @@ async def create_dashboard_embed(self, info: Dict[str, Any]) -> discord.Embed:
664664
# Add library statistics
665665
library_stats = info.get('library_stats', {})
666666
if library_stats:
667+
# Sort libraries by display_name
668+
sorted_libraries = sorted(
669+
library_stats.items(),
670+
key=lambda x: x[1].get('display_name', '').lower()
671+
)
672+
667673
stats_text = ""
668-
for library_id, stats in library_stats.items():
674+
for library_id, stats in sorted_libraries:
669675
if stats.get('count', 0) > 0: # Only show libraries with items
670676
stats_text += f"{stats.get('emoji', '📁')} **{stats.get('display_name', 'Unknown Library')}**\n"
671677
stats_text += f"```css\nTotal Items: {stats.get('count', 0)}\n```\n"
@@ -740,6 +746,9 @@ async def update_libraries(self, interaction: discord.Interaction):
740746

741747
libraries = response.json()
742748

749+
# Sort libraries by name
750+
libraries = sorted(libraries, key=lambda x: x.get("Name", "").lower())
751+
743752
# Update config with new libraries
744753
self.config["jellyfin_sections"]["sections"] = {}
745754

0 commit comments

Comments
 (0)