feat:update current episode when using episode buttons and normalize anime titles from allanime

This commit is contained in:
Benex254
2024-06-10 22:02:44 +03:00
parent 93d94a15ef
commit 380c2fa42c
7 changed files with 17 additions and 17 deletions

View File

@@ -1,13 +1,15 @@
from ..libs.anilist import AniList
from .base_model import BaseScreenModel
from ..libs.anime_provider.allanime_api import anime_provider
from kivy.cache import Cache
from fuzzywuzzy import fuzz
from kivy.cache import Cache
from ..libs.anilist import AniList
from ..libs.anime_provider.allanime.api import anime_provider
from .base_model import BaseScreenModel
from ..Utility.data import anime_maps
def anime_title_percentage_match(
possible_user_requested_anime_title: str, title: tuple
) -> int:
) -> float:
"""Returns the percentage match between the possible title and user title
Args:
@@ -17,6 +19,8 @@ def anime_title_percentage_match(
Returns:
int: the percentage match
"""
if normalized_anime_title := anime_maps.get(possible_user_requested_anime_title):
possible_user_requested_anime_title = normalized_anime_title
print(locals())
# compares both the romaji and english names and gets highest Score
percentage_ratio = max(

View File

@@ -2,6 +2,9 @@
Just contains some useful data used across the codebase
"""
anime_maps = {"1P": "one piece"}
themes_available = [
"Aliceblue",
"Antiquewhite",

View File

@@ -48,13 +48,13 @@ class AnimeScreenView(BaseScreenView):
def next_episode(self):
next_episode = self.current_episode + 1
if next_episode <= self.total_episodes:
self.current_episode = next_episode
# self.current_episode = next_episode
self.update_current_episode(str(next_episode))
def previous_episode(self):
previous_episode = self.current_episode - 1
if previous_episode > 0:
self.current_episode = previous_episode
# self.current_episode = previous_episode
self.update_current_episode(str(previous_episode))
def on_current_anime_data(self, instance, value):
@@ -66,6 +66,7 @@ class AnimeScreenView(BaseScreenView):
self.update_episodes(data["availableEpisodesDetail"]["sub"][::-1])
def update_current_episode(self, episode):
self.current_episode = int(episode)
self.controller.fetch_streams(self.current_title, episode)
self.update_current_video_stream("dropbox")
self.video_player.state = "play"

View File

@@ -89,7 +89,6 @@ class FastAnime(MDApp):
"theme_color": "Cyan",
"theme_style": "Dark",
"downloads_dir": downloads_dir,
"is_startup_anime_enable": False,
},
)

View File

@@ -16,7 +16,7 @@
"desc": "Sets the app to dark or light theme",
"section": "Preferences",
"key": "theme_style",
"options":["Light","Dark"]
"options": ["Light", "Dark"]
},
{
"type": "path",
@@ -24,12 +24,5 @@
"desc": "location to download your videos",
"section": "Preferences",
"key": "downloads_dir"
},
{
"type": "bool",
"title": "Show Startup anime",
"desc": "whether to show the startup anime, switch it off for faster app startup times",
"section": "Preferences",
"key": "is_startup_anime_enable"
}
]

View File

@@ -16,7 +16,7 @@ class MPVPlayer:
def run_mpv(self, url):
self.mpv_process = Popen(
["mpv", "--input-ipc-server=/tmp/mpvsocket", "--osc", url],
stdin=DEVNULL,
stdin=PIPE,
stdout=DEVNULL,
stderr=DEVNULL,
preexec_fn=os.setsid,

BIN
mpv-shot0001.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB