From 8e323e83f93cc32fb2dfaf0fff3c89f003f73d3a Mon Sep 17 00:00:00 2001 From: None <62809003+Arrowar@users.noreply.github.com> Date: Wed, 14 May 2025 09:34:30 +0200 Subject: [PATCH] Dev (#318) * Fix telegram bot (issues #305 bug) (#316) * fix create config.json * fix messagge telegram_bot option 0 (Streamingcommunity) * Update README.md * Update domain --------- Co-authored-by: GiuPic <47813665+GiuPic@users.noreply.github.com> --- README.md | 4 ++-- .../Api/Site/streamingcommunity/__init__.py | 16 +++++++++++++++- .../Api/Site/streamingcommunity/film.py | 2 +- .../Api/Site/streamingcommunity/series.py | 4 ++-- .../Api/Site/streamingcommunity/site.py | 4 ++-- StreamingCommunity/Util/config_json.py | 9 +++++++-- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 89337a1..f8235be 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ 📦 Installation - 🔄 [Update Domains](#update-domains) -- 🌐 [Available Sites](https://arrowar.github.io/StreamingDirectory/) +- 🌐 [Available Sites](https://arrowar.github.io/StreamingCommunity/) - 🛠️ [Installation](#installation) - 📦 [PyPI Installation](#1-pypi-installation) - 🔄 [Automatic Installation](#2-automatic-installation) @@ -799,4 +799,4 @@ Tool per guardare o scaricare film dalla piattaforma StreamingCommunity. # Disclaimer -This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. \ No newline at end of file +This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. diff --git a/StreamingCommunity/Api/Site/streamingcommunity/__init__.py b/StreamingCommunity/Api/Site/streamingcommunity/__init__.py index 6809642..160dbb6 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/__init__.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/__init__.py @@ -97,7 +97,21 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_ return if string_to_search is None: - string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip() + if site_constant.TELEGRAM_BOT: + bot = get_bot_instance() + string_to_search = bot.ask( + "key_search", + f"Enter the search term\nor type 'back' to return to the menu: ", + None + ) + + if string_to_search == 'back': + + # Restart the script + subprocess.Popen([sys.executable] + sys.argv) + sys.exit() + else: + string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip() # Search on database len_database = title_search(string_to_search) diff --git a/StreamingCommunity/Api/Site/streamingcommunity/film.py b/StreamingCommunity/Api/Site/streamingcommunity/film.py index 7e129f2..d70b162 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/film.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/film.py @@ -55,7 +55,7 @@ def download_film(select_title: MediaItem) -> str: console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n") # Init class - video_source = VideoSource(site_constant.FULL_URL, False, select_title.id) + video_source = VideoSource(f"{site_constant.FULL_URL}/it", False, select_title.id) # Retrieve scws and if available master playlist video_source.get_iframe(select_title.id) diff --git a/StreamingCommunity/Api/Site/streamingcommunity/series.py b/StreamingCommunity/Api/Site/streamingcommunity/series.py index 5b0aa00..1565e3b 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/series.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/series.py @@ -154,8 +154,8 @@ def download_series(select_season: MediaItem, season_selection: str = None, epis start_message() # Init class - video_source = VideoSource(site_constant.FULL_URL, True, select_season.id) - scrape_serie = GetSerieInfo(site_constant.FULL_URL, select_season.id, select_season.slug) + video_source = VideoSource(f"{site_constant.FULL_URL}/it", True, select_season.id) + scrape_serie = GetSerieInfo(f"{site_constant.FULL_URL}/it", select_season.id, select_season.slug) # Collect information about season scrape_serie.getNumberSeason() diff --git a/StreamingCommunity/Api/Site/streamingcommunity/site.py b/StreamingCommunity/Api/Site/streamingcommunity/site.py index 1b887cb..4f22d80 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/site.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/site.py @@ -46,7 +46,7 @@ def title_search(query: str) -> int: try: response = httpx.get( - site_constant.FULL_URL, + f"{site_constant.FULL_URL}/it", headers={'user-agent': get_userAgent()}, timeout=max_timeout ) @@ -59,7 +59,7 @@ def title_search(query: str) -> int: console.print(f"[red]Site: {site_constant.SITE_NAME} version, request error: {e}") return 0 - search_url = f"{site_constant.FULL_URL}/search?q={query}" + search_url = f"{site_constant.FULL_URL}/it/search?q={query}" console.print(f"[cyan]Search url: [yellow]{search_url}") try: diff --git a/StreamingCommunity/Util/config_json.py b/StreamingCommunity/Util/config_json.py index 9bee73e..bea1edc 100644 --- a/StreamingCommunity/Util/config_json.py +++ b/StreamingCommunity/Util/config_json.py @@ -36,8 +36,13 @@ class ConfigManager: base_path = os.path.dirname(sys.executable) else: - # Use the current directory where the script is executed - base_path = os.getcwd() + + # Get the actual path of the module file + current_file_path = os.path.abspath(__file__) + # Navigate upwards to find the project root + # Assuming this file is in a package structure like StreamingCommunity/Util/config_json.py + # We need to go up 2 levels to reach the project root + base_path = os.path.dirname(os.path.dirname(os.path.dirname(current_file_path))) # Initialize file paths self.file_path = os.path.join(base_path, file_name)