mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
feat: remove platformdirs as dep
This commit is contained in:
@@ -1,13 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
from platform import system
|
from platform import system
|
||||||
|
|
||||||
from platformdirs import PlatformDirs
|
from . import APP_NAME, AUTHOR, __version__
|
||||||
|
|
||||||
from . import APP_NAME, AUTHOR
|
|
||||||
|
|
||||||
PLATFORM = system()
|
PLATFORM = system()
|
||||||
dirs = PlatformDirs(appname=APP_NAME, appauthor=AUTHOR, ensure_exists=True)
|
|
||||||
|
|
||||||
|
|
||||||
# ---- app deps ----
|
# ---- app deps ----
|
||||||
APP_DIR = os.path.abspath(os.path.dirname(__file__))
|
APP_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
@@ -24,19 +22,63 @@ PREVIEW_IMAGE = os.path.join(ASSETS_DIR, "preview")
|
|||||||
|
|
||||||
|
|
||||||
# ----- user configs and data -----
|
# ----- user configs and data -----
|
||||||
APP_DATA_DIR = dirs.user_config_dir
|
|
||||||
if not APP_DATA_DIR:
|
|
||||||
APP_DATA_DIR = dirs.user_data_dir
|
|
||||||
|
|
||||||
|
S_PLATFORM = sys.platform
|
||||||
|
|
||||||
|
if S_PLATFORM == "win32":
|
||||||
|
# app data
|
||||||
|
app_data_dir_base = os.getenv("LOCALAPPDATA")
|
||||||
|
if not app_data_dir_base:
|
||||||
|
raise RuntimeError("Could not determine app data dir please report to devs")
|
||||||
|
APP_DATA_DIR = os.path.join(app_data_dir_base, AUTHOR, APP_NAME)
|
||||||
|
|
||||||
|
# cache dir
|
||||||
|
APP_CACHE_DIR = os.path.join(APP_DATA_DIR, "cache")
|
||||||
|
|
||||||
|
# videos dir
|
||||||
|
video_dir_base = os.path.expanduser("~/Videos")
|
||||||
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
|
|
||||||
|
elif S_PLATFORM == "darwin":
|
||||||
|
# app data
|
||||||
|
app_data_dir_base = os.path.expanduser("~/Library/Application Support")
|
||||||
|
APP_DATA_DIR = os.path.join(app_data_dir_base, APP_NAME, __version__)
|
||||||
|
|
||||||
|
# cache dir
|
||||||
|
cache_dir_base = os.path.expanduser("~/Library/Caches")
|
||||||
|
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME, __version__)
|
||||||
|
|
||||||
|
# videos dir
|
||||||
|
video_dir_base = os.path.expanduser("~/Movies")
|
||||||
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
|
else:
|
||||||
|
# app data
|
||||||
|
app_data_dir_base = os.environ.get("XDG_CONFIG_HOME", "")
|
||||||
|
if not app_data_dir_base.strip():
|
||||||
|
app_data_dir_base = os.path.expanduser("~/.config")
|
||||||
|
APP_DATA_DIR = os.path.join(app_data_dir_base, APP_NAME)
|
||||||
|
|
||||||
|
# cache dir
|
||||||
|
cache_dir_base = os.environ.get("XDG_CACHE_HOME", "")
|
||||||
|
if not cache_dir_base.strip():
|
||||||
|
cache_dir_base = os.path.expanduser("~/.cache")
|
||||||
|
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME)
|
||||||
|
|
||||||
|
# videos dir
|
||||||
|
video_dir_base = os.environ.get("XDG_VIDEOS_DIR", "")
|
||||||
|
if not video_dir_base.strip():
|
||||||
|
video_dir_base = os.path.expanduser("~/Videos")
|
||||||
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
|
|
||||||
|
# ensure paths exist
|
||||||
|
Path(APP_DATA_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
Path(APP_CACHE_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
Path(USER_VIDEOS_DIR).mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# useful paths
|
||||||
USER_DATA_PATH = os.path.join(APP_DATA_DIR, "user_data.json")
|
USER_DATA_PATH = os.path.join(APP_DATA_DIR, "user_data.json")
|
||||||
USER_CONFIG_PATH = os.path.join(APP_DATA_DIR, "config.ini")
|
USER_CONFIG_PATH = os.path.join(APP_DATA_DIR, "config.ini")
|
||||||
NOTIFIER_LOG_FILE_PATH = os.path.join(APP_DATA_DIR, "notifier.log")
|
NOTIFIER_LOG_FILE_PATH = os.path.join(APP_DATA_DIR, "notifier.log")
|
||||||
|
|
||||||
# cache dir
|
|
||||||
APP_CACHE_DIR = dirs.user_cache_dir
|
|
||||||
|
|
||||||
# video dir
|
|
||||||
USER_VIDEOS_DIR = os.path.join(dirs.user_videos_dir, APP_NAME)
|
|
||||||
|
|
||||||
|
|
||||||
USER_NAME = os.environ.get("USERNAME", "Anime fun")
|
USER_NAME = os.environ.get("USERNAME", "Anime fun")
|
||||||
|
|||||||
2
poetry.lock
generated
2
poetry.lock
generated
@@ -1407,4 +1407,4 @@ test = ["pytest (>=8.1,<9.0)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.10"
|
python-versions = "^3.10"
|
||||||
content-hash = "83ec7de7d9466dcd1fadef4b21eec2a879cc9a7d526992ed280b6af53b49d9f1"
|
content-hash = "7e083892b0414cd8248240f21e5672e424054fc1ddbf5d20acf65388a652ec79"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ yt-dlp = "^2024.5.27"
|
|||||||
rich = "^13.7.1"
|
rich = "^13.7.1"
|
||||||
click = "^8.1.7"
|
click = "^8.1.7"
|
||||||
inquirerpy = "^0.3.4"
|
inquirerpy = "^0.3.4"
|
||||||
platformdirs = "^4.2.2"
|
|
||||||
python-dotenv = "^1.0.1"
|
python-dotenv = "^1.0.1"
|
||||||
thefuzz = "^0.22.1"
|
thefuzz = "^0.22.1"
|
||||||
requests = "^2.32.3"
|
requests = "^2.32.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user