Skip to content

Commit

Permalink
chore(deps):drop plyer as a dependency and switch to platformdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Benex254 committed Jun 28, 2024
1 parent 1ffb122 commit f3b398d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 54 deletions.
15 changes: 0 additions & 15 deletions fastanime/FastAnime/config.ini

This file was deleted.

31 changes: 11 additions & 20 deletions fastanime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from platform import platform

import plyer
from platformdirs import PlatformDirs
from rich.traceback import install

install(show_locals=True)
Expand All @@ -15,38 +15,29 @@

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__))
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):
Expand Down
19 changes: 1 addition & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit f3b398d

Please sign in to comment.