From 1ead333e379e9a2fcf849b343b9722028f4f2b73 Mon Sep 17 00:00:00 2001 From: Cohvir <63691557+Cohvir@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:18:50 +0100 Subject: [PATCH] style: correct some user messages and typos --- .idea/.gitignore | 8 ++++ .idea/StreamingCommunity_api.iml | 14 +++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ Src/Api/film.py | 6 +-- Src/Api/page.py | 2 +- Src/Api/tv.py | 20 +++++----- Src/Lib/FFmpeg/installer.py | 2 +- Src/Lib/FFmpeg/my_m3u8.py | 38 +++++++++---------- Src/Upload/update.py | 6 +-- run.py | 28 +++++++------- update.py | 2 +- 13 files changed, 94 insertions(+), 52 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/StreamingCommunity_api.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/StreamingCommunity_api.iml b/.idea/StreamingCommunity_api.iml new file mode 100644 index 0000000..8e5446a --- /dev/null +++ b/.idea/StreamingCommunity_api.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b0ca488 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Src/Api/film.py b/Src/Api/film.py index 7820d89..080469e 100644 --- a/Src/Api/film.py +++ b/Src/Api/film.py @@ -22,7 +22,7 @@ def get_iframe(id_title, domain): try: return BeautifulSoup(req_embed, "lxml").find("body").find("script").text except: - console.log("[red]Cant play this video, (video not available)") + console.log("[red]Couldn't play this video file (video not available)") sys.exit(0) else: @@ -89,7 +89,7 @@ def main_dw_film(id_film, title_name, domain): json_win_video, json_win_param, render_quality = parse_content(embed_content) token_render = f"token{render_quality}" - console.print(f"[blue]Quality select => [red]{render_quality}") + console.print(f"[blue]Selected quality => [red]{render_quality}") m3u8_url = get_m3u8_url(json_win_video, json_win_param, render_quality) m3u8_key = get_m3u8_key(json_win_video, json_win_param, title_name, token_render) @@ -101,6 +101,6 @@ def main_dw_film(id_film, title_name, domain): m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, title_name, token_render) if m3u8_url_audio != None: - console.print("[blue]Use m3u8 audio => [red]True") + console.print("[blue]Using m3u8 audio => [red]True") download_m3u8(m3u8_index=m3u8_url, m3u8_audio=m3u8_url_audio, m3u8_subtitle=m3u8_url, key=m3u8_key, output_filename=mp4_path) diff --git a/Src/Api/page.py b/Src/Api/page.py index c060beb..700b5fa 100644 --- a/Src/Api/page.py +++ b/Src/Api/page.py @@ -26,7 +26,7 @@ def domain_version(): return domain, version except Exception as e: - console.log("[red]Cant get version, problem with domain. Try again.") + console.log("[red]Couldn't get the version, there's a problem with the domain. Try again.") sys.exit(0) diff --git a/Src/Api/tv.py b/Src/Api/tv.py index 3848662..97d5d8a 100644 --- a/Src/Api/tv.py +++ b/Src/Api/tv.py @@ -125,12 +125,12 @@ def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_sel enccoded_name = urllib.parse.quote(eps[index_ep_select]['name']) - console.print(f"[green]Download ep: [blue]{eps[index_ep_select]['n']} [green]=> [purple]{eps[index_ep_select]['name']}") + console.print(f"[green]Downloading episode: [blue]{eps[index_ep_select]['n']} [green]=> [purple]{eps[index_ep_select]['name']}") embed_content = get_iframe(tv_id, eps[index_ep_select]['id'], domain, token) json_win_video, json_win_param, render_quality = parse_content(embed_content) token_render = f"token{render_quality}" - console.print(f"[blue]Quality select => [red]{render_quality}") + console.print(f"[blue]Selected quality => [red]{render_quality}") m3u8_playlist = get_playlist(json_win_video, json_win_param, render_quality) m3u8_url = get_m3u8_url(json_win_video, json_win_param, render_quality) @@ -143,7 +143,7 @@ def dw_single_ep(tv_id, eps, index_ep_select, domain, token, tv_name, season_sel m3u8_url_audio = get_m3u8_playlist(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, enccoded_name, token_render) if m3u8_url_audio != None: - console.print("[blue]Use m3u8 audio => [red]True") + console.print("[blue]Using m3u8 audio => [red]True") download_m3u8(m3u8_index=m3u8_url, m3u8_audio=m3u8_url_audio, m3u8_subtitle=m3u8_playlist, key=m3u8_key, output_filename=mp4_path) @@ -152,9 +152,9 @@ def main_dw_tv(tv_id, tv_name, version, domain): token = get_token(tv_id, domain) num_season_find = get_info_tv(tv_id, tv_name, version, domain) - console.print("\n[green]Insert season [red]number [yellow]or [red](*) [green]to download all seasons [yellow]or [red][1-2] [green]for a range of season") - console.print(f"\n[blue]Season find: [red]{num_season_find}") - season_select = str(msg.ask("\n[green]Insert season number: ")) + console.print("\n[green]Insert season [red]number [yellow]or [red](*) [green]to download all seasons [yellow]or [red][1-2] [green]for a range of seasons") + console.print(f"\n[blue]Season(s) found: [red]{num_season_find}") + season_select = str(msg.ask("\n[green]Insert season(s) number: ")) if "[" in season_select: start, end = map(int, season_select[1:-1].split('-')) result = list(range(start, end + 1)) @@ -169,8 +169,8 @@ def main_dw_tv(tv_id, tv_name, version, domain): eps = get_info_season(tv_id, tv_name, domain, version, token, season_select) for ep in eps: - console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}") - index_ep_select = str(msg.ask("\n[green]Insert ep [red]number [yellow]or [red](*) [green]to download all ep [yellow]or [red][1-2] [green]for a range of ep: ")) + 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: ")) # Download range [] if "[" in index_ep_select: @@ -187,7 +187,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 ep") + console.print("[red]Wrong INDEX for the selected Episode") # Download all else: @@ -196,7 +196,7 @@ def main_dw_tv(tv_id, tv_name, version, domain): print("\n") else: - console.print("[red]Wrong index for season") + console.print("[red]Wrong 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/Lib/FFmpeg/installer.py b/Src/Lib/FFmpeg/installer.py index 725d5d8..9e2820c 100644 --- a/Src/Lib/FFmpeg/installer.py +++ b/Src/Lib/FFmpeg/installer.py @@ -55,7 +55,7 @@ def check_ffmpeg(): console.print("[cyan]FFmpeg is not in the PATH. Downloading and adding to the PATH...[/cyan]") if not isAdmin(): - console.log("[red]You need to be admin to proceed!") + console.log("[red]You need admin privileges to proceed!") sys.exit(0) download_ffmpeg() diff --git a/Src/Lib/FFmpeg/my_m3u8.py b/Src/Lib/FFmpeg/my_m3u8.py index d493b98..0a7793a 100644 --- a/Src/Lib/FFmpeg/my_m3u8.py +++ b/Src/Lib/FFmpeg/my_m3u8.py @@ -20,7 +20,7 @@ warnings.filterwarnings("ignore", category=UserWarning, module="cryptography") # Variable MAX_WORKER = 20 -DONWLOAD_SUB = True +DOWNLOAD_SUB = True DOWNLOAD_DEFAULT_LANGUAGE = False failed_segments = [] @@ -107,7 +107,7 @@ class M3U8_Parser: if self.video_playlist: return self.video_playlist[0].get('uri') else: - print("No video playlist find") + print("No video playlist found") return None def download_subtitle(self): @@ -123,7 +123,7 @@ class M3U8_Parser: continue os.makedirs(path, exist_ok=True) - console.log(f"[green]Download subtitle: [red]{name_language}") + console.log(f"[green]Downloading subtitle: [red]{name_language}") req_sub_content = requests.get(sub_info.get("uri")) sub_parse = M3U8_Parser() @@ -133,13 +133,13 @@ class M3U8_Parser: open(os.path.join(path, name_language + ".vtt"), "wb").write(requests.get(url_subititle).content) else: - console.log("[red]No subtitle find") + console.log("[red]No subtitle found") def get_track_audio(self, language_name): # Ex. English """Return url of audio eng audio playlist if present""" if self.audio_ts: - console.log(f"[cyan]Find {len(self.audio_ts)}, playlist with audio") + console.log(f"[cyan]Found {len(self.audio_ts)}, playlist with audio") if language_name != None: for obj_audio in self.audio_ts: @@ -149,7 +149,7 @@ class M3U8_Parser: return None else: - console.log("[red]Cant find playlist with audio") + console.log("[red]Couldn't find any playlist with audio") class M3U8_Segments: def __init__(self, url, key=None): @@ -187,7 +187,7 @@ class M3U8_Segments: #console.log(f"[red]Ts segments find [white]=> [yellow]{len(self.segments)}") if len(self.segments) == 0: - console.log("[red]Cant find segments to donwload, retry") + console.log("[red]Couldn't find any segments to download, retry") sys.exit(0) else: @@ -316,7 +316,7 @@ class M3U8_Segments: ts_files.sort(key=extract_number) if len(ts_files) == 0: - console.log("[red]Cant find segments to join, retry") + console.log("[red]Couldn't find any segments to join, retry") sys.exit(0) @@ -325,7 +325,7 @@ class M3U8_Segments: relative_path = os.path.relpath(os.path.join(self.temp_folder, ts_file), current_dir) f.write(f"file '{relative_path}'\n") - console.log("[cyan]Start join all file") + console.log("[cyan]Joining all files...") try: ffmpeg.input(file_list_path, format='concat', safe=0).output(output_filename, c='copy', loglevel='error').run() except ffmpeg.Error as e: @@ -411,7 +411,7 @@ def download_subtitle(url, name_language): path = os.path.join("videos", "subtitle") os.makedirs(path, exist_ok=True) - console.log(f"[green]Download subtitle: [red]{name_language}") + console.log(f"[green]Downloading subtitle: [red]{name_language}") open(os.path.join(path, name_language + ".vtt"), "wb").write(requests.get(url).content) def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_subtitle=None, key=None, output_filename=os.path.join("videos", "output.mp4"), log=False): @@ -420,7 +420,7 @@ def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_s key = bytes.fromhex(key) if key is not None else key if m3u8_playlist != None: - console.log(f"[green]Dowload m3u8 from playlist") + console.log(f"[green]Downloading m3u8 from playlist") # Parse m3u8 playlist parse_class_m3u8 = M3U8_Parser() @@ -432,24 +432,24 @@ def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_s parse_class_m3u8.parse_data(m3u8_playlist) - # Get italian language in present as defualt + # Get italian language if present as default if DOWNLOAD_DEFAULT_LANGUAGE: m3u8_audio = parse_class_m3u8.get_track_audio("Italian") - console.log(f"[green]Select language => [purple]{m3u8_audio}") + console.log(f"[green]Selected language => [purple]{m3u8_audio}") # Get best quality if m3u8_index == None: m3u8_index = parse_class_m3u8.get_best_quality() if "https" in m3u8_index: - if log: console.log(f"[green]Select m3u8 index => [purple]{m3u8_index}") + if log: console.log(f"[green]Selected m3u8 index => [purple]{m3u8_index}") else: - console.log("[red]Cant find a valid m3u8 index") + console.log("[red]Couldn't find a valid m3u8 index") sys.exit(0) - # Download subtitle if present ( normaly in m3u8 playlist ) - if DONWLOAD_SUB: + # Download subtitle if present ( normally in m3u8 playlist ) + if DOWNLOAD_SUB: parse_class_m3u8.download_subtitle() if m3u8_subtitle != None: @@ -463,7 +463,7 @@ def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_s parse_class_m3u8_sub.parse_data(m3u8_subtitle) # Download subtitle if present ( normaly in m3u8 playlist ) - if DONWLOAD_SUB: + if DOWNLOAD_SUB: parse_class_m3u8_sub.download_subtitle() @@ -473,5 +473,5 @@ def download_m3u8(m3u8_playlist=None, m3u8_index = None, m3u8_audio=None, m3u8_s os.makedirs(path, exist_ok=True) if log: - console.log(f"[green]Dowload m3u8 from index [white]=> [purple]{m3u8_index}") + console.log(f"[green]Download m3u8 from index [white]=> [purple]{m3u8_index}") M3U8_Downloader(m3u8_index, m3u8_audio, key=key, output_filename=output_filename).start() \ No newline at end of file diff --git a/Src/Upload/update.py b/Src/Upload/update.py index d256b69..2ee1478 100644 --- a/Src/Upload/update.py +++ b/Src/Upload/update.py @@ -34,11 +34,11 @@ def main_update(): if get_install_version() != last_version: console.print(f"[red]=> A new version is available: [green]{json['zipball_url']}") - console.print(f"[red]=> Versione: [yellow]{json['name']}") + console.print(f"[red]=> New Version: [yellow]{json['name']}") else: - console.print(f"[red]=> Everything up to date") - console.print(f"[red]=> Last version: [yellow]{json['name']}") + console.print(f"[red]=> Everything is up to date") + console.print(f"[red]=> Latest version: [yellow]{json['name']}") print("\n") diff --git a/run.py b/run.py index b4549eb..237fbba 100644 --- a/run.py +++ b/run.py @@ -36,30 +36,30 @@ def main(): initialize() domain, site_version = Page.domain_version() - film_search = msg.ask("\n[blue]Insert word to search in all site: ").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 [yellow]or [red][1,3,5] [green]to select discontinued movie/tv" + "\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" ) - console.print("\n[red]In case of tv show you will have to choose season and episode to download") - index_select = str(msg.ask("\n[blue]Index 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: ")) if index_select.isnumeric(): index_select = int(index_select) if 0 <= index_select <= len(db_title) - 1: selected_title = db_title[index_select] if selected_title['type'] == "movie": - console.print(f"[green]\nMovie select: {selected_title['name']}") + console.print(f"[green]\nSelected Movie: {selected_title['name']}") download_film(selected_title['id'], selected_title['slug'], domain) else: - console.print(f"[green]\nTv select: {selected_title['name']}") + console.print(f"[green]\nSelected TV Series: {selected_title['name']}") download_tv(selected_title['id'], selected_title['slug'], site_version, domain) else: - console.print("[red]Wrong index for selection") + console.print("[red]Wrong INDEX for selection") elif "[" in index_select: if "-" in index_select: start, end = map(int, index_select[1:-1].split('-')) @@ -67,27 +67,27 @@ def main(): for n in result: selected_title = db_title[n] if selected_title['type'] == "movie": - console.print(f"[green]\nMovie select: {selected_title['name']}") + console.print(f"[green]\nSelected Movie: {selected_title['name']}") download_film(selected_title['id'], selected_title['slug'], domain) else: - console.print(f"[green]\nTv select: {selected_title['name']}") + console.print(f"[green]\nSelected TV Series: {selected_title['name']}") download_tv(selected_title['id'], selected_title['slug'], site_version, domain) elif "," in index_select: result = list(map(int, index_select[1:-1].split(','))) for n in result: selected_title = db_title[n] if selected_title['type'] == "movie": - console.print(f"[green]\nMovie select: {selected_title['name']}") + console.print(f"[green]\nSelected Movie: {selected_title['name']}") download_film(selected_title['id'], selected_title['slug'], domain) else: - console.print(f"[green]\nTv select: {selected_title['name']}") + console.print(f"[green]\nSelected TV Series: {selected_title['name']}") download_tv(selected_title['id'], selected_title['slug'], site_version, domain) else: - console.print("[red]Wrong index for selection") + console.print("[red]Wrong INDEX for selection") else: - console.print("[red]Cant find a single element") + console.print("[red]Couldn't find any entries for the selected title") - console.print("[red]Done") + console.print("[red]Done!") if __name__ == '__main__': main() diff --git a/update.py b/update.py index 0fed552..455ef57 100644 --- a/update.py +++ b/update.py @@ -66,7 +66,7 @@ def download_and_extract_latest_commit(author, repo_name): temp_path = os.path.join(os.path.dirname(os.getcwd()), 'temp_extracted') with ZipFile(BytesIO(response.content)) as zip_ref: zip_ref.extractall(temp_path) - console.log("[green]Extract file ...") + console.log("[green]Extracting file ...") # Move files from the temporary folder to the current folder