diff --git a/Src/Api/Altadefinizione/costant.py b/Src/Api/Altadefinizione/costant.py index 098e5fc..9b6c8b5 100644 --- a/Src/Api/Altadefinizione/costant.py +++ b/Src/Api/Altadefinizione/costant.py @@ -1,4 +1,11 @@ # 26.05.24 -MAIN_FOLDER = "altadefinizione" +# Internal utilities +from Src.Util._jsonConfig import config_manager + + +SITE_NAME = "altadefinizione" +ROOT_PATH = config_manager.get('DEFAULT', 'root_path') +DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) + MOVIE_FOLDER = "Movie" \ No newline at end of file diff --git a/Src/Api/Altadefinizione/film.py b/Src/Api/Altadefinizione/film.py index 5b6d1f8..d0cc4b7 100644 --- a/Src/Api/Altadefinizione/film.py +++ b/Src/Api/Altadefinizione/film.py @@ -7,7 +7,6 @@ import logging # Internal utilities from Src.Util.console import console -from Src.Util._jsonConfig import config_manager from Src.Lib.Hls.downloader import Downloader from Src.Util.message import start_message @@ -17,8 +16,7 @@ from .Core.Player.supervideo import VideoSource # Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -from .costant import MAIN_FOLDER, MOVIE_FOLDER +from .costant import ROOT_PATH, SITE_NAME, MOVIE_FOLDER # Variable @@ -45,7 +43,7 @@ def download_film(title_name: str, url: str): # Define output path mp4_name = str(title_name).replace("-", "_") + ".mp4" - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, MOVIE_FOLDER, title_name) + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, MOVIE_FOLDER, title_name) # Get m3u8 master playlist master_playlist = video_source.get_playlist() diff --git a/Src/Api/Altadefinizione/site.py b/Src/Api/Altadefinizione/site.py index 49b82d0..1ce41b6 100644 --- a/Src/Api/Altadefinizione/site.py +++ b/Src/Api/Altadefinizione/site.py @@ -13,7 +13,6 @@ from unidecode import unidecode # Internal utilities from Src.Util.table import TVShowManager from Src.Util.console import console -from Src.Util._jsonConfig import config_manager from Src.Util.headers import get_headers @@ -21,12 +20,8 @@ from Src.Util.headers import get_headers from .Core.Class.SearchType import MediaManager, MediaItem -# Config -SITE_NAME = "altadefinizione" -DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) - - # Variable +from .costant import SITE_NAME, DOMAIN_NOW media_search_manager = MediaManager() table_show_manager = TVShowManager() diff --git a/Src/Api/Animeunity/anime.py b/Src/Api/Animeunity/anime.py index 7b030c7..3d597ad 100644 --- a/Src/Api/Animeunity/anime.py +++ b/Src/Api/Animeunity/anime.py @@ -6,7 +6,6 @@ import logging # Internal utilities from Src.Util.console import console, msg -from Src.Util._jsonConfig import config_manager from Src.Lib.Hls.downloader import Downloader from Src.Util.message import start_message @@ -16,12 +15,8 @@ from .Core.Player.vixcloud import VideoSource from .Core.Util import manage_selection -# Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -from .costant import MAIN_FOLDER, SERIES_FOLDER, MOVIE_FOLDER - - # Variable +from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER, MOVIE_FOLDER video_source = VideoSource() @@ -50,9 +45,9 @@ def download_episode(index_select: int): mp4_path = None mp4_name = f"{index_select + 1}.mp4" if video_source.is_series: - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, SERIES_FOLDER, video_source.series_name) + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, SERIES_FOLDER, video_source.series_name) else: - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, MOVIE_FOLDER, video_source.series_name) + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, MOVIE_FOLDER, video_source.series_name) # Start downloading Downloader( diff --git a/Src/Api/Animeunity/costant.py b/Src/Api/Animeunity/costant.py index aaaae90..8587dd8 100644 --- a/Src/Api/Animeunity/costant.py +++ b/Src/Api/Animeunity/costant.py @@ -1,5 +1,12 @@ # 26.05.24 -MAIN_FOLDER = "animeunity" +# Internal utilities +from Src.Util._jsonConfig import config_manager + + +SITE_NAME = "animeunity" +ROOT_PATH = config_manager.get('DEFAULT', 'root_path') +DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) + SERIES_FOLDER= "Serie" MOVIE_FOLDER = "Movie" diff --git a/Src/Api/Ddlstreamitaly/costant.py b/Src/Api/Ddlstreamitaly/costant.py index 56de031..0cc185d 100644 --- a/Src/Api/Ddlstreamitaly/costant.py +++ b/Src/Api/Ddlstreamitaly/costant.py @@ -1,5 +1,12 @@ # 09.06.24 -MAIN_FOLDER = "ddlstreamitaly" +# Internal utilities +from Src.Util._jsonConfig import config_manager + + +SITE_NAME = "ddlstreamitaly" +ROOT_PATH = config_manager.get('DEFAULT', 'root_path') +DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) + MOVIE_FOLDER = "Movie" SERIES_FOLDER = "Serie" diff --git a/Src/Api/Ddlstreamitaly/series.py b/Src/Api/Ddlstreamitaly/series.py index 1ca295f..8903fdc 100644 --- a/Src/Api/Ddlstreamitaly/series.py +++ b/Src/Api/Ddlstreamitaly/series.py @@ -10,7 +10,6 @@ from urllib.parse import urlparse from Src.Util.color import Colors from Src.Util.console import console, msg from Src.Util.os import create_folder, can_create_file -from Src.Util._jsonConfig import config_manager from Src.Util.table import TVShowManager from Src.Util.message import start_message from Src.Lib.Hls.download_mp4 import MP4_downloader @@ -23,13 +22,9 @@ from .Core.Util.manage_ep import manage_selection, map_episode_title from .Core.Player.ddl import VideoSource -# Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') - - # Variable +from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER table_show_manager = TVShowManager() -from .costant import MAIN_FOLDER, SERIES_FOLDER video_source = VideoSource() @@ -51,7 +46,7 @@ def donwload_video(scape_info_serie: GetSerieInfo, index_episode_selected: int) # Define filename and path for the downloaded video mp4_name = f"{map_episode_title(scape_info_serie.tv_name, None, index_episode_selected, obj_episode.get('name'))}.mp4" - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, SERIES_FOLDER, scape_info_serie.tv_name) + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, SERIES_FOLDER, scape_info_serie.tv_name) # Check if can create file output create_folder(mp4_path) diff --git a/Src/Api/Ddlstreamitaly/site.py b/Src/Api/Ddlstreamitaly/site.py index b864fec..aabee59 100644 --- a/Src/Api/Ddlstreamitaly/site.py +++ b/Src/Api/Ddlstreamitaly/site.py @@ -20,12 +20,8 @@ from Src.Util.headers import get_headers from .Core.Class.SearchType import MediaManager, MediaItem -# Config -SITE_NAME = "ddlstreamitaly" -DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) - - # Variable +from .costant import DOMAIN_NOW cookie_index = config_manager.get_dict('REQUESTS', 'index') media_search_manager = MediaManager() table_show_manager = TVShowManager() diff --git a/Src/Api/Guardaserie/costant.py b/Src/Api/Guardaserie/costant.py index ab2d74c..cd7ffe1 100644 --- a/Src/Api/Guardaserie/costant.py +++ b/Src/Api/Guardaserie/costant.py @@ -1,4 +1,11 @@ # 09.06.24 -MAIN_FOLDER = "guardaserie" +# Internal utilities +from Src.Util._jsonConfig import config_manager + + +SITE_NAME = "guardaserie" +ROOT_PATH = config_manager.get('DEFAULT', 'root_path') +DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) + SERIES_FOLDER = "Serie" diff --git a/Src/Api/Guardaserie/series.py b/Src/Api/Guardaserie/series.py index aef0cb0..4f677ac 100644 --- a/Src/Api/Guardaserie/series.py +++ b/Src/Api/Guardaserie/series.py @@ -7,7 +7,6 @@ import logging # Internal utilities from Src.Util.console import console, msg -from Src.Util._jsonConfig import config_manager from Src.Util.table import TVShowManager from Src.Util.message import start_message from Src.Lib.Hls.downloader import Downloader @@ -20,12 +19,8 @@ from .Core.Util.manage_ep import manage_selection, map_episode_title from .Core.Player.supervideo import VideoSource -# Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -from .costant import MAIN_FOLDER, SERIES_FOLDER - - # Variable +from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER table_show_manager = TVShowManager() video_source = VideoSource() @@ -49,7 +44,7 @@ def donwload_video(scape_info_serie: GetSerieInfo, index_season_selected: int, i # Define filename and path for the downloaded video mp4_name = f"{map_episode_title(scape_info_serie.tv_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.mp4" - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, SERIES_FOLDER, scape_info_serie.tv_name, f"S{index_season_selected}") + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, SERIES_FOLDER, scape_info_serie.tv_name, f"S{index_season_selected}") # Setup video source video_source.setup(obj_episode.get('url')) diff --git a/Src/Api/Guardaserie/site.py b/Src/Api/Guardaserie/site.py index c3a435f..74c6e3b 100644 --- a/Src/Api/Guardaserie/site.py +++ b/Src/Api/Guardaserie/site.py @@ -1,9 +1,7 @@ # 09.06.24 -import os import sys import logging -from urllib.parse import urlparse # External libraries @@ -14,7 +12,6 @@ from bs4 import BeautifulSoup # Internal utilities from Src.Util.table import TVShowManager from Src.Util.console import console, msg -from Src.Util._jsonConfig import config_manager from Src.Util.headers import get_headers @@ -23,17 +20,11 @@ from .Core.Class.SearchType import MediaManager, MediaItem # Variable +from .costant import DOMAIN_NOW media_search_manager = MediaManager() table_show_manager = TVShowManager() -# Config -SITE_NAME = "guardaserie" -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) - - - def title_search(word_to_search) -> int: """ Search for titles based on a search query. diff --git a/Src/Api/Streamingcommunity/costant.py b/Src/Api/Streamingcommunity/costant.py index 8fce4c2..1743da0 100644 --- a/Src/Api/Streamingcommunity/costant.py +++ b/Src/Api/Streamingcommunity/costant.py @@ -1,5 +1,12 @@ # 26.05.24 -MAIN_FOLDER = "streamingcommunity" +# Internal utilities +from Src.Util._jsonConfig import config_manager + + +SITE_NAME = "streamingcommunity" +ROOT_PATH = config_manager.get('DEFAULT', 'root_path') +DOMAIN_NOW = config_manager.get('SITE', SITE_NAME) + MOVIE_FOLDER = "Movie" SERIES_FOLDER = "Serie" \ No newline at end of file diff --git a/Src/Api/Streamingcommunity/film.py b/Src/Api/Streamingcommunity/film.py index b564649..95fdd19 100644 --- a/Src/Api/Streamingcommunity/film.py +++ b/Src/Api/Streamingcommunity/film.py @@ -1,13 +1,11 @@ # 3.12.23 import os -import sys import logging # Internal utilities from Src.Util.console import console -from Src.Util._jsonConfig import config_manager from Src.Lib.Hls.downloader import Downloader from Src.Util.message import start_message @@ -16,12 +14,8 @@ from Src.Util.message import start_message from .Core.Player.vixcloud import VideoSource -# Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -from .costant import MAIN_FOLDER, MOVIE_FOLDER - - # Variable +from .costant import ROOT_PATH, SITE_NAME, MOVIE_FOLDER video_source = VideoSource() @@ -53,7 +47,7 @@ def download_film(id_film: str, title_name: str, domain: str): # Define the filename and path for the downloaded film mp4_name = title_name.replace("-", "_") mp4_format = (mp4_name) + ".mp4" - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, MOVIE_FOLDER, title_name) + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, MOVIE_FOLDER, title_name) # Download the film using the m3u8 playlist, and output filename Downloader( diff --git a/Src/Api/Streamingcommunity/series.py b/Src/Api/Streamingcommunity/series.py index 460a7ea..6b69387 100644 --- a/Src/Api/Streamingcommunity/series.py +++ b/Src/Api/Streamingcommunity/series.py @@ -7,7 +7,6 @@ import logging # Internal utilities from Src.Util.console import console, msg -from Src.Util._jsonConfig import config_manager from Src.Util.table import TVShowManager from Src.Util.message import start_message from Src.Lib.Hls.downloader import Downloader @@ -18,12 +17,8 @@ from .Core.Player.vixcloud import VideoSource from .Core.Util import manage_selection, map_episode_title -# Config -ROOT_PATH = config_manager.get('DEFAULT', 'root_path') -from .costant import MAIN_FOLDER, SERIES_FOLDER - - # Variable +from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER video_source = VideoSource() table_show_manager = TVShowManager() @@ -47,7 +42,7 @@ def donwload_video(tv_name: str, index_season_selected: int, index_episode_selec # Define filename and path for the downloaded video mp4_name = f"{map_episode_title(tv_name, obj_episode, index_season_selected)}.mp4" - mp4_path = os.path.join(ROOT_PATH, MAIN_FOLDER, SERIES_FOLDER, tv_name, f"S{index_season_selected}") + mp4_path = os.path.join(ROOT_PATH, SITE_NAME, SERIES_FOLDER, tv_name, f"S{index_season_selected}") # Retrieve scws and if available master playlist video_source.get_iframe(obj_episode.id) diff --git a/update.py b/update.py new file mode 100644 index 0000000..96a4dcc --- /dev/null +++ b/update.py @@ -0,0 +1,67 @@ +# 01.03.2023 + +import os +import time + + +# Internal utilities +from Src.Upload.version import __version__ +from Src.Util.console import console + + +# External library +import httpx + + +# Variable +repo_name = "StreamingCommunity" +repo_user = "Lovi-0" +main = os.path.abspath(os.path.dirname(__file__)) + + +def update(): + """ + Check for updates on GitHub and display relevant information. + """ + + console.print("[green]Checking GitHub version [white]...") + + # Make the GitHub API requests and handle potential errors + try: + response_reposity = httpx.get(f"https://api.github.com/repos/{repo_user}/{repo_name}").json() + response_releases = httpx.get(f"https://api.github.com/repos/{repo_user}/{repo_name}/releases").json() + + except Exception as e: + console.print(f"[red]Error accessing GitHub API: {e}") + return + + # Get stargazers count from the repository + stargazers_count = response_reposity.get('stargazers_count', 0) + + # Calculate total download count from all releases + total_download_count = sum(asset['download_count'] for release in response_releases for asset in release.get('assets', [])) + + # Get latest version name + if response_releases: + last_version = response_releases[0].get('name', 'Unknown') + else: + last_version = 'Unknown' + + # Calculate percentual of stars based on download count + if total_download_count > 0 and stargazers_count > 0: + percentual_stars = round(stargazers_count / total_download_count * 100, 2) + else: + percentual_stars = 0 + + # Check installed version + if __version__ != last_version: + console.print(f"[red]New version available: [yellow]{last_version}") + else: + console.print(f"[red]Everything is up to date") + + console.print("\n") + console.print(f"[red]{repo_name} has been downloaded [yellow]{total_download_count} [red]times, but only [yellow]{percentual_stars}% [red]of users have starred it.\n\ + [cyan]Help the repository grow today by leaving a [yellow]star [cyan]and [yellow]sharing [cyan]it with others online!") + + time.sleep(1) + console.print("\n")