From 4a2c981dff293523af6523c2e209331cc00ecaec Mon Sep 17 00:00:00 2001 From: Benex254 Date: Wed, 19 Jun 2024 20:43:23 +0300 Subject: [PATCH] feat:create cli subpackage --- fastanime/__init__.py | 189 +++--------------- fastanime/__main__.py | 6 +- fastanime/cli/__init__.py | 10 + fastanime/cli/commands/__init__.py | 3 + fastanime/cli/commands/anilist/__init__.py | 23 +++ fastanime/cli/commands/anilist/favourites.py | 6 + fastanime/cli/commands/anilist/popular.py | 6 + fastanime/cli/commands/anilist/recent.py | 6 + fastanime/cli/commands/anilist/search.py | 6 + fastanime/cli/commands/anilist/trending.py | 6 + fastanime/cli/commands/anilist/upcoming.py | 6 + fastanime/cli/commands/download.py | 6 + fastanime/cli/commands/search.py | 6 + fastanime/cli/utils/fzf.py | 31 +++ fastanime/{ => gui}/Controller/__init__.py | 0 .../{ => gui}/Controller/anime_screen.py | 0 .../{ => gui}/Controller/downloads_screen.py | 0 fastanime/{ => gui}/Controller/home_screen.py | 0 .../{ => gui}/Controller/my_list_screen.py | 0 .../{ => gui}/Controller/search_screen.py | 0 fastanime/{ => gui}/Model/__init__.py | 0 fastanime/{ => gui}/Model/anime_screen.py | 0 fastanime/{ => gui}/Model/base_model.py | 0 fastanime/{ => gui}/Model/download_screen.py | 0 fastanime/{ => gui}/Model/home_screen.py | 0 fastanime/{ => gui}/Model/my_list_screen.py | 0 fastanime/{ => gui}/Model/search_screen.py | 0 .../{ => gui}/View/AnimeScreen/__init__.py | 0 .../View/AnimeScreen/anime_screen.kv | 0 .../View/AnimeScreen/anime_screen.py | 0 .../View/DownloadsScreen/__init__.py | 0 .../DownloadsScreen/components/__init__.py | 0 .../DownloadsScreen/components/status_bar.kv | 0 .../DownloadsScreen/components/task_card.kv | 0 .../DownloadsScreen/components/task_card.py | 0 .../View/DownloadsScreen/download_screen.kv | 0 .../View/DownloadsScreen/download_screen.py | 0 .../{ => gui}/View/HomeScreen/__init__.py | 0 .../View/HomeScreen/components/__init__.py | 0 .../{ => gui}/View/HomeScreen/home_screen.kv | 0 .../{ => gui}/View/HomeScreen/home_screen.py | 0 .../{ => gui}/View/MylistScreen/__init__.py | 0 .../View/MylistScreen/my_list_screen.kv | 0 .../View/MylistScreen/my_list_screen.py | 0 .../{ => gui}/View/SearchScreen/__init__.py | 0 .../View/SearchScreen/components/__init__.py | 0 .../View/SearchScreen/components/filters.kv | 0 .../View/SearchScreen/components/filters.py | 0 .../SearchScreen/components/pagination.kv | 0 .../SearchScreen/components/pagination.py | 0 .../components/trending_sidebar.kv | 0 .../components/trending_sidebar.py | 0 .../View/SearchScreen/search_screen.kv | 0 .../View/SearchScreen/search_screen.py | 0 fastanime/{ => gui}/View/__init__.py | 0 fastanime/{ => gui}/View/base_screen.py | 0 .../{ => gui}/View/components/__init__.py | 0 .../components/animdl_dialog/animdl_dialog.kv | 0 .../components/animdl_dialog/animdl_dialog.py | 0 .../{ => gui}/View/components/general.kv | 0 .../View/components/media_card/__init__.py | 0 .../media_card/components/__init__.py | 0 .../components/media_cards_container.kv | 0 .../media_card/components/media_player.py | 0 .../media_card/components/media_popup.kv | 0 .../media_card/components/media_popup.py | 0 .../media_card/components/tooltip.kv | 0 .../View/components/media_card/media_card.kv | 0 .../View/components/media_card/media_card.py | 0 .../{ => gui}/View/components/navrail.kv | 0 .../{ => gui}/View/components/tooltip.kv | 0 .../{ => gui}/View/components/top_app_bar.kv | 0 fastanime/{ => gui}/View/screens.py | 0 fastanime/gui/__init__.py | 0 fastanime/{fastanime.py => gui/gui.py} | 38 ++-- fastanime/readme.txt | 23 --- requirements.txt | 2 + 77 files changed, 161 insertions(+), 212 deletions(-) create mode 100644 fastanime/cli/__init__.py create mode 100644 fastanime/cli/commands/__init__.py create mode 100644 fastanime/cli/commands/anilist/__init__.py create mode 100644 fastanime/cli/commands/anilist/favourites.py create mode 100644 fastanime/cli/commands/anilist/popular.py create mode 100644 fastanime/cli/commands/anilist/recent.py create mode 100644 fastanime/cli/commands/anilist/search.py create mode 100644 fastanime/cli/commands/anilist/trending.py create mode 100644 fastanime/cli/commands/anilist/upcoming.py create mode 100644 fastanime/cli/commands/download.py create mode 100644 fastanime/cli/commands/search.py create mode 100644 fastanime/cli/utils/fzf.py rename fastanime/{ => gui}/Controller/__init__.py (100%) rename fastanime/{ => gui}/Controller/anime_screen.py (100%) rename fastanime/{ => gui}/Controller/downloads_screen.py (100%) rename fastanime/{ => gui}/Controller/home_screen.py (100%) rename fastanime/{ => gui}/Controller/my_list_screen.py (100%) rename fastanime/{ => gui}/Controller/search_screen.py (100%) rename fastanime/{ => gui}/Model/__init__.py (100%) rename fastanime/{ => gui}/Model/anime_screen.py (100%) rename fastanime/{ => gui}/Model/base_model.py (100%) rename fastanime/{ => gui}/Model/download_screen.py (100%) rename fastanime/{ => gui}/Model/home_screen.py (100%) rename fastanime/{ => gui}/Model/my_list_screen.py (100%) rename fastanime/{ => gui}/Model/search_screen.py (100%) rename fastanime/{ => gui}/View/AnimeScreen/__init__.py (100%) rename fastanime/{ => gui}/View/AnimeScreen/anime_screen.kv (100%) rename fastanime/{ => gui}/View/AnimeScreen/anime_screen.py (100%) rename fastanime/{ => gui}/View/DownloadsScreen/__init__.py (100%) rename fastanime/{ => gui}/View/DownloadsScreen/components/__init__.py (100%) rename fastanime/{ => gui}/View/DownloadsScreen/components/status_bar.kv (100%) rename fastanime/{ => gui}/View/DownloadsScreen/components/task_card.kv (100%) rename fastanime/{ => gui}/View/DownloadsScreen/components/task_card.py (100%) rename fastanime/{ => gui}/View/DownloadsScreen/download_screen.kv (100%) rename fastanime/{ => gui}/View/DownloadsScreen/download_screen.py (100%) rename fastanime/{ => gui}/View/HomeScreen/__init__.py (100%) rename fastanime/{ => gui}/View/HomeScreen/components/__init__.py (100%) rename fastanime/{ => gui}/View/HomeScreen/home_screen.kv (100%) rename fastanime/{ => gui}/View/HomeScreen/home_screen.py (100%) rename fastanime/{ => gui}/View/MylistScreen/__init__.py (100%) rename fastanime/{ => gui}/View/MylistScreen/my_list_screen.kv (100%) rename fastanime/{ => gui}/View/MylistScreen/my_list_screen.py (100%) rename fastanime/{ => gui}/View/SearchScreen/__init__.py (100%) rename fastanime/{ => gui}/View/SearchScreen/components/__init__.py (100%) rename fastanime/{ => gui}/View/SearchScreen/components/filters.kv (100%) rename fastanime/{ => gui}/View/SearchScreen/components/filters.py (100%) rename fastanime/{ => gui}/View/SearchScreen/components/pagination.kv (100%) rename fastanime/{ => gui}/View/SearchScreen/components/pagination.py (100%) rename fastanime/{ => gui}/View/SearchScreen/components/trending_sidebar.kv (100%) rename fastanime/{ => gui}/View/SearchScreen/components/trending_sidebar.py (100%) rename fastanime/{ => gui}/View/SearchScreen/search_screen.kv (100%) rename fastanime/{ => gui}/View/SearchScreen/search_screen.py (100%) rename fastanime/{ => gui}/View/__init__.py (100%) rename fastanime/{ => gui}/View/base_screen.py (100%) rename fastanime/{ => gui}/View/components/__init__.py (100%) rename fastanime/{ => gui}/View/components/animdl_dialog/animdl_dialog.kv (100%) rename fastanime/{ => gui}/View/components/animdl_dialog/animdl_dialog.py (100%) rename fastanime/{ => gui}/View/components/general.kv (100%) rename fastanime/{ => gui}/View/components/media_card/__init__.py (100%) rename fastanime/{ => gui}/View/components/media_card/components/__init__.py (100%) rename fastanime/{ => gui}/View/components/media_card/components/media_cards_container.kv (100%) rename fastanime/{ => gui}/View/components/media_card/components/media_player.py (100%) rename fastanime/{ => gui}/View/components/media_card/components/media_popup.kv (100%) rename fastanime/{ => gui}/View/components/media_card/components/media_popup.py (100%) rename fastanime/{ => gui}/View/components/media_card/components/tooltip.kv (100%) rename fastanime/{ => gui}/View/components/media_card/media_card.kv (100%) rename fastanime/{ => gui}/View/components/media_card/media_card.py (100%) rename fastanime/{ => gui}/View/components/navrail.kv (100%) rename fastanime/{ => gui}/View/components/tooltip.kv (100%) rename fastanime/{ => gui}/View/components/top_app_bar.kv (100%) rename fastanime/{ => gui}/View/screens.py (100%) create mode 100644 fastanime/gui/__init__.py rename fastanime/{fastanime.py => gui/gui.py} (86%) delete mode 100644 fastanime/readme.txt diff --git a/fastanime/__init__.py b/fastanime/__init__.py index 113df46..5cc3b9a 100644 --- a/fastanime/__init__.py +++ b/fastanime/__init__.py @@ -1,191 +1,48 @@ import os -import random +import sys + +from rich import print +from rich.traceback import install import plyer -from kivy.config import Config -from kivy.loader import Loader -from kivy.logger import Logger -from kivy.resources import resource_add_path, resource_find -from kivy.storage.jsonstore import JsonStore -from kivy.uix.screenmanager import FadeTransition, ScreenManager -from kivy.uix.settings import Settings, SettingsWithSidebar -from kivymd.app import MDApp -from .libs.mpv.player import mpv_player -from .Utility import ( - themes_available, -) -from .Utility.show_notification import show_notification -from .View.components.media_card.components.media_popup import MediaPopup -from .View.screens import screens +install() -os.environ["KIVY_VIDEO"] = "ffpyplayer" # noqa: E402 +# TODO:confirm data integrity -Config.set("graphics", "width", "1000") # noqa: E402 -Config.set("graphics", "minimum_width", "1000") # noqa: E402 -Config.set("kivy", "window_icon", resource_find("logo.ico")) # noqa: E402 -Config.write() # noqa: E402 - - -Loader.num_workers = 5 -Loader.max_upload_per_frame = 10 - - -# print(plyer.storagepath.get_application_dir(), plyer.storagepath.get_home_dir()) +# ----- some useful paths ----- app_dir = os.path.abspath(os.path.dirname(__file__)) - - data_folder = os.path.join(app_dir, "data") +configs_folder = os.path.join(app_dir, "configs") if not os.path.exists(data_folder): os.mkdir(data_folder) - if vid_path := plyer.storagepath.get_videos_dir(): # type: ignore downloads_dir = os.path.join(vid_path, "FastAnime") if not os.path.exists(downloads_dir): os.mkdir(downloads_dir) else: + # fallback downloads_dir = os.path.join(app_dir, "videos") if not os.path.exists(downloads_dir): os.mkdir(downloads_dir) - -# TODO:confirm data integrity -if os.path.exists(os.path.join(data_folder, "user_data.json")): - user_data = JsonStore(os.path.join(data_folder, "user_data.json")) -else: - user_data_path = os.path.join(data_folder, "user_data.json") - user_data = JsonStore(user_data_path) - - +user_data_path = os.path.join(data_folder, "user_data.json") assets_folder = os.path.join(app_dir, "assets") -resource_add_path(assets_folder) -conigs_folder = os.path.join(app_dir, "configs") -resource_add_path(conigs_folder) -from .Utility import user_data_helper +def FastAnime(gui=False): + if "--gui" in sys.argv: + gui = True + sys.argv.remove("--gui") + print(f"Hello {os.environ.get("USERNAME")} from the fastanime team") + if gui: + print(__name__) + from .gui.gui import run_gui + print("Run GUI") + run_gui() + else: + from .cli import run_cli -from .Utility.downloader.downloader import downloader - - -class FastAnime(MDApp): - # Ensure the user data fields exist - if not (user_data.exists("user_anime_list")): - user_data_helper.update_user_anime_list([]) - - def __init__(self, **kwargs): - self.default_banner_image = resource_find( - random.choice(["banner_1.jpg", "banner.jpg"]) - ) - self.default_anime_image = resource_find( - random.choice(["default_1.jpg", "default.jpg"]) - ) - super().__init__(**kwargs) - self.icon = resource_find("logo.png") - - self.load_all_kv_files(self.directory) - self.theme_cls.theme_style = "Dark" - self.theme_cls.primary_palette = "Lightcoral" - self.manager_screens = ScreenManager() - self.manager_screens.transition = FadeTransition() - - def build(self) -> ScreenManager: - self.settings_cls = SettingsWithSidebar - - self.generate_application_screens() - - if config := self.config: - if theme_color := config.get("Preferences", "theme_color"): - self.theme_cls.primary_palette = theme_color - if theme_style := config.get("Preferences", "theme_style"): - self.theme_cls.theme_style = theme_style - - self.anime_screen = self.manager_screens.get_screen("anime screen") - self.search_screen = self.manager_screens.get_screen("search screen") - self.download_screen = self.manager_screens.get_screen("downloads screen") - self.home_screen = self.manager_screens.get_screen("home screen") - return self.manager_screens - - def on_start(self, *args): - self.media_card_popup = MediaPopup() - - def generate_application_screens(self) -> None: - for i, name_screen in enumerate(screens.keys()): - model = screens[name_screen]["model"]() - controller = screens[name_screen]["controller"](model) - view = controller.get_view() - view.manager_screens = self.manager_screens - view.name = name_screen - self.manager_screens.add_widget(view) - - def build_config(self, config): - # General settings setup - config.setdefaults( - "Preferences", - { - "theme_color": "Cyan", - "theme_style": "Dark", - "downloads_dir": downloads_dir, - }, - ) - - def build_settings(self, settings: Settings): - settings.add_json_panel( - "Settings", self.config, resource_find("general_settings_panel.json") - ) - - def on_config_change(self, config, section, key, value): - # TODO: Change to match case - if section == "Preferences": - match key: - case "theme_color": - if value in themes_available: - self.theme_cls.primary_palette = value - else: - Logger.warning( - "AniXStream Settings: An invalid theme has been entered and will be ignored" - ) - config.set("Preferences", "theme_color", "Cyan") - config.write() - case "theme_style": - self.theme_cls.theme_style = value - - def on_stop(self): - pass - - def search_for_anime(self, search_field, **kwargs): - if self.manager_screens.current != "search screen": - self.manager_screens.current = "search screen" - self.search_screen.handle_search_for_anime(search_field, **kwargs) - - def add_anime_to_user_anime_list(self, id: int): - updated_list = user_data_helper.get_user_anime_list() - updated_list.append(id) - user_data_helper.update_user_anime_list(updated_list) - - def remove_anime_from_user_anime_list(self, id: int): - updated_list = user_data_helper.get_user_anime_list() - if updated_list.count(id): - updated_list.remove(id) - user_data_helper.update_user_anime_list(updated_list) - - def show_anime_screen(self, id: int, title, caller_screen_name: str): - self.manager_screens.current = "anime screen" - self.anime_screen.controller.update_anime_view(id, title, caller_screen_name) - - def play_on_mpv(self, anime_video_url: str): - if mpv_player.mpv_process: - mpv_player.stop_mpv() - mpv_player.run_mpv(anime_video_url) - - def download_anime_video(self, url: str, anime_title: tuple): - self.download_screen.new_download_task(anime_title) - show_notification("New Download", f"{anime_title[0]} episode: {anime_title[1]}") - progress_hook = self.download_screen.on_episode_download_progress - downloader.download_file(url, anime_title, progress_hook) - - -def main(): - FastAnime().run() + run_cli() diff --git a/fastanime/__main__.py b/fastanime/__main__.py index e740e2d..a984e8e 100644 --- a/fastanime/__main__.py +++ b/fastanime/__main__.py @@ -11,13 +11,13 @@ if __package__ is None and not getattr(sys, "frozen", False): if __name__ == "__main__": in_development = bool(os.environ.get("IN_DEVELOPMENT", False)) - import fastanime + from . import FastAnime if in_development: - fastanime.main() + FastAnime() else: try: - fastanime.main() + FastAnime() except Exception as e: from .Utility.utils import write_crash diff --git a/fastanime/cli/__init__.py b/fastanime/cli/__init__.py new file mode 100644 index 0000000..14319d7 --- /dev/null +++ b/fastanime/cli/__init__.py @@ -0,0 +1,10 @@ +import click +from rich import print +from .commands import search, download, anilist + +commands = {"search": search, "download": download, "anilist": anilist} + + +@click.group(commands=commands) +def run_cli(): + print("Yellow") diff --git a/fastanime/cli/commands/__init__.py b/fastanime/cli/commands/__init__.py new file mode 100644 index 0000000..a1dfaab --- /dev/null +++ b/fastanime/cli/commands/__init__.py @@ -0,0 +1,3 @@ +from .anilist import anilist +from .download import download +from .search import search diff --git a/fastanime/cli/commands/anilist/__init__.py b/fastanime/cli/commands/anilist/__init__.py new file mode 100644 index 0000000..3ff80da --- /dev/null +++ b/fastanime/cli/commands/anilist/__init__.py @@ -0,0 +1,23 @@ +import click + +from .favourites import favourites +from .recent import recent +from .search import search +from .popular import popular +from .trending import trending +from .upcoming import upcoming + + +commands = { + "favourites": favourites, + "recent": recent, + "search": search, + "popular": popular, + "trending": trending, + "upcoming": upcoming, +} + + +@click.group(commands=commands) +def anilist(): + pass diff --git a/fastanime/cli/commands/anilist/favourites.py b/fastanime/cli/commands/anilist/favourites.py new file mode 100644 index 0000000..1825149 --- /dev/null +++ b/fastanime/cli/commands/anilist/favourites.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def favourites(): + print("favourites") diff --git a/fastanime/cli/commands/anilist/popular.py b/fastanime/cli/commands/anilist/popular.py new file mode 100644 index 0000000..26fc27c --- /dev/null +++ b/fastanime/cli/commands/anilist/popular.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def popular(): + print("popular") diff --git a/fastanime/cli/commands/anilist/recent.py b/fastanime/cli/commands/anilist/recent.py new file mode 100644 index 0000000..0baace6 --- /dev/null +++ b/fastanime/cli/commands/anilist/recent.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def recent(): + print("recent") diff --git a/fastanime/cli/commands/anilist/search.py b/fastanime/cli/commands/anilist/search.py new file mode 100644 index 0000000..00bd076 --- /dev/null +++ b/fastanime/cli/commands/anilist/search.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def search(): + print("search") diff --git a/fastanime/cli/commands/anilist/trending.py b/fastanime/cli/commands/anilist/trending.py new file mode 100644 index 0000000..2f6b80c --- /dev/null +++ b/fastanime/cli/commands/anilist/trending.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def trending(): + print("trending") diff --git a/fastanime/cli/commands/anilist/upcoming.py b/fastanime/cli/commands/anilist/upcoming.py new file mode 100644 index 0000000..7944a45 --- /dev/null +++ b/fastanime/cli/commands/anilist/upcoming.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def upcoming(): + print("upcoming") diff --git a/fastanime/cli/commands/download.py b/fastanime/cli/commands/download.py new file mode 100644 index 0000000..f86aed3 --- /dev/null +++ b/fastanime/cli/commands/download.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def download(): + print("download") diff --git a/fastanime/cli/commands/search.py b/fastanime/cli/commands/search.py new file mode 100644 index 0000000..2a540ba --- /dev/null +++ b/fastanime/cli/commands/search.py @@ -0,0 +1,6 @@ +import click + + +@click.command() +def search(): + print("Searching") diff --git a/fastanime/cli/utils/fzf.py b/fastanime/cli/utils/fzf.py new file mode 100644 index 0000000..ce6a277 --- /dev/null +++ b/fastanime/cli/utils/fzf.py @@ -0,0 +1,31 @@ +import subprocess +import logging + +logger = logging.getLogger(__name__) + + +def run_fzf(options: tuple[str], *custom_commands): + """ + Run fzf with a list of options and return the selected option. + """ + # Join the list of options into a single string with newlines + options_str = "\n".join(options) + + # Run fzf as a subprocess + result = subprocess.run( + ["fzf", *custom_commands], + input=options_str, + text=True, + stdout=subprocess.PIPE, + ) + + # Check if fzf was successful + if result.returncode == 0: + # Return the selected option + selection = result.stdout.strip() + logger.info(f"fzf: selected {selection}") + return selection + else: + # Handle the case where fzf fails or is canceled + logger.error("fzf was canceled or failed") + return None diff --git a/fastanime/Controller/__init__.py b/fastanime/gui/Controller/__init__.py similarity index 100% rename from fastanime/Controller/__init__.py rename to fastanime/gui/Controller/__init__.py diff --git a/fastanime/Controller/anime_screen.py b/fastanime/gui/Controller/anime_screen.py similarity index 100% rename from fastanime/Controller/anime_screen.py rename to fastanime/gui/Controller/anime_screen.py diff --git a/fastanime/Controller/downloads_screen.py b/fastanime/gui/Controller/downloads_screen.py similarity index 100% rename from fastanime/Controller/downloads_screen.py rename to fastanime/gui/Controller/downloads_screen.py diff --git a/fastanime/Controller/home_screen.py b/fastanime/gui/Controller/home_screen.py similarity index 100% rename from fastanime/Controller/home_screen.py rename to fastanime/gui/Controller/home_screen.py diff --git a/fastanime/Controller/my_list_screen.py b/fastanime/gui/Controller/my_list_screen.py similarity index 100% rename from fastanime/Controller/my_list_screen.py rename to fastanime/gui/Controller/my_list_screen.py diff --git a/fastanime/Controller/search_screen.py b/fastanime/gui/Controller/search_screen.py similarity index 100% rename from fastanime/Controller/search_screen.py rename to fastanime/gui/Controller/search_screen.py diff --git a/fastanime/Model/__init__.py b/fastanime/gui/Model/__init__.py similarity index 100% rename from fastanime/Model/__init__.py rename to fastanime/gui/Model/__init__.py diff --git a/fastanime/Model/anime_screen.py b/fastanime/gui/Model/anime_screen.py similarity index 100% rename from fastanime/Model/anime_screen.py rename to fastanime/gui/Model/anime_screen.py diff --git a/fastanime/Model/base_model.py b/fastanime/gui/Model/base_model.py similarity index 100% rename from fastanime/Model/base_model.py rename to fastanime/gui/Model/base_model.py diff --git a/fastanime/Model/download_screen.py b/fastanime/gui/Model/download_screen.py similarity index 100% rename from fastanime/Model/download_screen.py rename to fastanime/gui/Model/download_screen.py diff --git a/fastanime/Model/home_screen.py b/fastanime/gui/Model/home_screen.py similarity index 100% rename from fastanime/Model/home_screen.py rename to fastanime/gui/Model/home_screen.py diff --git a/fastanime/Model/my_list_screen.py b/fastanime/gui/Model/my_list_screen.py similarity index 100% rename from fastanime/Model/my_list_screen.py rename to fastanime/gui/Model/my_list_screen.py diff --git a/fastanime/Model/search_screen.py b/fastanime/gui/Model/search_screen.py similarity index 100% rename from fastanime/Model/search_screen.py rename to fastanime/gui/Model/search_screen.py diff --git a/fastanime/View/AnimeScreen/__init__.py b/fastanime/gui/View/AnimeScreen/__init__.py similarity index 100% rename from fastanime/View/AnimeScreen/__init__.py rename to fastanime/gui/View/AnimeScreen/__init__.py diff --git a/fastanime/View/AnimeScreen/anime_screen.kv b/fastanime/gui/View/AnimeScreen/anime_screen.kv similarity index 100% rename from fastanime/View/AnimeScreen/anime_screen.kv rename to fastanime/gui/View/AnimeScreen/anime_screen.kv diff --git a/fastanime/View/AnimeScreen/anime_screen.py b/fastanime/gui/View/AnimeScreen/anime_screen.py similarity index 100% rename from fastanime/View/AnimeScreen/anime_screen.py rename to fastanime/gui/View/AnimeScreen/anime_screen.py diff --git a/fastanime/View/DownloadsScreen/__init__.py b/fastanime/gui/View/DownloadsScreen/__init__.py similarity index 100% rename from fastanime/View/DownloadsScreen/__init__.py rename to fastanime/gui/View/DownloadsScreen/__init__.py diff --git a/fastanime/View/DownloadsScreen/components/__init__.py b/fastanime/gui/View/DownloadsScreen/components/__init__.py similarity index 100% rename from fastanime/View/DownloadsScreen/components/__init__.py rename to fastanime/gui/View/DownloadsScreen/components/__init__.py diff --git a/fastanime/View/DownloadsScreen/components/status_bar.kv b/fastanime/gui/View/DownloadsScreen/components/status_bar.kv similarity index 100% rename from fastanime/View/DownloadsScreen/components/status_bar.kv rename to fastanime/gui/View/DownloadsScreen/components/status_bar.kv diff --git a/fastanime/View/DownloadsScreen/components/task_card.kv b/fastanime/gui/View/DownloadsScreen/components/task_card.kv similarity index 100% rename from fastanime/View/DownloadsScreen/components/task_card.kv rename to fastanime/gui/View/DownloadsScreen/components/task_card.kv diff --git a/fastanime/View/DownloadsScreen/components/task_card.py b/fastanime/gui/View/DownloadsScreen/components/task_card.py similarity index 100% rename from fastanime/View/DownloadsScreen/components/task_card.py rename to fastanime/gui/View/DownloadsScreen/components/task_card.py diff --git a/fastanime/View/DownloadsScreen/download_screen.kv b/fastanime/gui/View/DownloadsScreen/download_screen.kv similarity index 100% rename from fastanime/View/DownloadsScreen/download_screen.kv rename to fastanime/gui/View/DownloadsScreen/download_screen.kv diff --git a/fastanime/View/DownloadsScreen/download_screen.py b/fastanime/gui/View/DownloadsScreen/download_screen.py similarity index 100% rename from fastanime/View/DownloadsScreen/download_screen.py rename to fastanime/gui/View/DownloadsScreen/download_screen.py diff --git a/fastanime/View/HomeScreen/__init__.py b/fastanime/gui/View/HomeScreen/__init__.py similarity index 100% rename from fastanime/View/HomeScreen/__init__.py rename to fastanime/gui/View/HomeScreen/__init__.py diff --git a/fastanime/View/HomeScreen/components/__init__.py b/fastanime/gui/View/HomeScreen/components/__init__.py similarity index 100% rename from fastanime/View/HomeScreen/components/__init__.py rename to fastanime/gui/View/HomeScreen/components/__init__.py diff --git a/fastanime/View/HomeScreen/home_screen.kv b/fastanime/gui/View/HomeScreen/home_screen.kv similarity index 100% rename from fastanime/View/HomeScreen/home_screen.kv rename to fastanime/gui/View/HomeScreen/home_screen.kv diff --git a/fastanime/View/HomeScreen/home_screen.py b/fastanime/gui/View/HomeScreen/home_screen.py similarity index 100% rename from fastanime/View/HomeScreen/home_screen.py rename to fastanime/gui/View/HomeScreen/home_screen.py diff --git a/fastanime/View/MylistScreen/__init__.py b/fastanime/gui/View/MylistScreen/__init__.py similarity index 100% rename from fastanime/View/MylistScreen/__init__.py rename to fastanime/gui/View/MylistScreen/__init__.py diff --git a/fastanime/View/MylistScreen/my_list_screen.kv b/fastanime/gui/View/MylistScreen/my_list_screen.kv similarity index 100% rename from fastanime/View/MylistScreen/my_list_screen.kv rename to fastanime/gui/View/MylistScreen/my_list_screen.kv diff --git a/fastanime/View/MylistScreen/my_list_screen.py b/fastanime/gui/View/MylistScreen/my_list_screen.py similarity index 100% rename from fastanime/View/MylistScreen/my_list_screen.py rename to fastanime/gui/View/MylistScreen/my_list_screen.py diff --git a/fastanime/View/SearchScreen/__init__.py b/fastanime/gui/View/SearchScreen/__init__.py similarity index 100% rename from fastanime/View/SearchScreen/__init__.py rename to fastanime/gui/View/SearchScreen/__init__.py diff --git a/fastanime/View/SearchScreen/components/__init__.py b/fastanime/gui/View/SearchScreen/components/__init__.py similarity index 100% rename from fastanime/View/SearchScreen/components/__init__.py rename to fastanime/gui/View/SearchScreen/components/__init__.py diff --git a/fastanime/View/SearchScreen/components/filters.kv b/fastanime/gui/View/SearchScreen/components/filters.kv similarity index 100% rename from fastanime/View/SearchScreen/components/filters.kv rename to fastanime/gui/View/SearchScreen/components/filters.kv diff --git a/fastanime/View/SearchScreen/components/filters.py b/fastanime/gui/View/SearchScreen/components/filters.py similarity index 100% rename from fastanime/View/SearchScreen/components/filters.py rename to fastanime/gui/View/SearchScreen/components/filters.py diff --git a/fastanime/View/SearchScreen/components/pagination.kv b/fastanime/gui/View/SearchScreen/components/pagination.kv similarity index 100% rename from fastanime/View/SearchScreen/components/pagination.kv rename to fastanime/gui/View/SearchScreen/components/pagination.kv diff --git a/fastanime/View/SearchScreen/components/pagination.py b/fastanime/gui/View/SearchScreen/components/pagination.py similarity index 100% rename from fastanime/View/SearchScreen/components/pagination.py rename to fastanime/gui/View/SearchScreen/components/pagination.py diff --git a/fastanime/View/SearchScreen/components/trending_sidebar.kv b/fastanime/gui/View/SearchScreen/components/trending_sidebar.kv similarity index 100% rename from fastanime/View/SearchScreen/components/trending_sidebar.kv rename to fastanime/gui/View/SearchScreen/components/trending_sidebar.kv diff --git a/fastanime/View/SearchScreen/components/trending_sidebar.py b/fastanime/gui/View/SearchScreen/components/trending_sidebar.py similarity index 100% rename from fastanime/View/SearchScreen/components/trending_sidebar.py rename to fastanime/gui/View/SearchScreen/components/trending_sidebar.py diff --git a/fastanime/View/SearchScreen/search_screen.kv b/fastanime/gui/View/SearchScreen/search_screen.kv similarity index 100% rename from fastanime/View/SearchScreen/search_screen.kv rename to fastanime/gui/View/SearchScreen/search_screen.kv diff --git a/fastanime/View/SearchScreen/search_screen.py b/fastanime/gui/View/SearchScreen/search_screen.py similarity index 100% rename from fastanime/View/SearchScreen/search_screen.py rename to fastanime/gui/View/SearchScreen/search_screen.py diff --git a/fastanime/View/__init__.py b/fastanime/gui/View/__init__.py similarity index 100% rename from fastanime/View/__init__.py rename to fastanime/gui/View/__init__.py diff --git a/fastanime/View/base_screen.py b/fastanime/gui/View/base_screen.py similarity index 100% rename from fastanime/View/base_screen.py rename to fastanime/gui/View/base_screen.py diff --git a/fastanime/View/components/__init__.py b/fastanime/gui/View/components/__init__.py similarity index 100% rename from fastanime/View/components/__init__.py rename to fastanime/gui/View/components/__init__.py diff --git a/fastanime/View/components/animdl_dialog/animdl_dialog.kv b/fastanime/gui/View/components/animdl_dialog/animdl_dialog.kv similarity index 100% rename from fastanime/View/components/animdl_dialog/animdl_dialog.kv rename to fastanime/gui/View/components/animdl_dialog/animdl_dialog.kv diff --git a/fastanime/View/components/animdl_dialog/animdl_dialog.py b/fastanime/gui/View/components/animdl_dialog/animdl_dialog.py similarity index 100% rename from fastanime/View/components/animdl_dialog/animdl_dialog.py rename to fastanime/gui/View/components/animdl_dialog/animdl_dialog.py diff --git a/fastanime/View/components/general.kv b/fastanime/gui/View/components/general.kv similarity index 100% rename from fastanime/View/components/general.kv rename to fastanime/gui/View/components/general.kv diff --git a/fastanime/View/components/media_card/__init__.py b/fastanime/gui/View/components/media_card/__init__.py similarity index 100% rename from fastanime/View/components/media_card/__init__.py rename to fastanime/gui/View/components/media_card/__init__.py diff --git a/fastanime/View/components/media_card/components/__init__.py b/fastanime/gui/View/components/media_card/components/__init__.py similarity index 100% rename from fastanime/View/components/media_card/components/__init__.py rename to fastanime/gui/View/components/media_card/components/__init__.py diff --git a/fastanime/View/components/media_card/components/media_cards_container.kv b/fastanime/gui/View/components/media_card/components/media_cards_container.kv similarity index 100% rename from fastanime/View/components/media_card/components/media_cards_container.kv rename to fastanime/gui/View/components/media_card/components/media_cards_container.kv diff --git a/fastanime/View/components/media_card/components/media_player.py b/fastanime/gui/View/components/media_card/components/media_player.py similarity index 100% rename from fastanime/View/components/media_card/components/media_player.py rename to fastanime/gui/View/components/media_card/components/media_player.py diff --git a/fastanime/View/components/media_card/components/media_popup.kv b/fastanime/gui/View/components/media_card/components/media_popup.kv similarity index 100% rename from fastanime/View/components/media_card/components/media_popup.kv rename to fastanime/gui/View/components/media_card/components/media_popup.kv diff --git a/fastanime/View/components/media_card/components/media_popup.py b/fastanime/gui/View/components/media_card/components/media_popup.py similarity index 100% rename from fastanime/View/components/media_card/components/media_popup.py rename to fastanime/gui/View/components/media_card/components/media_popup.py diff --git a/fastanime/View/components/media_card/components/tooltip.kv b/fastanime/gui/View/components/media_card/components/tooltip.kv similarity index 100% rename from fastanime/View/components/media_card/components/tooltip.kv rename to fastanime/gui/View/components/media_card/components/tooltip.kv diff --git a/fastanime/View/components/media_card/media_card.kv b/fastanime/gui/View/components/media_card/media_card.kv similarity index 100% rename from fastanime/View/components/media_card/media_card.kv rename to fastanime/gui/View/components/media_card/media_card.kv diff --git a/fastanime/View/components/media_card/media_card.py b/fastanime/gui/View/components/media_card/media_card.py similarity index 100% rename from fastanime/View/components/media_card/media_card.py rename to fastanime/gui/View/components/media_card/media_card.py diff --git a/fastanime/View/components/navrail.kv b/fastanime/gui/View/components/navrail.kv similarity index 100% rename from fastanime/View/components/navrail.kv rename to fastanime/gui/View/components/navrail.kv diff --git a/fastanime/View/components/tooltip.kv b/fastanime/gui/View/components/tooltip.kv similarity index 100% rename from fastanime/View/components/tooltip.kv rename to fastanime/gui/View/components/tooltip.kv diff --git a/fastanime/View/components/top_app_bar.kv b/fastanime/gui/View/components/top_app_bar.kv similarity index 100% rename from fastanime/View/components/top_app_bar.kv rename to fastanime/gui/View/components/top_app_bar.kv diff --git a/fastanime/View/screens.py b/fastanime/gui/View/screens.py similarity index 100% rename from fastanime/View/screens.py rename to fastanime/gui/View/screens.py diff --git a/fastanime/gui/__init__.py b/fastanime/gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fastanime/fastanime.py b/fastanime/gui/gui.py similarity index 86% rename from fastanime/fastanime.py rename to fastanime/gui/gui.py index 46b50b3..b8c501a 100644 --- a/fastanime/fastanime.py +++ b/fastanime/gui/gui.py @@ -4,39 +4,37 @@ import random from kivy.config import Config from kivy.loader import Loader from kivy.logger import Logger -from kivy.resources import resource_find +from kivy.resources import resource_add_path, resource_find from kivy.uix.screenmanager import FadeTransition, ScreenManager from kivy.uix.settings import Settings, SettingsWithSidebar + from kivymd.app import MDApp -from fastanime.Utility.show_notification import show_notification +from ..Utility.show_notification import show_notification -from . import downloads_dir -from .libs.mpv.player import mpv_player -from .Utility import ( +from .. import downloads_dir, assets_folder, configs_folder +from ..libs.mpv.player import mpv_player +from ..Utility import ( themes_available, user_data_helper, ) -from .Utility.downloader.downloader import downloader -from .Utility.utils import write_crash +from ..Utility.downloader.downloader import downloader from .View.components.media_card.components.media_popup import MediaPopup from .View.screens import screens -os.environ["KIVY_VIDEO"] = "ffpyplayer" # noqa: E402 -Config.set("graphics", "width", "1000") # noqa: E402 -Config.set("graphics", "minimum_width", "1000") # noqa: E402 -Config.set("kivy", "window_icon", resource_find("logo.ico")) # noqa: E402 -Config.write() # noqa: E402 +def setup_app(): + os.environ["KIVY_VIDEO"] = "ffpyplayer" # noqa: E402 + Config.set("graphics", "width", "1000") # noqa: E402 + Config.set("graphics", "minimum_width", "1000") # noqa: E402 + Config.set("kivy", "window_icon", resource_find("logo.ico")) # noqa: E402 + Config.write() # noqa: E402 + Loader.num_workers = 5 + Loader.max_upload_per_frame = 10 -Loader.num_workers = 5 -Loader.max_upload_per_frame = 10 - - -# Ensure the user data fields exist -if not (user_data_helper.user_data.exists("user_anime_list")): - user_data_helper.update_user_anime_list([]) + resource_add_path(assets_folder) + resource_add_path(configs_folder) class FastAnime(MDApp): @@ -149,5 +147,5 @@ class FastAnime(MDApp): downloader.download_file(url, anime_title, progress_hook) -def run_app(): +def run_gui(): FastAnime().run() diff --git a/fastanime/readme.txt b/fastanime/readme.txt deleted file mode 100644 index 32445a7..0000000 --- a/fastanime/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -All this instructions should be done from the folder you chose to install -aniXstream but incase you have never installed python should work any where - -1. First install pyenv with the following command: -Invoke-WebRequest -UseBasicParsing -Uri -"https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" --OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1" -2. run the following command: - pyenv --version to check whether installation was a success -3. run pyenv install 3.10 and confirm success by running pyenv -l and check -for 3.10 -4. run pyenv local 3.10 (if in anixstream directory) or pyenv global 3.10 (if -in another directory to set python version 3.10 as global interpreter) -5. check if success by running python --version and checking if output is 3.10 -6. run python -m pip install animdl -7. check if success by running python -m animdl and if no error then you are -ready to use anixstream to stream anime -8. additionally you can use animdl independently by running python -m animdl -and any arguments specified in the animdl documentation eg python -m animdl -stream naruto ------------------------------ -Now enjoy :) ------------------------------- diff --git a/requirements.txt b/requirements.txt index 111acae..6e9e65f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,5 @@ plyer https://github.com/kivymd/KivyMD/archive/master.zip fuzzywuzzy python-Levenshtein +rich +click