From 536e175a3ae62752984b2bf5f11d736caeeaf9ab Mon Sep 17 00:00:00 2001 From: Benex254 Date: Mon, 5 Aug 2024 09:47:00 +0300 Subject: [PATCH] chore(deps):drop plyer as a dependency and switch to platformdirs --- fastanime/FastAnime/config.ini | 15 --------------- fastanime/__init__.py | 31 +++++++++++-------------------- poetry.lock | 19 +------------------ pyproject.toml | 2 +- 4 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 fastanime/FastAnime/config.ini diff --git a/fastanime/FastAnime/config.ini b/fastanime/FastAnime/config.ini deleted file mode 100644 index dbcc5ff..0000000 --- a/fastanime/FastAnime/config.ini +++ /dev/null @@ -1,15 +0,0 @@ -[DEFAULT] -server = -continue_from_history = False -quality = 0 -auto_next = True -sort_by = search match -downloads_dir = /home/benxl-85/Videos/FastAnime -translation_type = sub - -[stream] - -[general] - -[anilist] - diff --git a/fastanime/__init__.py b/fastanime/__init__.py index dcffd4f..8a6f39c 100644 --- a/fastanime/__init__.py +++ b/fastanime/__init__.py @@ -3,7 +3,7 @@ import os import sys from platform import platform -import plyer +from platformdirs import PlatformDirs from rich.traceback import install install(show_locals=True) @@ -15,6 +15,12 @@ __version__ = "0.3.0" PLATFORM = platform() APP_NAME = "FastAnime" +AUTHOR = "Benex254" +GIT_REPO = "github.com" +REPO = f"{GIT_REPO}/{AUTHOR}/{APP_NAME}" + +dirs = PlatformDirs(appname=APP_NAME, appauthor=AUTHOR, ensure_exists=True) + # ---- app deps ---- APP_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -22,31 +28,16 @@ CONFIGS_DIR = os.path.join(APP_DIR, "configs") ASSETS_DIR = os.path.join(APP_DIR, "assets") # ----- user configs and data ----- -if PLATFORM == "windows": - APP_DATA_DIR_ = os.environ.get("LOCALAPPDATA", APP_DIR) -else: - APP_DATA_DIR_ = os.environ.get("XDG_DATA_HOME", APP_DIR) - -if not APP_DATA_DIR_: - APP_DATA_DIR = os.path.join(APP_DIR, "data") -else: - APP_DATA_DIR = os.path.join(APP_DATA_DIR_, APP_NAME) - -if not os.path.exists(APP_DATA_DIR): - os.mkdir(APP_DATA_DIR) +APP_DATA_DIR = dirs.user_config_dir +if not APP_DATA_DIR: + APP_DATA_DIR = dirs.user_data_dir USER_DATA_PATH = os.path.join(APP_DATA_DIR, "user_data.json") USER_CONFIG_PATH = os.path.join(APP_DATA_DIR, "config.ini") # video dir -if vid_path := plyer.storagepath.get_videos_dir(): # type: ignore - USER_DOWNLOADS_DIR = os.path.join(vid_path, "FastAnime") -else: - USER_DOWNLOADS_DIR = os.path.join(APP_DIR, "videos") - -if not os.path.exists(USER_DOWNLOADS_DIR): - os.mkdir(USER_DOWNLOADS_DIR) +USER_DOWNLOADS_DIR = dirs.user_downloads_dir def FastAnime(gui=False): diff --git a/poetry.lock b/poetry.lock index 70f3d31..df672c9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1144,23 +1144,6 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] -[[package]] -name = "plyer" -version = "2.1.0" -description = "Platform-independent wrapper for platform-dependent APIs" -optional = false -python-versions = "*" -files = [ - {file = "plyer-2.1.0-py2.py3-none-any.whl", hash = "sha256:1b1772060df8b3045ed4f08231690ec8f7de30f5a004aa1724665a9074eed113"}, - {file = "plyer-2.1.0.tar.gz", hash = "sha256:65b7dfb7e11e07af37a8487eb2aa69524276ef70dad500b07228ce64736baa61"}, -] - -[package.extras] -android = ["pyjnius"] -dev = ["flake8", "mock"] -ios = ["pyobjus"] -macosx = ["pyobjus"] - [[package]] name = "pre-commit" version = "3.7.1" @@ -1786,4 +1769,4 @@ test = ["pytest (>=8.1,<9.0)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "51811bf7a41344b911fbf883ede9fab2b0a93dc68c59ad90d2aab5ccd0339a51" +content-hash = "2ea2a2ce566efdc50ed0d3cc5e37f746e9a49d32af2bc82a94161ced3c5cb8f6" diff --git a/pyproject.toml b/pyproject.toml index 75d7e2d..50414b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ python = "^3.10" kivy = "^2.3.0" yt-dlp = "^2024.5.27" ffpyplayer = "^4.5.1" -plyer = "^2.1.0" fuzzywuzzy = "^0.18.0" rich = "^13.7.1" click = "^8.1.7" @@ -20,6 +19,7 @@ kivymd = [{url = "https://github.com/kivymd/KivyMD/archive/master.zip"}] pyshortcuts = "^1.9.0" inquirerpy = "^0.3.4" +platformdirs = "^4.2.2" [tool.poetry.group.dev.dependencies] black = "^24.4.2" isort = "^5.13.2"