mirror of
https://github.com/Benexl/FastAnime.git
synced 2026-01-07 19:00:51 -08:00
doc and style: formatted the whole codebase to pep8 plus added documentation where necessary
This commit is contained in:
@@ -19,6 +19,7 @@ from .components import (
|
||||
|
||||
|
||||
class AnimeScreenView(BaseScreenView):
|
||||
"""The anime screen view"""
|
||||
caller_screen_name = StringProperty()
|
||||
header: AnimeHeader = ObjectProperty()
|
||||
side_bar: AnimeSideBar = ObjectProperty()
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
padding:"10dp"
|
||||
orientation:"vertical"
|
||||
StreamDialogHeaderLabel:
|
||||
text:"Stream on Animdl"
|
||||
text:"Stream Anime"
|
||||
StreamDialogLabel:
|
||||
text:"Title"
|
||||
MDTextField:
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
from kivy.clock import Clock
|
||||
from kivy.uix.modalview import ModalView
|
||||
|
||||
from kivymd.uix.behaviors import StencilBehavior,CommonElevationBehavior,BackgroundColorBehavior
|
||||
from kivymd.uix.behaviors import (
|
||||
StencilBehavior,
|
||||
CommonElevationBehavior,
|
||||
BackgroundColorBehavior,
|
||||
)
|
||||
from kivymd.theming import ThemableBehavior
|
||||
|
||||
class AnimdlStreamDialog(ThemableBehavior,StencilBehavior,CommonElevationBehavior,BackgroundColorBehavior,ModalView):
|
||||
def __init__(self,data,mpv,**kwargs):
|
||||
|
||||
class AnimdlStreamDialog(
|
||||
ThemableBehavior,
|
||||
StencilBehavior,
|
||||
CommonElevationBehavior,
|
||||
BackgroundColorBehavior,
|
||||
ModalView,
|
||||
):
|
||||
"""The anime streaming dialog"""
|
||||
|
||||
def __init__(self, data, mpv, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.data = data
|
||||
self.mpv=mpv
|
||||
if title:=data["title"].get("romaji"):
|
||||
self.mpv = mpv
|
||||
if title := data["title"].get("romaji"):
|
||||
self.ids.title_field.text = title
|
||||
elif title:=data["title"].get("english"):
|
||||
elif title := data["title"].get("english"):
|
||||
self.ids.title_field.text = title
|
||||
|
||||
self.ids.quality_field.text = "best"
|
||||
def stream_anime(self,app):
|
||||
|
||||
def _stream_anime(self, app):
|
||||
if self.mpv:
|
||||
streaming_cmds = {}
|
||||
title = self.ids.title_field.text
|
||||
@@ -27,7 +42,7 @@ class AnimdlStreamDialog(ThemableBehavior,StencilBehavior,CommonElevationBehavio
|
||||
quality = self.ids.quality_field.text
|
||||
if quality:
|
||||
streaming_cmds["quality"] = quality
|
||||
else:
|
||||
else:
|
||||
streaming_cmds["quality"] = "best"
|
||||
|
||||
app.watch_on_animdl(streaming_cmds)
|
||||
@@ -38,14 +53,17 @@ class AnimdlStreamDialog(ThemableBehavior,StencilBehavior,CommonElevationBehavio
|
||||
|
||||
episodes_range = self.ids.range_field.text
|
||||
if episodes_range:
|
||||
cmds = [*cmds,"-r",episodes_range]
|
||||
cmds = [*cmds, "-r", episodes_range]
|
||||
|
||||
latest = self.ids.latest_field.text
|
||||
if latest:
|
||||
cmds = [*cmds,"-s",latest]
|
||||
cmds = [*cmds, "-s", latest]
|
||||
|
||||
quality = self.ids.quality_field.text
|
||||
if quality:
|
||||
cmds = [*cmds,"-q",quality]
|
||||
cmds = [*cmds, "-q", quality]
|
||||
|
||||
app.watch_on_animdl(custom_options = cmds)
|
||||
app.watch_on_animdl(custom_options=cmds)
|
||||
|
||||
def stream_anime(self, app):
|
||||
Clock.schedule_once(lambda _: self._stream_anime(app))
|
||||
|
||||
@@ -1,46 +1,56 @@
|
||||
from kivy.properties import ObjectProperty,ListProperty
|
||||
from kivy.clock import Clock
|
||||
from kivy.properties import ObjectProperty, ListProperty
|
||||
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
|
||||
|
||||
class AnimeCharacter(MDBoxLayout):
|
||||
voice_actors = ObjectProperty({
|
||||
"name":"",
|
||||
"image":""
|
||||
})
|
||||
character = ObjectProperty({
|
||||
"name":"",
|
||||
"gender":"",
|
||||
"dateOfBirth":"",
|
||||
"image":"",
|
||||
"age":"",
|
||||
"description":""
|
||||
})
|
||||
"""an Anime character data"""
|
||||
|
||||
voice_actors = ObjectProperty({"name": "", "image": ""})
|
||||
character = ObjectProperty(
|
||||
{
|
||||
"name": "",
|
||||
"gender": "",
|
||||
"dateOfBirth": "",
|
||||
"image": "",
|
||||
"age": "",
|
||||
"description": "",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class AnimeCharacters(MDBoxLayout):
|
||||
"""The anime characters card"""
|
||||
|
||||
container = ObjectProperty()
|
||||
characters = ListProperty()
|
||||
def on_characters(self,instance,characters):
|
||||
format_date = lambda date_: f"{date_['day']}/{date_['month']}/{date_['year']}" if date_ else ""
|
||||
|
||||
def update_characters_card(self, instance, characters):
|
||||
format_date = lambda date_: (
|
||||
f"{date_['day']}/{date_['month']}/{date_['year']}" if date_ else ""
|
||||
)
|
||||
|
||||
self.container.clear_widgets()
|
||||
for character_ in characters: # character (character,actor)
|
||||
for character_ in characters: # character (character,actor)
|
||||
character = character_[0]
|
||||
actors = character_[1]
|
||||
|
||||
anime_character = AnimeCharacter()
|
||||
anime_character.character = {
|
||||
"name":character["name"]["full"],
|
||||
"gender":character["gender"],
|
||||
"dateOfBirth":format_date(character["dateOfBirth"]),
|
||||
"image":character["image"]["medium"],
|
||||
"age":character["age"],
|
||||
"description":character["description"]
|
||||
"name": character["name"]["full"],
|
||||
"gender": character["gender"],
|
||||
"dateOfBirth": format_date(character["dateOfBirth"]),
|
||||
"image": character["image"]["medium"],
|
||||
"age": character["age"],
|
||||
"description": character["description"],
|
||||
}
|
||||
anime_character.voice_actors = {
|
||||
"name":", ".join([actor["name"]["full"] for actor in actors])
|
||||
"name": ", ".join([actor["name"]["full"] for actor in actors])
|
||||
}
|
||||
|
||||
# anime_character.voice_actor =
|
||||
self.container.add_widget(anime_character)
|
||||
|
||||
def on_characters(self, *args):
|
||||
Clock.schedule_once(lambda _: self.update_characters_card(*args))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
padding:"10dp"
|
||||
spacing:"10dp"
|
||||
pos_hint: {'center_x': 0.5}
|
||||
# StackLayout:
|
||||
MDButton:
|
||||
on_press:
|
||||
root.screen.add_to_user_anime_list()
|
||||
|
||||
@@ -4,4 +4,6 @@ from kivymd.uix.boxlayout import MDBoxLayout
|
||||
|
||||
|
||||
class Controls(MDBoxLayout):
|
||||
"""The diferent controls available"""
|
||||
|
||||
screen = ObjectProperty()
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
# <DescriptionHeader>
|
||||
# adaptive_height:True
|
||||
# md_bg_color:self.theme_cls.secondaryContainerColor
|
||||
# MDLabel:
|
||||
# text:root.text
|
||||
# adaptive_height:True
|
||||
# max_lines:0
|
||||
# shorten:False
|
||||
# bold:True
|
||||
# font_style: "Body"
|
||||
# role: "large"
|
||||
# padding:"10dp"
|
||||
|
||||
<DescriptionContainer@MDBoxLayout>:
|
||||
adaptive_height:True
|
||||
md_bg_color:self.theme_cls.surfaceContainerLowColor
|
||||
|
||||
@@ -4,5 +4,6 @@ from kivymd.uix.boxlayout import MDBoxLayout
|
||||
|
||||
|
||||
class AnimeDescription(MDBoxLayout):
|
||||
description = StringProperty()
|
||||
"""The anime description"""
|
||||
|
||||
description = StringProperty()
|
||||
|
||||
@@ -1,26 +1,41 @@
|
||||
from kivy.uix.modalview import ModalView
|
||||
from kivymd.uix.behaviors import StencilBehavior,CommonElevationBehavior,BackgroundColorBehavior
|
||||
|
||||
from kivymd.uix.behaviors import (
|
||||
StencilBehavior,
|
||||
CommonElevationBehavior,
|
||||
BackgroundColorBehavior,
|
||||
)
|
||||
from kivymd.theming import ThemableBehavior
|
||||
|
||||
|
||||
# from main import AniXStreamApp
|
||||
class DownloadAnimeDialog(ThemableBehavior,StencilBehavior,CommonElevationBehavior,BackgroundColorBehavior,ModalView):
|
||||
def __init__(self,data,**kwargs):
|
||||
super(DownloadAnimeDialog,self).__init__(**kwargs)
|
||||
class DownloadAnimeDialog(
|
||||
ThemableBehavior,
|
||||
StencilBehavior,
|
||||
CommonElevationBehavior,
|
||||
BackgroundColorBehavior,
|
||||
ModalView,
|
||||
):
|
||||
"""The download anime dialog"""
|
||||
|
||||
def __init__(self, data, **kwargs):
|
||||
super(DownloadAnimeDialog, self).__init__(**kwargs)
|
||||
self.data = data
|
||||
self.anime_id = self.data["id"]
|
||||
if title:=data["title"].get("romaji"):
|
||||
if title := data["title"].get("romaji"):
|
||||
self.ids.title_field.text = title
|
||||
elif title:=data["title"].get("english"):
|
||||
elif title := data["title"].get("english"):
|
||||
self.ids.title_field.text = title
|
||||
self.ids.quality_field.text = "best"
|
||||
def download_anime(self,app):
|
||||
|
||||
def download_anime(self, app):
|
||||
default_cmds = {}
|
||||
title=self.ids.title_field.text
|
||||
title = self.ids.title_field.text
|
||||
default_cmds["title"] = title
|
||||
if episodes_range:=self.ids.range_field.text:
|
||||
if episodes_range := self.ids.range_field.text:
|
||||
default_cmds["episodes_range"] = episodes_range
|
||||
|
||||
if quality:=self.ids.range_field.text:
|
||||
if quality := self.ids.range_field.text:
|
||||
default_cmds["quality"] = quality
|
||||
|
||||
# print(title,episodes_range,latest,quality)
|
||||
app.download_anime(self.anime_id,default_cmds)
|
||||
app.download_anime(self.anime_id, default_cmds)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<AnimeHeader>:
|
||||
adaptive_height:True
|
||||
orientation: 'vertical'
|
||||
# padding:"10dp"
|
||||
MDBoxLayout:
|
||||
adaptive_height:True
|
||||
md_bg_color:self.theme_cls.secondaryContainerColor
|
||||
|
||||
@@ -6,4 +6,3 @@ from kivymd.uix.boxlayout import MDBoxLayout
|
||||
class AnimeHeader(MDBoxLayout):
|
||||
titles = StringProperty()
|
||||
banner_image = StringProperty()
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ from kivymd.uix.boxlayout import MDBoxLayout
|
||||
class RankingsBar(MDBoxLayout):
|
||||
rankings = DictProperty(
|
||||
{
|
||||
"Popularity":0,
|
||||
"Favourites":0,
|
||||
"AverageScore":0,
|
||||
"Popularity": 0,
|
||||
"Favourites": 0,
|
||||
"AverageScore": 0,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
from kivy.properties import ObjectProperty,ListProperty
|
||||
from kivy.properties import ObjectProperty, ListProperty
|
||||
from kivy.clock import Clock
|
||||
|
||||
from kivymd.uix.boxlayout import MDBoxLayout
|
||||
|
||||
|
||||
class AnimeReview(MDBoxLayout):
|
||||
review = ObjectProperty({
|
||||
"username":"",
|
||||
"avatar":"",
|
||||
"summary":""
|
||||
})
|
||||
review = ObjectProperty({"username": "", "avatar": "", "summary": ""})
|
||||
|
||||
|
||||
class AnimeReviews(MDBoxLayout):
|
||||
"""anime reviews"""
|
||||
|
||||
reviews = ListProperty()
|
||||
container = ObjectProperty()
|
||||
def on_reviews(self,instance,reviews):
|
||||
|
||||
def on_reviews(self, *args):
|
||||
Clock.schedule_once(lambda _: self.update_reviews_card(*args))
|
||||
|
||||
def update_reviews_card(self, instance, reviews):
|
||||
self.container.clear_widgets()
|
||||
for review in reviews:
|
||||
review_ = AnimeReview()
|
||||
review_.review = {
|
||||
"username":review["user"]["name"],
|
||||
"avatar":review["user"]["avatar"]["medium"],
|
||||
"summary":review["summary"]
|
||||
"username": review["user"]["name"],
|
||||
"avatar": review["user"]["avatar"]["medium"],
|
||||
"summary": review["summary"],
|
||||
}
|
||||
self.container.add_widget(review_)
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
spacing:"10dp"
|
||||
orientation: 'vertical'
|
||||
pos_hint: {'center_x': 0.5}
|
||||
|
||||
|
||||
<SideBarLabel>:
|
||||
adaptive_height:True
|
||||
max_lines:0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from kivy.properties import ObjectProperty,StringProperty,DictProperty,ListProperty
|
||||
from kivy.properties import ObjectProperty, StringProperty, DictProperty, ListProperty
|
||||
from kivy.utils import get_hex_from_color
|
||||
from kivy.factory import Factory
|
||||
|
||||
@@ -10,34 +10,42 @@ class HeaderLabel(MDBoxLayout):
|
||||
text = StringProperty()
|
||||
halign = StringProperty("center")
|
||||
|
||||
|
||||
Factory.register("HeaderLabel", HeaderLabel)
|
||||
|
||||
|
||||
class SideBarLabel(MDLabel):
|
||||
pass
|
||||
|
||||
|
||||
# TODO:Switch to using the kivy_markup_module
|
||||
class AnimeSideBar(MDBoxLayout):
|
||||
screen = ObjectProperty()
|
||||
image = StringProperty()
|
||||
alternative_titles = DictProperty({
|
||||
"synonyms":"",
|
||||
"english":"",
|
||||
"japanese":"",
|
||||
})
|
||||
information = DictProperty({
|
||||
"episodes":"",
|
||||
"status":"",
|
||||
"aired":"",
|
||||
"nextAiringEpisode":"",
|
||||
"premiered":"",
|
||||
"broadcast":"",
|
||||
"countryOfOrigin":"",
|
||||
"hashtag":"",
|
||||
"studios":"", # { "name": "Sunrise", "isAnimationStudio": true }
|
||||
"source":"",
|
||||
"genres":"",
|
||||
"duration":"",
|
||||
"producers":"",
|
||||
})
|
||||
alternative_titles = DictProperty(
|
||||
{
|
||||
"synonyms": "",
|
||||
"english": "",
|
||||
"japanese": "",
|
||||
}
|
||||
)
|
||||
information = DictProperty(
|
||||
{
|
||||
"episodes": "",
|
||||
"status": "",
|
||||
"aired": "",
|
||||
"nextAiringEpisode": "",
|
||||
"premiered": "",
|
||||
"broadcast": "",
|
||||
"countryOfOrigin": "",
|
||||
"hashtag": "",
|
||||
"studios": "", # { "name": "Sunrise", "isAnimationStudio": true }
|
||||
"source": "",
|
||||
"genres": "",
|
||||
"duration": "",
|
||||
"producers": "",
|
||||
}
|
||||
)
|
||||
statistics = ListProperty()
|
||||
statistics_container = ObjectProperty()
|
||||
external_links = ListProperty()
|
||||
@@ -45,7 +53,7 @@ class AnimeSideBar(MDBoxLayout):
|
||||
tags = ListProperty()
|
||||
tags_container = ObjectProperty()
|
||||
|
||||
def on_statistics(self,instance,value):
|
||||
def on_statistics(self, instance, value):
|
||||
self.statistics_container.clear_widgets()
|
||||
header = HeaderLabel()
|
||||
header.text = "Rankings"
|
||||
@@ -56,10 +64,11 @@ class AnimeSideBar(MDBoxLayout):
|
||||
label.text = "[color={}]{}:[/color] {}".format(
|
||||
get_hex_from_color(label.theme_cls.primaryColor),
|
||||
stat[0].capitalize(),
|
||||
f"{stat[1]}")
|
||||
f"{stat[1]}",
|
||||
)
|
||||
self.statistics_container.add_widget(label)
|
||||
|
||||
def on_tags(self,instance,value):
|
||||
def on_tags(self, instance, value):
|
||||
self.tags_container.clear_widgets()
|
||||
header = HeaderLabel()
|
||||
header.text = "Tags"
|
||||
@@ -69,11 +78,11 @@ class AnimeSideBar(MDBoxLayout):
|
||||
label.text = "[color={}]{}:[/color] {}".format(
|
||||
get_hex_from_color(label.theme_cls.primaryColor),
|
||||
tag[0].capitalize(),
|
||||
f"{tag[1]} %")
|
||||
f"{tag[1]} %",
|
||||
)
|
||||
self.tags_container.add_widget(label)
|
||||
|
||||
|
||||
def on_external_links(self,instance,value):
|
||||
def on_external_links(self, instance, value):
|
||||
self.external_links_container.clear_widgets()
|
||||
header = HeaderLabel()
|
||||
header.text = "External Links"
|
||||
@@ -84,5 +93,6 @@ class AnimeSideBar(MDBoxLayout):
|
||||
label.text = "[color={}]{}:[/color] {}".format(
|
||||
get_hex_from_color(label.theme_cls.primaryColor),
|
||||
site[0].capitalize(),
|
||||
site[1])
|
||||
site[1],
|
||||
)
|
||||
self.external_links_container.add_widget(label)
|
||||
|
||||
Reference in New Issue
Block a user