diff --git a/Src/Api/film.py b/Src/Api/film.py index 080469e..4ec6a20 100644 --- a/Src/Api/film.py +++ b/Src/Api/film.py @@ -3,6 +3,7 @@ # Class import from Src.Util.headers import get_headers from Src.Util.console import console +from Src.Util.config import config from Src.Lib.FFmpeg.my_m3u8 import download_m3u8 # General import @@ -96,7 +97,7 @@ def main_dw_film(id_film, title_name, domain): mp4_name = title_name.replace("+", " ").replace(",", "").replace("-", "_") mp4_format = mp4_name + ".mp4" - mp4_path = os.path.join("videos", mp4_format) + mp4_path = os.path.join(config['root_path'], config['film_folder_name'], mp4_name, mp4_format) m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, title_name, token_render) diff --git a/Src/Api/tv.py b/Src/Api/tv.py index 97d5d8a..fb85b7c 100644 --- a/Src/Api/tv.py +++ b/Src/Api/tv.py @@ -3,6 +3,7 @@ # Class import from Src.Util.headers import get_headers from Src.Util.console import console, msg +from Src.Util.config import config from Src.Lib.FFmpeg.my_m3u8 import download_m3u8 # General import @@ -138,7 +139,8 @@ def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_sel mp4_name = f"{tv_name.replace('+', '_')}_S{str(season_select).zfill(2)}E{str(index_ep_select+1).zfill(2)}" mp4_format = f"{mp4_name}.mp4" - mp4_path = os.path.join("videos",tv_name, mp4_format) + season = mp4_name.rsplit("E", 1)[0] + mp4_path = os.path.join(config['root_path'], config['series_folder_name'], tv_name, season, mp4_format) m3u8_url_audio = get_m3u8_playlist(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, enccoded_name, token_render) @@ -170,7 +172,7 @@ def main_dw_tv(tv_id, tv_name, version, domain): for ep in eps: console.print(f"[green]Episode: [blue]{ep['n']} [green]=> [purple]{ep['name']}") - index_ep_select = str(msg.ask("\n[green]Insert episode [red]number [yellow]or [red](*) [green]to download all episodes [yellow]or [red][1-2] [green]for a range of episodes: ")) + index_ep_select = str(msg.ask("\n[green]Insert episode [yellow]number [green]or [red](*) [green]to download all episodes or [red][1-2] [green]for a range of episodes: ")) # Download range [] if "[" in index_ep_select: @@ -187,7 +189,7 @@ def main_dw_tv(tv_id, tv_name, version, domain): index_ep_select = int(index_ep_select) - 1 dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select) else: - console.print("[red]Wrong INDEX for the selected Episode") + console.print("[red]Wrong [yellow]INDEX [red]for the selected Episode") # Download all else: @@ -196,7 +198,7 @@ def main_dw_tv(tv_id, tv_name, version, domain): print("\n") else: - console.print("[red]Wrong INDEX for the selected Season") + console.print("[red]Wrong [yellow]INDEX for the selected Season") else: for n_season in range(1, num_season_find+1): eps = get_info_season(tv_id, tv_name, domain, version, token, n_season) diff --git a/Src/Util/config.py b/Src/Util/config.py new file mode 100644 index 0000000..1280b8c --- /dev/null +++ b/Src/Util/config.py @@ -0,0 +1,10 @@ +import json +from pathlib import Path + +def load_config(file_path): + with open(file_path, 'r') as file: + config_file = json.load(file) + return config_file + +config_path = Path(__file__).parent.parent.parent / 'config.json' # path for config.json (in root directory) +config = load_config(config_path) \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..9af2a3b --- /dev/null +++ b/config.json @@ -0,0 +1,7 @@ +{ + "root_path": "videos", + "film_folder_name": "Film", + "series_folder_name": "Serie", + "download_subtitles": false, + "convert_to_mp4": true +} \ No newline at end of file diff --git a/run.py b/run.py index 237fbba..9617d9c 100644 --- a/run.py +++ b/run.py @@ -36,17 +36,17 @@ def main(): initialize() domain, site_version = Page.domain_version() - film_search = msg.ask("\n[blue]Search for any movie or tv series title: ").strip() + film_search = msg.ask("\n[blue]Search for any movie or tv series title").strip() db_title = Page.search(film_search, domain) Page.display_search_results(db_title) if len(db_title) != 0: console.print(f"\n[blue]Total result: {len(db_title)}") console.print( - "\n[green]Insert INDEX [red]number [yellow]or [red][1-2] [green]for a range of movies/tv series [yellow]or [red][1,3,5] [green]to select discontinued movie/tv series" + "\n[green]Insert [yellow]INDEX [red]number [green]or [red][1-2] [green]for a range of movies/tv series or [red][1,3,5] [green]to select discontinued movie/tv series" ) console.print("\n[red]In case of a TV Series you will choose seasons and episodes to download") - index_select = str(msg.ask("\n[blue]Select INDEX to download: ")) + index_select = str(msg.ask("\n[blue]Select [yellow]INDEX [blue]to download")) if index_select.isnumeric(): index_select = int(index_select) if 0 <= index_select <= len(db_title) - 1: