mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
chore: use plyer.sttoragepath if possible
This commit is contained in:
@@ -6,7 +6,7 @@ if sys.version_info < (3, 10):
|
|||||||
) # noqa: F541
|
) # noqa: F541
|
||||||
|
|
||||||
|
|
||||||
__version__ = "v1.6.0"
|
__version__ = "v1.6.1"
|
||||||
|
|
||||||
APP_NAME = "FastAnime"
|
APP_NAME = "FastAnime"
|
||||||
AUTHOR = "Benex254"
|
AUTHOR = "Benex254"
|
||||||
|
|||||||
@@ -3,12 +3,19 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from platform import system
|
from platform import system
|
||||||
|
|
||||||
|
from plyer import storagepath
|
||||||
|
|
||||||
from . import APP_NAME, AUTHOR, __version__
|
from . import APP_NAME, AUTHOR, __version__
|
||||||
|
|
||||||
PLATFORM = system()
|
PLATFORM = system()
|
||||||
|
|
||||||
# ---- app deps ----
|
# ---- app deps ----
|
||||||
APP_DIR = os.path.abspath(os.path.dirname(__file__))
|
try:
|
||||||
|
APP_DIR = storagepath.get_application_dir() # pyright:ignore
|
||||||
|
except Exception:
|
||||||
|
APP_DIR = None
|
||||||
|
if not APP_DIR:
|
||||||
|
APP_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
CONFIGS_DIR = os.path.join(APP_DIR, "configs")
|
CONFIGS_DIR = os.path.join(APP_DIR, "configs")
|
||||||
ASSETS_DIR = os.path.join(APP_DIR, "assets")
|
ASSETS_DIR = os.path.join(APP_DIR, "assets")
|
||||||
|
|
||||||
@@ -24,10 +31,18 @@ PREVIEW_IMAGE = os.path.join(ASSETS_DIR, "preview")
|
|||||||
# ----- user configs and data -----
|
# ----- user configs and data -----
|
||||||
|
|
||||||
S_PLATFORM = sys.platform
|
S_PLATFORM = sys.platform
|
||||||
|
try:
|
||||||
|
app_data_dir_base = None
|
||||||
|
video_dir_base = storagepath.get_videos_dir() # pyright:ignore
|
||||||
|
cache_dir_base = None
|
||||||
|
except Exception:
|
||||||
|
video_dir_base = None
|
||||||
|
cache_dir_base = None
|
||||||
|
app_data_dir_base = None
|
||||||
if S_PLATFORM == "win32":
|
if S_PLATFORM == "win32":
|
||||||
# app data
|
# app data
|
||||||
app_data_dir_base = os.getenv("LOCALAPPDATA")
|
if not app_data_dir_base:
|
||||||
|
app_data_dir_base = os.getenv("LOCALAPPDATA")
|
||||||
if not app_data_dir_base:
|
if not app_data_dir_base:
|
||||||
raise RuntimeError("Could not determine app data dir please report to devs")
|
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)
|
APP_DATA_DIR = os.path.join(app_data_dir_base, AUTHOR, APP_NAME)
|
||||||
@@ -36,38 +51,45 @@ if S_PLATFORM == "win32":
|
|||||||
APP_CACHE_DIR = os.path.join(APP_DATA_DIR, "cache")
|
APP_CACHE_DIR = os.path.join(APP_DATA_DIR, "cache")
|
||||||
|
|
||||||
# videos dir
|
# videos dir
|
||||||
video_dir_base = os.path.expanduser("~/Videos")
|
if not video_dir_base:
|
||||||
|
video_dir_base = os.path.expanduser("~/Videos")
|
||||||
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
|
|
||||||
elif S_PLATFORM == "darwin":
|
elif S_PLATFORM == "darwin":
|
||||||
# app data
|
# app data
|
||||||
app_data_dir_base = os.path.expanduser("~/Library/Application Support")
|
if not app_data_dir_base:
|
||||||
|
app_data_dir_base = os.path.expanduser("~/Library/Application Support")
|
||||||
APP_DATA_DIR = os.path.join(app_data_dir_base, APP_NAME, __version__)
|
APP_DATA_DIR = os.path.join(app_data_dir_base, APP_NAME, __version__)
|
||||||
|
|
||||||
# cache dir
|
# cache dir
|
||||||
cache_dir_base = os.path.expanduser("~/Library/Caches")
|
if not cache_dir_base:
|
||||||
|
cache_dir_base = os.path.expanduser("~/Library/Caches")
|
||||||
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME, __version__)
|
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME, __version__)
|
||||||
|
|
||||||
# videos dir
|
# videos dir
|
||||||
video_dir_base = os.path.expanduser("~/Movies")
|
if not video_dir_base:
|
||||||
|
video_dir_base = os.path.expanduser("~/Movies")
|
||||||
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
else:
|
else:
|
||||||
# app data
|
# app data
|
||||||
app_data_dir_base = os.environ.get("XDG_CONFIG_HOME", "")
|
if not app_data_dir_base:
|
||||||
if not app_data_dir_base.strip():
|
app_data_dir_base = os.environ.get("XDG_CONFIG_HOME", "")
|
||||||
app_data_dir_base = os.path.expanduser("~/.config")
|
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)
|
APP_DATA_DIR = os.path.join(app_data_dir_base, APP_NAME)
|
||||||
|
|
||||||
# cache dir
|
# cache dir
|
||||||
cache_dir_base = os.environ.get("XDG_CACHE_HOME", "")
|
if not cache_dir_base:
|
||||||
if not cache_dir_base.strip():
|
cache_dir_base = os.environ.get("XDG_CACHE_HOME", "")
|
||||||
cache_dir_base = os.path.expanduser("~/.cache")
|
if not cache_dir_base.strip():
|
||||||
|
cache_dir_base = os.path.expanduser("~/.cache")
|
||||||
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME)
|
APP_CACHE_DIR = os.path.join(cache_dir_base, APP_NAME)
|
||||||
|
|
||||||
# videos dir
|
# videos dir
|
||||||
video_dir_base = os.environ.get("XDG_VIDEOS_DIR", "")
|
if not video_dir_base:
|
||||||
if not video_dir_base.strip():
|
video_dir_base = os.environ.get("XDG_VIDEOS_DIR", "")
|
||||||
video_dir_base = os.path.expanduser("~/Videos")
|
if not video_dir_base.strip():
|
||||||
|
video_dir_base = os.path.expanduser("~/Videos")
|
||||||
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
USER_VIDEOS_DIR = os.path.join(video_dir_base, APP_NAME)
|
||||||
|
|
||||||
# ensure paths exist
|
# ensure paths exist
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "fastanime"
|
name = "fastanime"
|
||||||
version = "1.6.0.dev1"
|
version = "1.6.1.dev1"
|
||||||
description = "A browser anime site experience from the terminal"
|
description = "A browser anime site experience from the terminal"
|
||||||
authors = ["Benextempest <benextempest@gmail.com>"]
|
authors = ["Benextempest <benextempest@gmail.com>"]
|
||||||
license = "UNLICENSE"
|
license = "UNLICENSE"
|
||||||
|
|||||||
Reference in New Issue
Block a user