diff --git a/app/Utility/animdl_config_manager.py b/app/Utility/animdl_config_manager.py index be14005..cc1601f 100644 --- a/app/Utility/animdl_config_manager.py +++ b/app/Utility/animdl_config_manager.py @@ -10,6 +10,7 @@ class AnimdlConfig(TypedDict): default_provider: str quality_string: str +print(os.getenv("LOCALAPPDATA")) user_profile_path = plyer.storagepath.get_home_dir() # type: ignore animdl_config_folder_location = os.path.join(user_profile_path, ".animdl") diff --git a/app/View/AnimeScreen/components/controls.kv b/app/View/AnimeScreen/components/controls.kv index 2b04282..4a10c8d 100644 --- a/app/View/AnimeScreen/components/controls.kv +++ b/app/View/AnimeScreen/components/controls.kv @@ -22,7 +22,7 @@ MDButtonText: text:"Watch on mpv" MDButton: - on_press: app.watch_on_allanime(root.screen.data["title"]["romaji"]) + on_press: app.watch_on_allanime(root.screen.data["title"]["romaji"]) if root.screen.data["title"]["romaji"] else app.watch_on_allanime(root.screen.data["title"]["english"]) MDButtonText: text:"Watch on AllAnime" MDButton: diff --git a/app/animdl_config_panel.json b/app/animdl_config_panel.json index 36f1187..77c78cc 100644 --- a/app/animdl_config_panel.json +++ b/app/animdl_config_panel.json @@ -11,15 +11,15 @@ "key": "default_provider", "options": [ "9anime", - "AllAnime", - "AnimePahe", - "AnimeOut", - "Animtime", - "Kawaifu", - "GoGoAnime", - "Haho", - "Marin", - "Zoro" + "allanime", + "animepahe", + "animeout", + "animtime", + "kawaifu", + "gogoanime", + "haho", + "marin", + "zoro" ] }, { diff --git a/app/libs/animdl/animdl_api.py b/app/libs/animdl/animdl_api.py index 95f0f0a..99a1f25 100644 --- a/app/libs/animdl/animdl_api.py +++ b/app/libs/animdl/animdl_api.py @@ -128,7 +128,7 @@ class AnimdlApi: return most_likely_anime_url_and_title # ("title","anime url") else: raise AnimdlAnimeUrlNotFoundException( - "The anime your searching for doesnt exist or animdl is broken or not in your system path" + "The anime your searching for doesnt exist or animdl provider is broken or animdl not in your system path\nTry changing the default provider" ) @classmethod @@ -201,10 +201,7 @@ class AnimdlApi: Logger.info( f"Animdl Api Mpv Streamer: Failed to stream episode {episode['episode']} no valid streams" ) - else: - Logger.info( - f"Animdl Api Mpv Streamer: Failed to stream {title} no valid streams found for alll episdes" - ) + yield f"Epiosde {episode['episode']} doesnt have any valid stream links" @classmethod def get_all_anime_stream_urls_by_anime_url( diff --git a/app/main.py b/app/main.py index d6f465f..66113bd 100644 --- a/app/main.py +++ b/app/main.py @@ -290,31 +290,34 @@ class AniXStreamApp(MDApp): ---------- title_: The anime title requested to be opened """ - if anime := AnimdlApi.get_anime_url_by_title(title_): - title, link = anime - parsed_link = f"https://allmanga.to/bangumi/{link.split('/')[-1]}" - else: - Logger.error( - f"AniXStream:Failed to open {title_} in browser on allanime site" - ) - show_notification( - "Failure", f"Failed to open {title_} in browser on allanime site" - ) - if webbrowser.open(parsed_link): - Logger.info( - f"AniXStream:Successfully opened {title} in browser allanime site" - ) - show_notification( - "Success", f"Successfully opened {title} in browser allanime site" - ) - else: - Logger.error( - f"AniXStream:Failed to open {title} in browser on allanime site" - ) - show_notification( - "Failure", f"Failed to open {title} in browser on allanime site" - ) - + try: + if anime := AnimdlApi.get_anime_url_by_title(title_): + title, link = anime + parsed_link = f"https://allmanga.to/bangumi/{link.split('/')[-1]}" + else: + Logger.error( + f"AniXStream:Failed to open {title_} in browser on allanime site" + ) + show_notification( + "Failure", f"Failed to open {title_} in browser on allanime site" + ) + if webbrowser.open(parsed_link): + Logger.info( + f"AniXStream:Successfully opened {title} in browser allanime site" + ) + show_notification( + "Success", f"Successfully opened {title} in browser allanime site" + ) + else: + Logger.error( + f"AniXStream:Failed to open {title} in browser on allanime site" + ) + show_notification( + "Failure", f"Failed to open {title} in browser on allanime site" + ) + except Exception as e: + show_notification("Something went wrong",f"{e}") + def stream_anime_with_custom_input_cmds(self, *cmds): self.animdl_streaming_subprocess = ( AnimdlApi._run_animdl_command_and_get_subprocess(["stream", *cmds]) @@ -335,14 +338,21 @@ class AniXStreamApp(MDApp): streams = AnimdlApi.stream_anime_with_mpv(title, episodes_range, quality) # TODO: End mpv child process properly for stream in streams: - self.animdl_streaming_subprocess = stream - for line in self.animdl_streaming_subprocess.stderr: # type: ignore - if self.stop_streaming: - if stream: - stream.terminate() - stream.kill() - del stream - return + try: + if isinstance(stream,str): + show_notification("Failed to stream current episode",f"{stream}") + continue + self.animdl_streaming_subprocess = stream + + for line in self.animdl_streaming_subprocess.stderr: # type: ignore + if self.stop_streaming: + if stream: + stream.terminate() + stream.kill() + del stream + return + except Exception as e: + show_notification("Something went wrong while streaming",f"{e}") def watch_on_animdl( self, diff --git a/app/temp/temp.py b/app/temp/temp.py index fb2731b..b25b4f1 100644 --- a/app/temp/temp.py +++ b/app/temp/temp.py @@ -1,84 +1,4 @@ -# # import plyer - -# # plyer.notification.notify(app_name="Aninforma",message="hello",title="Anime Update") # type: ignore - -# from kivy.properties import StringProperty -# from kivy.uix.widget import Widget -# def get_prop(): -# return StringProperty() - -# class app(Widget): -# def awe(self): -# self.prop = get_prop - -# def on_prop(self,value,instance): -# print( -import requests -from inspect import isgenerator -from typing import Generator - -def jo(): - - if False: - return {} - else: - def _f(): - for i in [1,2,3,4]: - yield i - return _f() - -# url = "https://upos-bstar1-mirrorakam.akamaized.net/iupxcodeboss/9v/lr/n230705er39jxogp0ap3b823gkkylr9v-1-261210110000.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1715806416&gen=playurlv2&os=akam&oi=2823883151&trid=cdad1de563c743629bdbef3a82d44df0i&mid=1715226141&platform=pc&upsig=02ff8e9f9060bc3437356a7cb6cc1ed1&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&hdnts=exp=1715806416~hmac=836a02ef21ecc1a02034d7d10083bdf97103df2a586d8ba6009d8521abd855ac&bvc=vod&nettype=0&orderid=0,1&logo=00000000&f=i_0_0" - -# url = "https://allanime.pro/apiak/sk.json?sub=dx-ep-LYKSutL2PaAjYyXWz_1_sub_English" - -# url = "https://upos-bstar1-mirrorakam.akamaized.net/iupxcodeboss/9v/lr/n230705er39jxogp0ap3b823gkkylr9v-1-2d1301000023.m4s?e=ig8euxZM2rNcNbdlhoNvNC8BqJIzNbfqXBvEqxTEto8BTrNvN0GvT90W5JZMkX_YN0MvXg8gNEV4NC8xNEV4N03eN0B5tZlqNxTEto8BTrNvNeZVuJ10Kj_g2UB02J0mN0B5tZlqNCNEto8BTrNvNC7MTX502C8f2jmMQJ6mqF2fka1mqx6gqj0eN0B599M=&uipk=5&nbs=1&deadline=1715806416&gen=playurlv2&os=akam&oi=2823883151&trid=cdad1de563c743629bdbef3a82d44df0i&mid=1715226141&platform=pc&upsig=419c3e929cd04770d08cb0eb8f95470d&uparams=e,uipk,nbs,deadline,gen,os,oi,trid,mid,platform&hdnts=exp=1715806416~hmac=93ee08fbb96878bc55af2ed52bf9d176d96d93656ff865d59ed817bb04ecdedc&bvc=vod&nettype=0&orderid=0,1&logo=00000000&f=i_0_0" - -url = "https://video.wixstatic.com/video/7ef2fd_c718a462da2b43c9b1cae21babfadf2c/480p/mp4/file.mp4" - -# r = requests.get(url) - - -# for cont in r.iter_content(chunk_size=8*1024): -# print(cont) -from subprocess import run,Popen,PIPE -import re -def download_with_mpv(url,output_path): - process = Popen(["mpv",url,f"--stream-dump={output_path}"],stderr=PIPE,text=True) - progress_regex = re.compile(r"\d+/\d+") # eg Dumping 2044776/125359745 - - for stream in process.stderr: - if matches:=progress_regex.findall(stream): - # current_bytes,total_bytes = [float(val) for val in matches[0].split("/")] - print(matches) - # print("percentage download: ",(current_bytes/total_bytes)*100,"%") - - else: - print("hmm") - - -def progress(stream): - buffer = b"" - for line in iter(lambda: stream.read(),b""): - # match = progress_regex.search(line) - # if match: - # progress = match.group(1) - buffer += line - if buffer: - yield line - print(f"Progress: {line}%") - -# from tqdm import tqdm - -# tqdm. - -from multiprocessing import Process -import time -pr = Process(target=lambda *_:print("io"),args=(url,"./vid.mp4")) -pr.start() - -time.sleep(5) -# print(r.content) -# print(r.headers) -# d = jo() -# h = {} -# print(isgenerator(d)) \ No newline at end of file +import plyer +plyer.facades.StoragePath.get() +p = plyer.storagepath.get_external_storage_dir() +print(p)