Better costnat for api.

This commit is contained in:
Lovi 2024-06-15 08:59:46 +02:00
parent 51d046de13
commit 0f919ba97b
15 changed files with 123 additions and 67 deletions

View File

@ -1,4 +1,11 @@
# 26.05.24 # 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" MOVIE_FOLDER = "Movie"

View File

@ -7,7 +7,6 @@ import logging
# Internal utilities # Internal utilities
from Src.Util.console import console from Src.Util.console import console
from Src.Util._jsonConfig import config_manager
from Src.Lib.Hls.downloader import Downloader from Src.Lib.Hls.downloader import Downloader
from Src.Util.message import start_message from Src.Util.message import start_message
@ -17,8 +16,7 @@ from .Core.Player.supervideo import VideoSource
# Config # Config
ROOT_PATH = config_manager.get('DEFAULT', 'root_path') from .costant import ROOT_PATH, SITE_NAME, MOVIE_FOLDER
from .costant import MAIN_FOLDER, MOVIE_FOLDER
# Variable # Variable
@ -45,7 +43,7 @@ def download_film(title_name: str, url: str):
# Define output path # Define output path
mp4_name = str(title_name).replace("-", "_") + ".mp4" 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 # Get m3u8 master playlist
master_playlist = video_source.get_playlist() master_playlist = video_source.get_playlist()

View File

@ -13,7 +13,6 @@ from unidecode import unidecode
# Internal utilities # Internal utilities
from Src.Util.table import TVShowManager from Src.Util.table import TVShowManager
from Src.Util.console import console from Src.Util.console import console
from Src.Util._jsonConfig import config_manager
from Src.Util.headers import get_headers 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 from .Core.Class.SearchType import MediaManager, MediaItem
# Config
SITE_NAME = "altadefinizione"
DOMAIN_NOW = config_manager.get('SITE', SITE_NAME)
# Variable # Variable
from .costant import SITE_NAME, DOMAIN_NOW
media_search_manager = MediaManager() media_search_manager = MediaManager()
table_show_manager = TVShowManager() table_show_manager = TVShowManager()

View File

