mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
feat(config file): implement configuration settings
This commit is contained in:
parent
1ead333e37
commit
d472787278
@ -3,6 +3,7 @@
|
|||||||
# Class import
|
# Class import
|
||||||
from Src.Util.headers import get_headers
|
from Src.Util.headers import get_headers
|
||||||
from Src.Util.console import console
|
from Src.Util.console import console
|
||||||
|
from Src.Util.config import config
|
||||||
from Src.Lib.FFmpeg.my_m3u8 import download_m3u8
|
from Src.Lib.FFmpeg.my_m3u8 import download_m3u8
|
||||||
|
|
||||||
# General import
|
# General import
|
||||||
@ -96,7 +97,7 @@ def main_dw_film(id_film, title_name, domain):
|
|||||||
|
|
||||||
mp4_name = title_name.replace("+", " ").replace(",", "").replace("-", "_")
|
mp4_name = title_name.replace("+", " ").replace(",", "").replace("-", "_")
|
||||||
mp4_format = mp4_name + ".mp4"
|
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)
|
m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, title_name, token_render)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# Class import
|
# Class import
|
||||||
from Src.Util.headers import get_headers
|
from Src.Util.headers import get_headers
|
||||||
from Src.Util.console import console, msg
|
from Src.Util.console import console, msg
|
||||||
|
from Src.Util.config import config
|
||||||
from Src.Lib.FFmpeg.my_m3u8 import download_m3u8
|
from Src.Lib.FFmpeg.my_m3u8 import download_m3u8
|
||||||
|
|
||||||
# General import
|
# 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_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_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)
|
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:
|
for ep in eps:
|
||||||
console.print(f"[green]Episode: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
|
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 []
|
# Download range []
|
||||||
if "[" in index_ep_select:
|
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
|
index_ep_select = int(index_ep_select) - 1
|
||||||
dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select)
|
dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_select)
|
||||||
else:
|
else:
|
||||||
console.print("[red]Wrong INDEX for the selected Episode")
|
console.print("[red]Wrong [yellow]INDEX [red]for the selected Episode")
|
||||||
|
|
||||||
# Download all
|
# Download all
|
||||||
else:
|
else:
|
||||||
@ -196,7 +198,7 @@ def main_dw_tv(tv_id, tv_name, version, domain):
|
|||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
console.print("[red]Wrong INDEX for the selected Season")
|
console.print("[red]Wrong [yellow]INDEX for the selected Season")
|
||||||
else:
|
else:
|
||||||
for n_season in range(1, num_season_find+1):
|
for n_season in range(1, num_season_find+1):
|
||||||
eps = get_info_season(tv_id, tv_name, domain, version, token, n_season)
|
eps = get_info_season(tv_id, tv_name, domain, version, token, n_season)
|
||||||
|
10
Src/Util/config.py
Normal file
10
Src/Util/config.py
Normal file
@ -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)
|
7
config.json
Normal file
7
config.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"root_path": "videos",
|
||||||
|
"film_folder_name": "Film",
|
||||||
|
"series_folder_name": "Serie",
|
||||||
|
"download_subtitles": false,
|
||||||
|
"convert_to_mp4": true
|
||||||
|
}
|
6
run.py
6
run.py
@ -36,17 +36,17 @@ def main():
|
|||||||
initialize()
|
initialize()
|
||||||
domain, site_version = Page.domain_version()
|
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)
|
db_title = Page.search(film_search, domain)
|
||||||
Page.display_search_results(db_title)
|
Page.display_search_results(db_title)
|
||||||
|
|
||||||
if len(db_title) != 0:
|
if len(db_title) != 0:
|
||||||
console.print(f"\n[blue]Total result: {len(db_title)}")
|
console.print(f"\n[blue]Total result: {len(db_title)}")
|
||||||
console.print(
|
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")
|
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():
|
if index_select.isnumeric():
|
||||||
index_select = int(index_select)
|
index_select = int(index_select)
|
||||||
if 0 <= index_select <= len(db_title) - 1:
|
if 0 <= index_select <= len(db_title) - 1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user