From 129766111dbd8cd2c639926d99df5bc6dd03a6cf Mon Sep 17 00:00:00 2001 From: Benedict Xavier Wanyonyi Date: Mon, 27 May 2024 18:55:50 +0300 Subject: [PATCH] feat:added help screen plus kivy_markup_helper --- app/Utility/kivy_markup_helper.py | 45 +++++++++++++ .../AnimeScreen/components/rankings_bar.kv | 1 - app/View/HelpScreen/help_screen.kv | 50 ++++++++++++++- app/View/HelpScreen/help_screen.py | 63 ++++++++++++++++++- app/libs/anilist/queries_graphql.py | 4 +- app/main.py | 3 +- app/user_data.json | 2 +- 7 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 app/Utility/kivy_markup_helper.py diff --git a/app/Utility/kivy_markup_helper.py b/app/Utility/kivy_markup_helper.py new file mode 100644 index 0000000..7b1e95f --- /dev/null +++ b/app/Utility/kivy_markup_helper.py @@ -0,0 +1,45 @@ +""" +Contains helper functions to make your life easy when adding kivy markup to text +""" + +from kivy.utils import get_hex_from_color + + +def bolden(text: str): + return f"[b]{text}[/b]" + +def italicize(text: str): + return f"[i]{text}[/i]" + +def underline(text: str): + return f"[u]{text}[/u]" + +def strike_through(text: str): + return f"[s]{text}[/s]" + +def sub_script(text: str): + return f"[sub]{text}[/sub]" + +def super_script(text: str): + return f"[sup]{text}[/sup]" + +def color_text(text: str, color: tuple): + hex_color = get_hex_from_color(color) + return f"[color={hex_color}]{text}[/color]" + +def font(text: str, font_name: str): + return f"[font={font_name}]{text}[/font]" + +def font_family(text: str, family: str): + return f"[font_family={family}]{text}[/font_family]" + +def font_context(text: str, context: str): + return f"[font_context={context}]{text}[/font_context]" + +def font_size(text: str, size: int): + return f"[size={size}]{text}[/size]" + +def text_ref(text: str, ref: str): + return f"[ref={ref}]{text}[/ref]" + + diff --git a/app/View/AnimeScreen/components/rankings_bar.kv b/app/View/AnimeScreen/components/rankings_bar.kv index 065d43c..b5531ea 100644 --- a/app/View/AnimeScreen/components/rankings_bar.kv +++ b/app/View/AnimeScreen/components/rankings_bar.kv @@ -16,7 +16,6 @@ role: "large" - : orientation:"vertical" diff --git a/app/View/HelpScreen/help_screen.kv b/app/View/HelpScreen/help_screen.kv index 740c520..9da6dfa 100644 --- a/app/View/HelpScreen/help_screen.kv +++ b/app/View/HelpScreen/help_screen.kv @@ -1,6 +1,27 @@ #:import get_color_from_hex kivy.utils.get_color_from_hex #:import StringProperty kivy.properties.StringProperty + + + + spacing:"10dp" + orientation:"vertical" + adaptive_height:True + md_bg_color:self.theme_cls.surfaceContainerLowColor + theme_text_color:"Secondary" + + + halign:"left" + +: + adaptive_height:True + max_lines:0 + shorten:False + markup:True + font_style: "Body" + padding:"10dp" + role: "large" + md_bg_color: self.theme_cls.backgroundColor # main_container:main_container @@ -13,6 +34,29 @@ MDBoxLayout: orientation: 'vertical' SearchBar: - - MDLabel: - text:"Help Screen" \ No newline at end of file + MDScrollView: + size_hint_x:.95 + MDBoxLayout: + adaptive_height:True + padding:"10dp" + orientation:"vertical" + HelpCard: + HelpHeaderLabel: + text:"Animdl Commands" + HelpDescription: + text:root.animdl_help + HelpCard: + HelpHeaderLabel: + text:"Installing Animdl" + HelpDescription: + text:root.installing_animdl_help + HelpCard: + HelpHeaderLabel: + text:"Available Themes" + HelpDescription: + text:root.available_themes + HelpCard: + HelpHeaderLabel: + text:"About" + HelpDescription: + text:"This app was made to be a gui wrapper for any and all anime cli tools. Inoder to solve the age old problem of getting the same experience from the cli as you would in a website" \ No newline at end of file diff --git a/app/View/HelpScreen/help_screen.py b/app/View/HelpScreen/help_screen.py index 4155b6d..30fe07c 100644 --- a/app/View/HelpScreen/help_screen.py +++ b/app/View/HelpScreen/help_screen.py @@ -1,13 +1,70 @@ -from kivy.properties import ObjectProperty -from View.base_screen import BaseScreenView +from kivy.properties import ObjectProperty, StringProperty +from View.base_screen import BaseScreenView +from Utility.kivy_markup_helper import bolden, color_text, underline +from Utility.data import themes_available class HelpScreenView(BaseScreenView): main_container = ObjectProperty() + animdl_help = StringProperty() + installing_animdl_help = StringProperty() + available_themes = StringProperty() + def __init__(self, **kw): + super(HelpScreenView, self).__init__(**kw) + self.animdl_help = f""" +{underline(color_text(bolden('Streaming Commands'),self.theme_cls.surfaceBrightColor))} + {color_text(bolden('-r:'),self.theme_cls.primaryFixedDimColor)} specifies the range of episodes + example: {color_text(('animdl stream -r 1-4'),self.theme_cls.tertiaryColor)} + explanation:in this case gets 4 episodes 1 to 4 + {color_text(('-s:'),self.theme_cls.primaryFixedDimColor)} special selector for the most recent episodes or basically selects from the end + example: {color_text(('animdl stream -s 4'),self.theme_cls.tertiaryColor)} + explanation: in this case gets the latest 4 episodes + {color_text(('-q:'),self.theme_cls.primaryFixedDimColor)} sets the quality of the stream + example: {color_text(('animdl stream -q best'),self.theme_cls.tertiaryColor)} + explanation: The quality of the anime stream should be the best possible others include 1080,720... plus worst +{underline(color_text(bolden('Downloading Commands'),self.theme_cls.surfaceBrightColor))} + {color_text(bolden('-r:'),self.theme_cls.primaryFixedDimColor)} specifies the range of episodes + example: {color_text(('animdl download -r 1-4'),self.theme_cls.tertiaryColor)} + explanation:in this case gets 4 episodes 1 to 4 + {color_text(('-s:'),self.theme_cls.primaryFixedDimColor)} special selector for the most recent episodes or basically selects from the end + example: {color_text(('animdl download -s 4'),self.theme_cls.tertiaryColor)} + explanation: in this case gets the latest 4 episodes + {color_text(('-q:'),self.theme_cls.primaryFixedDimColor)} sets the quality of the download + example: {color_text(('animdl download -q best'),self.theme_cls.tertiaryColor)} + explanation: The quality of the anime download should be the best possible others include 1080,720... plus worst + """ + self.installing_animdl_help = f""" +This works on windows only and should be done in powershell +1. First install pyenv with the following command: +{color_text(('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"'),self.theme_cls.tertiaryColor)} +2. run the following command to check if successsful: +{color_text(('pyenv --version '),self.theme_cls.tertiaryColor)} +3. run the following command to install python 3.10 +{color_text(('pyenv install 3.10'),self.theme_cls.tertiaryColor)} +4. To confirm successful install of python 3.10 run the following command and check if 3.10 is listed: +{color_text(('pyenv -l'),self.theme_cls.tertiaryColor)} +5. Next run: +{color_text(('pyenv local 3.10'),self.theme_cls.tertiaryColor)} (if in anixstream directory to set python 3.10 as local interpreter) +or run: +{color_text(('pyenv global 3.10'),self.theme_cls.tertiaryColor)} (if in another directory to set python version 3.10 as global interpreter) +6. Check if success by running and checking if output is 3.10: +{color_text(('python --version'),self.theme_cls.tertiaryColor)} +7. Run: +{color_text(('python -m pip install animdl'),self.theme_cls.tertiaryColor)} +8. Check if success by running: +{color_text(('python -m animdl'),self.theme_cls.tertiaryColor)} +{color_text(('Note:'),self.theme_cls.secondaryColor)} +All this instructions should be done from the folder you choose to install +aniXstream but incase you have never installed python should work any where +{bolden('-----------------------------')} +Now enjoy :) +{bolden('-----------------------------')} + """ + self.available_themes = "\n".join(themes_available) + def model_is_changed(self) -> None: """ Called whenever any change has occurred in the data model. The view in this method tracks these changes and updates the UI according to these changes. """ - \ No newline at end of file diff --git a/app/libs/anilist/queries_graphql.py b/app/libs/anilist/queries_graphql.py index 23936b2..cc66626 100644 --- a/app/libs/anilist/queries_graphql.py +++ b/app/libs/anilist/queries_graphql.py @@ -322,8 +322,8 @@ query{ most_recently_updated_query = """ query{ - Page(perPage:15,genre_not_in:["hentai"]){ - media(sort:UPDATED_AT_DESC,type:ANIME,averageScore_greater:50){ + Page(perPage:15){ + media(sort:UPDATED_AT_DESC,type:ANIME,averageScore_greater:50,genre_not_in:["hentai"]){ id title{ romaji diff --git a/app/main.py b/app/main.py index f4f3eed..40eb2e8 100644 --- a/app/main.py +++ b/app/main.py @@ -16,7 +16,7 @@ from kivy.config import Config from kivy.loader import Loader Loader.num_workers = 5 -Loader.max_upload_per_frame = 5 +Loader.max_upload_per_frame = 10 from kivy.clock import Clock from kivy.logger import Logger @@ -39,6 +39,7 @@ if not (user_data_helper.user_data.exists("user_anime_list")): if not (user_data_helper.yt_cache.exists("yt_stream_links")): user_data_helper.update_anime_trailer_cache([]) +# TODO: Confirm data integrity from user_data and yt_cache # TODO: Arrange the app methods class AniXStreamApp(MDApp): diff --git a/app/user_data.json b/app/user_data.json index 5f0906b..a7c93c5 100644 --- a/app/user_data.json +++ b/app/user_data.json @@ -1 +1 @@ -{"user_anime_list": {"user_anime_list": [166531, 21640, 269, 21519, 150672, 20626, 21, 9756, 9253, 6702, 20657, 11061, 8247, 116674, 21827, 107226, 19163, 15583, 21857, 17641, 117612, 21745, 21874, 104051, 5114]}} \ No newline at end of file +{"user_anime_list": {"user_anime_list": [166531, 98437, 269, 104462, 21519, 150672, 104463, 21, 20631, 9756, 115230, 124194, 9253, 6702, 4654, 20657, 16049, 125367, 6213, 100185, 111322, 15583, 21857, 97889, 21745, 104051, 5114, 151806]}} \ No newline at end of file