@ -6,7 +6,6 @@ import logging
# Internal utilities # Internal utilities
from Src.Util.console import console, msg from Src.Util.console import console, msg
from Src.Util._jsonConfig import config_manager
from Src.Lib.Hls.downloader import Downloader from Src.Lib.Hls.downloader import Downloader
from Src.Util.message import start_message from Src.Util.message import start_message
@ -16,12 +15,8 @@ from .Core.Player.vixcloud import VideoSource
from .Core.Util import manage_selection 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 # Variable
from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER, MOVIE_FOLDER
video_source = VideoSource() video_source = VideoSource()
@ -50,9 +45,9 @@ def download_episode(index_select: int):
mp4_path = None mp4_path = None
mp4_name = f"{index_select + 1}.mp4" mp4_name = f"{index_select + 1}.mp4"
if video_source.is_series: 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: 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 # Start downloading
Downloader( Downloader(

View File

@ -1,5 +1,12 @@
# 26.05.24 # 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" SERIES_FOLDER= "Serie"
MOVIE_FOLDER = "Movie" MOVIE_FOLDER = "Movie"

View File

@ -1,5 +1,12 @@
# 09.06.24 # 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" MOVIE_FOLDER = "Movie"
SERIES_FOLDER = "Serie" SERIES_FOLDER = "Serie"

View File

@ -10,7 +10,6 @@ from urllib.parse import urlparse
from Src.Util.color import Colors from Src.Util.color import Colors
from Src.Util.console import console, msg from Src.Util.console import console, msg
from Src.Util.os import create_folder, can_create_file 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.table import TVShowManager
from Src.Util.message import start_message from Src.Util.message import start_message
from Src.Lib.Hls.download_mp4 import MP4_downloader 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 from .Core.Player.ddl import VideoSource
# Config
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
# Variable # Variable
from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER
table_show_manager = TVShowManager() table_show_manager = TVShowManager()
from .costant import MAIN_FOLDER, SERIES_FOLDER
video_source = VideoSource() 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 # 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_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 # Check if can create file output
create_folder(mp4_path) create_folder(mp4_path)

View File

@ -20,12 +20,8 @@ from Src.Util.headers import get_headers
from .Core.Class.SearchType import MediaManager, MediaItem from .Core.Class.SearchType import MediaManager, MediaItem
# Config
SITE_NAME = "ddlstreamitaly"
DOMAIN_NOW = config_manager.get('SITE', SITE_NAME)
# Variable # Variable
from .costant import DOMAIN_NOW
cookie_index = config_manager.get_dict('REQUESTS', 'index') cookie_index = config_manager.get_dict('REQUESTS', 'index')
media_search_manager = MediaManager() media_search_manager = MediaManager()
table_show_manager = TVShowManager() table_show_manager = TVShowManager()

View File

@ -1,4 +1,11 @@
# 09.06.24 # 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" SERIES_FOLDER = "Serie"

View File

@ -7,7 +7,6 @@ import logging
# Internal utilities # Internal utilities
from Src.Util.console import console, msg from Src.Util.console import console, msg
from Src.Util._jsonConfig import config_manager
from Src.Util.table import TVShowManager from Src.Util.table import TVShowManager
from Src.Util.message import start_message from Src.Util.message import start_message
from Src.Lib.Hls.downloader import Downloader 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 from .Core.Player.supervideo import VideoSource
# Config
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
from .costant import MAIN_FOLDER, SERIES_FOLDER
# Variable # Variable
from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER
table_show_manager = TVShowManager() table_show_manager = TVShowManager()
video_source = VideoSource() 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 # 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_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 # Setup video source
video_source.setup(obj_episode.get('url')) video_source.setup(obj_episode.get('url'))

View File

@ -1,9 +1,7 @@
# 09.06.24 # 09.06.24
import os
import sys import sys
import logging import logging
from urllib.parse import urlparse
# External libraries # External libraries
@ -14,7 +12,6 @@ from bs4 import BeautifulSoup
# Internal utilities # Internal utilities
from Src.Util.table import TVShowManager from Src.Util.table import TVShowManager
from Src.Util.console import console, msg from Src.Util.console import console, msg
from Src.Util._jsonConfig import config_manager
from Src.Util.headers import get_headers from Src.Util.headers import get_headers
@ -23,17 +20,11 @@ from .Core.Class.SearchType import MediaManager, MediaItem
# Variable # Variable
from .costant import DOMAIN_NOW
media_search_manager = MediaManager() media_search_manager = MediaManager()
table_show_manager = TVShowManager() 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: def title_search(word_to_search) -> int:
""" """
Search for titles based on a search query. Search for titles based on a search query.

View File

@ -1,5 +1,12 @@
# 26.05.24 # 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" MOVIE_FOLDER = "Movie"
SERIES_FOLDER = "Serie" SERIES_FOLDER = "Serie"

View File

@ -1,13 +1,11 @@
# 3.12.23 # 3.12.23
import os import os
import sys
import logging import logging
# Internal utilities # Internal utilities
from Src.Util.console import console from Src.Util.console import console
from Src.Util._jsonConfig import config_manager
from Src.Lib.Hls.downloader import Downloader from Src.Lib.Hls.downloader import Downloader
from Src.Util.message import start_message from Src.Util.message import start_message
@ -16,12 +14,8 @@ from Src.Util.message import start_message
from .Core.Player.vixcloud import VideoSource from .Core.Player.vixcloud import VideoSource
# Config
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
from .costant import MAIN_FOLDER, MOVIE_FOLDER
# Variable # Variable
from .costant import ROOT_PATH, SITE_NAME, MOVIE_FOLDER
video_source = VideoSource() 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 # Define the filename and path for the downloaded film
mp4_name = title_name.replace("-", "_") mp4_name = title_name.replace("-", "_")
mp4_format = (mp4_name) + ".mp4" 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 # Download the film using the m3u8 playlist, and output filename
Downloader( Downloader(

View File

@ -7,7 +7,6 @@ import logging
# Internal utilities # Internal utilities
from Src.Util.console import console, msg from Src.Util.console import console, msg
from Src.Util._jsonConfig import config_manager
from Src.Util.table import TVShowManager from Src.Util.table import TVShowManager
from Src.Util.message import start_message from Src.Util.message import start_message
from Src.Lib.Hls.downloader import Downloader 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 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 # Variable
from .costant import ROOT_PATH, SITE_NAME, SERIES_FOLDER
video_source = VideoSource() video_source = VideoSource()
table_show_manager = TVShowManager() 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 # Define filename and path for the downloaded video
mp4_name = f"{map_episode_title(tv_name, obj_episode, index_season_selected)}.mp4" 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 # Retrieve scws and if available master playlist
video_source.get_iframe(obj_episode.id) video_source.get_iframe(obj_episode.id)

67
update.py Normal file
View File

@ -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")