fix(update-command): use viu-media when updating

This commit is contained in:
Benexl
2025-08-18 01:28:59 +03:00
parent c8a42c4920
commit 249a207cad
7 changed files with 51 additions and 46 deletions

View File

@@ -6,7 +6,7 @@ import click
from click.core import ParameterSource from click.core import ParameterSource
from ..core.config import AppConfig from ..core.config import AppConfig
from ..core.constants import PROJECT_NAME, USER_CONFIG, __version__ from ..core.constants import CLI_NAME, USER_CONFIG, __version__
from .config import ConfigLoader from .config import ConfigLoader
from .options import options_from_model from .options import options_from_model
from .utils.exception import setup_exceptions_handler from .utils.exception import setup_exceptions_handler
@@ -47,7 +47,7 @@ commands = {
root="viu_media.cli.commands", root="viu_media.cli.commands",
invoke_without_command=True, invoke_without_command=True,
lazy_subcommands=commands, lazy_subcommands=commands,
context_settings=dict(auto_envvar_prefix=PROJECT_NAME), context_settings=dict(auto_envvar_prefix=CLI_NAME),
) )
@click.version_option(__version__, "--version") @click.version_option(__version__, "--version")
@click.option("--no-config", is_flag=True, help="Don't load the user config file.") @click.option("--no-config", is_flag=True, help="Don't load the user config file.")

View File

