Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions audiotagloader/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

from .cache import cache

import questionary

custom_style = questionary.Style(
[
("selected", "#ffffff bg:#0066cc"),
("highlighted", "#ffffff bg:#0066cc"),
("pointer", "#ff0000 bold"),
]
)


class App:
def __init__(self, target_dir: Path):
Expand Down Expand Up @@ -134,21 +144,38 @@ def get_track_tags_by_artist(
) -> tuple[Album, Image, Tracklist]:
artists = self._get_artists_by_name(artist_name)

for i in range(len(artists)):
print(f"[{i}] {artists[i].name}")
choices = []
for i, artist in enumerate(artists):
choices.append(
questionary.Choice(title=f"[{i:02d}] {artist.name}", value=artist)
)

current_artist = artists[
max(0, min(MAX_PROPOSED_LEN - 1, int(input("select artist: "))))
]
current_artist = questionary.select(
"Select artist:",
style=custom_style,
choices=choices,
).ask()

albums = self._get_albums_by_artist(current_artist)

for i in range(len(albums)):
print(f"[{i:02d}] {albums[i].year} - {albums[i].title} {albums[i].id}")
max_title_len = min(max(max(len(a.title) for a in albums), 40), 40)

choices = []
for i, album in enumerate(albums):
title = album.title
if len(title) > 40:
title = title[:37] + "..."
title_str = (
f"[{i:02d}] {album.year:04d} - {title:<{max_title_len}} - {album.id}"
)

choices.append(questionary.Choice(title=title_str, value=album))

current_album = albums[
max(0, min(len(albums) - 1, int(input("select album: "))))
]
current_album = questionary.select(
"Select album:",
style=custom_style,
choices=choices,
).ask()

image = self._get_cover_image(current_album.id)
tracks = self._get_tracklist(current_album.id)
Expand Down
44 changes: 43 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies = [
"pydantic (>=2.12.5,<3.0.0)",
"redis (>=7.2.0,<8.0.0)",
"typer (>=0.24.1,<0.25.0)",
"questionary (>=2.1.1,<3.0.0)",
]

[tool.poetry]
Expand Down