mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-06 17:53:40 -08:00
stats fix
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user