@@ -123,9 +123,9 @@ def _generate_desktop_entry():
from rich.prompt import Confirm from rich.prompt import Confirm
from ...core.constants import ( from ...core.constants import (
CLI_NAME,
ICON_PATH, ICON_PATH,
PLATFORM, PLATFORM,
PROJECT_NAME,
USER_APPLICATIONS, USER_APPLICATIONS,
__version__, __version__,
) )
@@ -149,7 +149,7 @@ def _generate_desktop_entry():
desktop_entry = dedent( desktop_entry = dedent(
f""" f"""
[Desktop Entry] [Desktop Entry]
Name={PROJECT_NAME.title()} Name={CLI_NAME.title()}
Type=Application Type=Application
version={__version__} version={__version__}
Path={Path().home()} Path={Path().home()}
@@ -160,7 +160,7 @@ def _generate_desktop_entry():
Categories=Entertainment Categories=Entertainment
""" """
) )
desktop_entry_path = USER_APPLICATIONS / f"{PROJECT_NAME}.desktop" desktop_entry_path = USER_APPLICATIONS / f"{CLI_NAME}.desktop"
if desktop_entry_path.exists(): if desktop_entry_path.exists():
if not Confirm.ask( if not Confirm.ask(
f"The file already exists {desktop_entry_path}; or would you like to rewrite it", f"The file already exists {desktop_entry_path}; or would you like to rewrite it",

View File

@@ -8,7 +8,7 @@ from pydantic.fields import ComputedFieldInfo, FieldInfo
from pydantic_core import PydanticUndefined from pydantic_core import PydanticUndefined
from ...core.config import AppConfig from ...core.config import AppConfig
from ...core.constants import APP_ASCII_ART, DISCORD_INVITE, PROJECT_NAME, REPO_HOME from ...core.constants import APP_ASCII_ART, CLI_NAME, DISCORD_INVITE, REPO_HOME
# The header for the config file. # The header for the config file.
config_asci = "\n".join( config_asci = "\n".join(
@@ -28,7 +28,7 @@ CONFIG_HEADER = f"""
CONFIG_FOOTER = f""" CONFIG_FOOTER = f"""
# ============================================================================== # ==============================================================================
# #
# HOPE YOU ENJOY {PROJECT_NAME} AND BE SURE TO STAR THE PROJECT ON GITHUB # HOPE YOU ENJOY {CLI_NAME} AND BE SURE TO STAR THE PROJECT ON GITHUB
# {REPO_HOME} # {REPO_HOME}
# #
# Also join the discord server # Also join the discord server

View File

@@ -34,12 +34,12 @@ class FeedbackService:
try: try:
from plyer import notification from plyer import notification
from ....core.constants import ICON_PATH, PROJECT_NAME from ....core.constants import CLI_NAME, ICON_PATH
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=message, message=message,
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=self.app_config.general.desktop_notification_duration * 60, timeout=self.app_config.general.desktop_notification_duration * 60,
) )
@@ -60,12 +60,12 @@ class FeedbackService:
try: try:
from plyer import notification from plyer import notification
from ....core.constants import ICON_PATH, PROJECT_NAME from ....core.constants import CLI_NAME, ICON_PATH
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=message, message=message,
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=self.app_config.general.desktop_notification_duration * 60, timeout=self.app_config.general.desktop_notification_duration * 60,
) )
@@ -87,12 +87,12 @@ class FeedbackService:
try: try:
from plyer import notification from plyer import notification
from ....core.constants import ICON_PATH, PROJECT_NAME from ....core.constants import CLI_NAME, ICON_PATH
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=message, message=message,
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=self.app_config.general.desktop_notification_duration * 60, timeout=self.app_config.general.desktop_notification_duration * 60,
) )
@@ -113,12 +113,12 @@ class FeedbackService:
try: try:
from plyer import notification from plyer import notification
from ....core.constants import ICON_PATH, PROJECT_NAME from ....core.constants import CLI_NAME, ICON_PATH
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=message, message=message,
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=self.app_config.general.desktop_notification_duration * 60, timeout=self.app_config.general.desktop_notification_duration * 60,
) )
@@ -169,12 +169,12 @@ class FeedbackService:
try: try:
from plyer import notification from plyer import notification
from ....core.constants import ICON_PATH, PROJECT_NAME from ....core.constants import CLI_NAME, ICON_PATH
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message="No current way to display info in rofi, use fzf and the terminal instead", message="No current way to display info in rofi, use fzf and the terminal instead",
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=self.app_config.general.desktop_notification_duration * 60, timeout=self.app_config.general.desktop_notification_duration * 60,
) )

View File

@@ -9,13 +9,19 @@ import sys
from httpx import get from httpx import get
from rich import print from rich import print
from ...core.constants import AUTHOR, GIT_REPO, PROJECT_NAME_LOWER, __version__ from ...core.constants import (
AUTHOR,
CLI_NAME_LOWER,
GIT_REPO,
PROJECT_NAME,
__version__,
)
API_URL = f"https://api.{GIT_REPO}/repos/{AUTHOR}/{PROJECT_NAME_LOWER}/releases/latest" API_URL = f"https://api.{GIT_REPO}/repos/{AUTHOR}/{CLI_NAME_LOWER}/releases/latest"
def check_for_updates(): def check_for_updates():
USER_AGENT = f"{PROJECT_NAME_LOWER} user" USER_AGENT = f"{CLI_NAME_LOWER} user"
try: try:
response = get( response = get(
API_URL, API_URL,
@@ -96,9 +102,9 @@ def update_app(force=False):
return False, release_json return False, release_json
process = subprocess.run( process = subprocess.run(
[NIX, "profile", "upgrade", PROJECT_NAME_LOWER], check=False [NIX, "profile", "upgrade", CLI_NAME_LOWER], check=False
) )
elif is_git_repo(AUTHOR, PROJECT_NAME_LOWER): elif is_git_repo(AUTHOR, CLI_NAME_LOWER):
GIT_EXECUTABLE = shutil.which("git") GIT_EXECUTABLE = shutil.which("git")
args = [ args = [
GIT_EXECUTABLE, GIT_EXECUTABLE,
@@ -117,11 +123,9 @@ def update_app(force=False):
) )
elif UV := shutil.which("uv"): elif UV := shutil.which("uv"):
process = subprocess.run( process = subprocess.run([UV, "tool", "upgrade", PROJECT_NAME], check=False)
[UV, "tool", "upgrade", PROJECT_NAME_LOWER], check=False
)
elif PIPX := shutil.which("pipx"): elif PIPX := shutil.which("pipx"):
process = subprocess.run([PIPX, "upgrade", PROJECT_NAME_LOWER], check=False) process = subprocess.run([PIPX, "upgrade", PROJECT_NAME], check=False)
else: else:
PYTHON_EXECUTABLE = sys.executable PYTHON_EXECUTABLE = sys.executable
@@ -130,7 +134,7 @@ def update_app(force=False):
"-m", "-m",
"pip", "pip",
"install", "install",
PROJECT_NAME_LOWER, PROJECT_NAME,
"-U", "-U",
"--no-warn-script-location", "--no-warn-script-location",
] ]

View File

@@ -4,9 +4,10 @@ from importlib import metadata, resources
from pathlib import Path from pathlib import Path
PLATFORM = sys.platform PLATFORM = sys.platform
PROJECT_NAME = "VIU" CLI_NAME = "VIU"
PROJECT_NAME_LOWER = "viu" CLI_NAME_LOWER = "viu"
APP_NAME = os.environ.get(f"{PROJECT_NAME}_APP_NAME", PROJECT_NAME_LOWER) PROJECT_NAME = "viu-media"
APP_NAME = os.environ.get(f"{CLI_NAME}_APP_NAME", CLI_NAME_LOWER)
USER_NAME = os.environ.get("USERNAME", "User") USER_NAME = os.environ.get("USERNAME", "User")
@@ -24,7 +25,7 @@ ANILIST_AUTH = (
) )
try: try:
APP_DIR = Path(str(resources.files(PROJECT_NAME.lower()))) APP_DIR = Path(str(resources.files(CLI_NAME.lower())))
except ModuleNotFoundError: except ModuleNotFoundError:
from pathlib import Path from pathlib import Path

View File

@@ -54,15 +54,15 @@ class RofiSelector(BaseSelector):
from plyer import notification from plyer import notification
from ....core.constants import ( from ....core.constants import (
CLI_NAME,
CLI_NAME_LOWER,
ICON_PATH, ICON_PATH,
PROJECT_NAME,
PROJECT_NAME_LOWER,
) )
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=f"Nothing was selected {PROJECT_NAME_LOWER} is shutting down", message=f"Nothing was selected {CLI_NAME_LOWER} is shutting down",
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=2 * 60, timeout=2 * 60,
) )
@@ -120,15 +120,15 @@ class RofiSelector(BaseSelector):
from plyer import notification from plyer import notification
from ....core.constants import ( from ....core.constants import (
CLI_NAME,
CLI_NAME_LOWER,
ICON_PATH, ICON_PATH,
PROJECT_NAME,
PROJECT_NAME_LOWER,
) )
notification.notify( # type: ignore notification.notify( # type: ignore
title=f"{PROJECT_NAME} notification".title(), title=f"{CLI_NAME} notification".title(),
message=f"Nothing was selected {PROJECT_NAME_LOWER} is shutting down", message=f"Nothing was selected {CLI_NAME_LOWER} is shutting down",
app_name=PROJECT_NAME, app_name=CLI_NAME,
app_icon=str(ICON_PATH), app_icon=str(ICON_PATH),
timeout=2 * 60, timeout=2 * 60,
) )