stats fix

This commit is contained in:
Aethar
2025-07-26 17:37:43 +09:00
parent 3ea37c4079
commit 89ff453778

View File

@@ -32,60 +32,61 @@ def stats(config: "AppConfig"):
media_api_client = create_api_client(config.general.media_api, config)
# Check authentication
try:
# Check authentication
if profile := auth.get_auth():
if not media_api_client.authenticate(profile.token):
feedback.error(
"Authentication Required",
f"You must be logged in to {config.general.media_api} to sync your media list.",
)
feedback.info("Run this command to authenticate:", f"fastanime {config.general.media_api} auth")
raise click.Abort()
# Check if kitten is available for image display
KITTEN_EXECUTABLE = shutil.which("kitten")
if not KITTEN_EXECUTABLE:
feedback.warning("Kitten not found - profile image will not be displayed")
else:
# Display profile image using kitten icat
if user_profile.avatar_url:
console.clear()
image_x = int(console.size.width * 0.1)
image_y = int(console.size.height * 0.1)
img_w = console.size.width // 3
img_h = console.size.height // 3
image_process = subprocess.run(
[
KITTEN_EXECUTABLE,
"icat",
"--clear",
"--place",
f"{img_w}x{img_h}@{image_x}x{image_y}",
user_profile.avatar_url,
],
check=False,
if profile := auth.get_auth():
if not media_api_client.authenticate(profile.token):
feedback.error(
"Authentication Required",
f"You must be logged in to {config.general.media_api} to sync your media list.",
)
feedback.info("Run this command to authenticate:", f"fastanime {config.general.media_api} auth")
raise click.Abort()
if image_process.returncode != 0:
feedback.warning("Failed to display profile image")
# Display user information
about_text = getattr(user_profile, "about", "") or "No description available"
console.print(
Panel(
Markdown(about_text),
title=f"📊 {user_profile.name}'s Profile",
# Check if kitten is available for image display
KITTEN_EXECUTABLE = shutil.which("kitten")
if not KITTEN_EXECUTABLE:
feedback.warning("Kitten not found - profile image will not be displayed")
else:
# Display profile image using kitten icat
if profile.avatar_url:
console.clear()
image_x = int(console.size.width * 0.1)
image_y = int(console.size.height * 0.1)
img_w = console.size.width // 3
img_h = console.size.height // 3
image_process = subprocess.run(
[
KITTEN_EXECUTABLE,
"icat",
"--clear",
"--place",
f"{img_w}x{img_h}@{image_x}x{image_y}",
profile.avatar_url,
],
check=False,
)
if image_process.returncode != 0:
feedback.warning("Failed to display profile image")
# Display user information
about_text = getattr(profile, "about", "") or "No description available"
console.print(
Panel(
Markdown(about_text),
title=f"📊 {profile.name}'s Profile",
)
)
)
# You can add more stats here if the API provides them
feedback.success("User profile displayed successfully")
# You can add more stats here if the API provides them
feedback.success("User profile displayed successfully")
except FastAnimeError as e:
feedback.error("Failed to fetch user stats", str(e))