From 389e7cec688933de014f3135cab7a6d7cc037cc6 Mon Sep 17 00:00:00 2001 From: Lovi-0 Date: Sat, 24 Aug 2024 17:04:02 +0200 Subject: [PATCH] Animeunity upgrade --- Src/Api/animeunity/Core/Player/vixcloud.py | 2 +- Src/Api/animeunity/anime.py | 26 ++++++++++++++-------- run.py | 8 +++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Src/Api/animeunity/Core/Player/vixcloud.py b/Src/Api/animeunity/Core/Player/vixcloud.py index 7b00ad5..0fbd153 100644 --- a/Src/Api/animeunity/Core/Player/vixcloud.py +++ b/Src/Api/animeunity/Core/Player/vixcloud.py @@ -119,10 +119,10 @@ class VideoSource: video_response = httpx.get(embed_url) video_response.raise_for_status() - # Parse response with BeautifulSoup to get content of the scriot soup = BeautifulSoup(video_response.text, "html.parser") script = soup.find("body").find("script").text + self.src_mp4 = soup.find("body").find_all("script")[1].text.split(" = ")[1].replace("'", "") return script diff --git a/Src/Api/animeunity/anime.py b/Src/Api/animeunity/anime.py index 6e7265a..7044f28 100644 --- a/Src/Api/animeunity/anime.py +++ b/Src/Api/animeunity/anime.py @@ -1,19 +1,21 @@ # 11.03.24 import os +import sys import logging # Internal utilities from Src.Util.console import console, msg -from Src.Lib.Downloader import HLS_Downloader from Src.Util.message import start_message -from ..Template import manage_selection +from Src.Util.os import create_folder, can_create_file +from Src.Lib.Downloader import MP4_downloader # Logic class -from .Core.Player.vixcloud import VideoSource +from ..Template import manage_selection from ..Template.Class.SearchType import MediaItem +from .Core.Player.vixcloud import VideoSource # Variable @@ -38,11 +40,11 @@ def download_episode(index_select: int): start_message() console.print(f"[yellow]Download: [red]EP_{obj_episode.number} \n") - # Get the embed URL for the episode - embed_url = video_source.get_embed(obj_episode.id) + # Get the js script from the episode + js_script = video_source.get_embed(obj_episode.id) # Parse parameter in embed text - video_source.parse_script(embed_url) + video_source.parse_script(js_script) # Create output path mp4_path = None @@ -52,10 +54,16 @@ def download_episode(index_select: int): else: mp4_path = os.path.join(ROOT_PATH, SITE_NAME, MOVIE_FOLDER, video_source.series_name) + # Check if can create file output + create_folder(mp4_path) + if not can_create_file(mp4_name): + logging.error("Invalid mp4 name.") + sys.exit(0) + # Start downloading - HLS_Downloader( - m3u8_playlist = video_source.get_playlist(), - output_filename = os.path.join(mp4_path, mp4_name) + MP4_downloader( + str(video_source.src_mp4).strip(), + os.path.join(mp4_path, mp4_name) ).start() else: diff --git a/run.py b/run.py index f88d1ee..82b5fd5 100644 --- a/run.py +++ b/run.py @@ -16,7 +16,7 @@ from Src.Util.message import start_message from Src.Util.console import console, msg from Src.Util._jsonConfig import config_manager from Src.Upload.update import update as git_update -from Src.Util.os import get_system_summary +from Src.Util.os import get_system_summary, create_folder from Src.Lib.TMBD.tmbd import tmdb from Src.Util.logger import Logger @@ -138,6 +138,10 @@ def initialize(): def main(): + # Create folder root path if not exist + folder_root_path = config_manager.get("DEFAULT", "root_path") + create_folder(folder_name=folder_root_path) + # Load search functions search_functions = load_search_functions() @@ -182,5 +186,5 @@ def main(): if __name__ == '__main__': - initialize() + #initialize() main() \ No newline at end of file