Merge pull request #104 from Aethar01/master

Fixes for auto enum increment and except clause outside a try block.
This commit is contained in:
Benexl
2025-07-26 13:04:28 +03:00
committed by GitHub
2 changed files with 62 additions and 56 deletions

View File

@@ -31,59 +31,65 @@ 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 profile.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}",
profile.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(profile.user_profile, "about", "") or "No description available"
)
console.print(
Panel(
Markdown(about_text),
title=f"📊 {profile.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))
raise click.Abort()
except Exception as e:
feedback.error("Unexpected error occurred", str(e))
raise click.Abort()

View File

@@ -12,19 +12,19 @@ from ...libs.provider.anime.types import Anime, SearchResults, Server
class InternalDirective(Enum):
MAIN = "MAIN"
BACK = auto()
BACK = "BACK"
BACK_FORCE = auto()
BACK_FORCE = "BACK_FORCE"
BACKX2 = auto()
BACKX2 = "BACKX2"
BACKX3 = auto()
BACKX3 = "BACKX3"
EXIT = auto()
EXIT = "EXIT"
CONFIG_EDIT = auto()
CONFIG_EDIT = "CONFIG_EDIT"
RELOAD = auto()
RELOAD = "RELOAD"
class MenuName(Enum):