From 9c84eb665cd30a740154915bd0d5858c60ce3005 Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Fri, 28 Feb 2025 13:54:49 +0100 Subject: [PATCH] Bump v2.9.0. --- StreamingCommunity/Api/Site/cb01new/film.py | 8 ++--- .../Api/Site/guardaserie/series.py | 11 +++--- .../Api/Site/mostraguarda/film.py | 8 ++--- .../Api/Site/streamingcommunity/film.py | 8 ++--- .../Api/Site/streamingcommunity/series.py | 8 ++--- .../Lib/Downloader/HLS/downloader.py | 6 +++- StreamingCommunity/Lib/M3U8/parser.py | 34 +++++++++++++------ StreamingCommunity/Upload/version.py | 2 +- setup.py | 2 +- 9 files changed, 47 insertions(+), 40 deletions(-) diff --git a/StreamingCommunity/Api/Site/cb01new/film.py b/StreamingCommunity/Api/Site/cb01new/film.py index a197529..163a7e1 100644 --- a/StreamingCommunity/Api/Site/cb01new/film.py +++ b/StreamingCommunity/Api/Site/cb01new/film.py @@ -55,10 +55,8 @@ def download_film(select_title: MediaItem) -> str: output_path=os.path.join(mp4_path, title_name) ).start() - if "error" in r_proc.keys(): - try: - os.remove(r_proc['path']) - except: - pass + if r_proc['error'] is not None: + try: os.remove(r_proc['path']) + except: pass return r_proc['path'] \ No newline at end of file diff --git a/StreamingCommunity/Api/Site/guardaserie/series.py b/StreamingCommunity/Api/Site/guardaserie/series.py index aaf38e9..8905164 100644 --- a/StreamingCommunity/Api/Site/guardaserie/series.py +++ b/StreamingCommunity/Api/Site/guardaserie/series.py @@ -72,13 +72,10 @@ def download_video(index_season_selected: int, index_episode_selected: int, scap m3u8_url=master_playlist, output_path=os.path.join(mp4_path, mp4_name) ).start() - - - if "error" in r_proc.keys(): - try: - os.remove(r_proc['path']) - except: - pass + + if r_proc['error'] is not None: + try: os.remove(r_proc['path']) + except: pass return r_proc['path'], r_proc['stopped'] diff --git a/StreamingCommunity/Api/Site/mostraguarda/film.py b/StreamingCommunity/Api/Site/mostraguarda/film.py index d317837..03b4b6b 100644 --- a/StreamingCommunity/Api/Site/mostraguarda/film.py +++ b/StreamingCommunity/Api/Site/mostraguarda/film.py @@ -86,10 +86,8 @@ def download_film(movie_details: Json_film) -> str: output_path=os.path.join(mp4_path, title_name) ).start() - if "error" in r_proc.keys(): - try: - os.remove(r_proc['path']) - except: - pass + if r_proc['error'] is not None: + try: os.remove(r_proc['path']) + except: pass return r_proc['path'] \ No newline at end of file diff --git a/StreamingCommunity/Api/Site/streamingcommunity/film.py b/StreamingCommunity/Api/Site/streamingcommunity/film.py index ec6d1d1..9544e58 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/film.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/film.py @@ -80,10 +80,8 @@ def download_film(select_title: MediaItem) -> str: if script_id != "unknown": TelegramSession.deleteScriptId(script_id) - if "error" in r_proc.keys(): - try: - os.remove(r_proc['path']) - except: - pass + if r_proc['error'] is not None: + try: os.remove(r_proc['path']) + except: pass return r_proc['path'] \ No newline at end of file diff --git a/StreamingCommunity/Api/Site/streamingcommunity/series.py b/StreamingCommunity/Api/Site/streamingcommunity/series.py index 367a0f1..7e48a15 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/series.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/series.py @@ -86,11 +86,9 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra output_path=os.path.join(mp4_path, mp4_name) ).start() - if "error" in r_proc.keys(): - try: - os.remove(r_proc['path']) - except: - pass + if r_proc['error'] is not None: + try: os.remove(r_proc['path']) + except: pass return r_proc['path'], r_proc['stopped'] diff --git a/StreamingCommunity/Lib/Downloader/HLS/downloader.py b/StreamingCommunity/Lib/Downloader/HLS/downloader.py index c864851..e9b3707 100644 --- a/StreamingCommunity/Lib/Downloader/HLS/downloader.py +++ b/StreamingCommunity/Lib/Downloader/HLS/downloader.py @@ -429,7 +429,8 @@ class HLS_Downloader: 'path': self.path_manager.output_path, 'url': self.m3u8_url, 'is_master': False, - 'error': 'File already exists', + 'msg': 'File already exists', + 'error': None, 'stopped': False } if TELEGRAM_BOT: @@ -473,6 +474,8 @@ class HLS_Downloader: 'path': self.path_manager.output_path, 'url': self.m3u8_url, 'is_master': self.m3u8_manager.is_master, + 'msg': None, + 'error': None, 'stopped': download_stopped } @@ -485,6 +488,7 @@ class HLS_Downloader: 'path': None, 'url': self.m3u8_url, 'is_master': getattr(self.m3u8_manager, 'is_master', None), + 'msg': None, 'error': error_msg, 'stopped': False } diff --git a/StreamingCommunity/Lib/M3U8/parser.py b/StreamingCommunity/Lib/M3U8/parser.py index 55af46b..5d40e9b 100644 --- a/StreamingCommunity/Lib/M3U8/parser.py +++ b/StreamingCommunity/Lib/M3U8/parser.py @@ -503,25 +503,35 @@ class M3U8_Parser: except Exception as e: logging.error(f"Error parsing video info: {e}") - def __parse_encryption_keys__(self, m3u8_obj) -> None: + def __parse_encryption_keys__(self, obj) -> None: """ - Extracts encryption keys from the M3U8 object. + Extracts encryption keys either from the M3U8 object or from individual segments. Parameters: - - m3u8_obj: The M3U8 object containing encryption keys. + - obj: Either the main M3U8 object or an individual segment. """ try: - if m3u8_obj.key is not None: + if hasattr(obj, 'key') and obj.key is not None: + key_info = { + 'method': obj.key.method, + 'iv': obj.key.iv, + 'uri': obj.key.uri + } + if self.keys is None: - self.keys = { - 'method': m3u8_obj.key.method, - 'iv': m3u8_obj.key.iv, - 'uri': m3u8_obj.key.uri - } + self.keys = key_info + + """ + elif obj.key.uri not in self.keys: + if isinstance(self.keys, dict): + self.keys[obj.key.uri] = key_info + else: + old_key = self.keys + self.keys = {'default': old_key, obj.key.uri: key_info} + """ except Exception as e: logging.error(f"Error parsing encryption keys: {e}") - sys.exit(0) pass def __parse_subtitles_and_audio__(self, m3u8_obj) -> None: @@ -574,6 +584,10 @@ class M3U8_Parser: self.segments.append(segment.uri) else: self.subtitle.append(segment.uri) + + # Second check if there is key in main m3u8 obj + if self.keys is None: + self.__parse_encryption_keys__(m3u8_obj) except Exception as e: logging.error(f"Error parsing segments: {e}") diff --git a/StreamingCommunity/Upload/version.py b/StreamingCommunity/Upload/version.py index a3c0aa6..ccd8370 100644 --- a/StreamingCommunity/Upload/version.py +++ b/StreamingCommunity/Upload/version.py @@ -1,5 +1,5 @@ __title__ = 'StreamingCommunity' -__version__ = '2.8.0' +__version__ = '2.9.0' __author__ = 'Arrowar' __description__ = 'A command-line program to download film' __copyright__ = 'Copyright 2024' diff --git a/setup.py b/setup.py index f10bef3..9035c0d 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open("requirements.txt", "r", encoding="utf-8-sig") as f: setup( name="StreamingCommunity", - version="2.8.0", + version="2.9.0", long_description=read_readme(), long_description_content_type="text/markdown", author="Lovi-0",