mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 11:35:29 +00:00
Remove constant
This commit is contained in:
parent
5754bd8d94
commit
38cf30f977
@ -9,6 +9,7 @@ from StreamingCommunity.Api.Template import get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .title import download_title
|
||||
|
||||
@ -19,7 +20,6 @@ _useFor = "film_serie"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "tor"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -27,7 +27,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
Main function of the application for film and series.
|
||||
"""
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(quote_plus(string_to_search))
|
||||
|
@ -1,15 +0,0 @@
|
||||
# 09.06.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = config_manager.get('DEFAULT', 'serie_folder_name')
|
||||
MOVIE_FOLDER = config_manager.get('DEFAULT', 'movie_folder_name')
|
@ -13,12 +13,12 @@ from StreamingCommunity.Util.table import TVShowManager
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Util import search_domain
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, DOMAIN_NOW
|
||||
media_search_manager = MediaManager()
|
||||
table_show_manager = TVShowManager()
|
||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
||||
@ -39,15 +39,15 @@ def title_search(word_to_search: str) -> int:
|
||||
table_show_manager.clear()
|
||||
|
||||
# Find new domain if prev dont work
|
||||
domain_to_use = DOMAIN_NOW
|
||||
domain_to_use = site_constant.DOMAIN_NOW
|
||||
|
||||
if not disable_searchDomain:
|
||||
domain_to_use, base_url = search_domain(SITE_NAME, f"https://{SITE_NAME}.{DOMAIN_NOW}")
|
||||
domain_to_use, base_url = search_domain(site_constant.SITE_NAME, f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}")
|
||||
|
||||
# Construct the full site URL and load the search page
|
||||
try:
|
||||
response = httpx.get(
|
||||
url=f"https://{SITE_NAME}.{domain_to_use}/search/{word_to_search}/1/",
|
||||
url=f"https://{site_constant.SITE_NAME}.{domain_to_use}/search/{word_to_search}/1/",
|
||||
headers={'user-agent': get_headers()},
|
||||
follow_redirects=True,
|
||||
timeout=max_timeout
|
||||
@ -55,7 +55,7 @@ def title_search(word_to_search: str) -> int:
|
||||
response.raise_for_status()
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"Site: {SITE_NAME}, request search error: {e}")
|
||||
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
|
||||
|
||||
# Create soup and find table
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
|
@ -17,12 +17,10 @@ from StreamingCommunity.Lib.Downloader import TOR_downloader
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
# Config
|
||||
from .costant import DOMAIN_NOW, SITE_NAME, MOVIE_FOLDER
|
||||
|
||||
|
||||
def download_title(select_title: MediaItem):
|
||||
"""
|
||||
@ -37,13 +35,13 @@ def download_title(select_title: MediaItem):
|
||||
|
||||
# Define output path
|
||||
title_name = os_manager.get_sanitize_file(select_title.name)
|
||||
mp4_path = os.path.join(MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
|
||||
# Create output folder
|
||||
os_manager.create_path(mp4_path)
|
||||
|
||||
# Make request to page with magnet
|
||||
full_site_name = f"{SITE_NAME}.{DOMAIN_NOW}"
|
||||
full_site_name = f"{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}"
|
||||
response = httpx.get(
|
||||
url="https://" + full_site_name + select_title.url,
|
||||
headers={
|
||||
|
@ -12,6 +12,7 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .film import download_film
|
||||
|
||||
@ -22,14 +23,13 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME, TELEGRAM_BOT
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
Main function of the application for film and series.
|
||||
"""
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
if string_to_search is None:
|
||||
@ -49,7 +49,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
|
||||
else:
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(quote_plus(string_to_search))
|
||||
@ -67,7 +67,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
download_film(select_title)
|
||||
|
||||
else:
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot.send_message(f"Nessun risultato trovato riprova", None)
|
||||
|
||||
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
|
||||
|
@ -1,21 +0,0 @@
|
||||
# 26.05.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot')
|
@ -11,6 +11,7 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .film_serie import download_film, download_series
|
||||
|
||||
@ -21,12 +22,11 @@ _useFor = "anime"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "mp4"
|
||||
from .costant import SITE_NAME, TELEGRAM_BOT
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
if string_to_search is None:
|
||||
@ -46,7 +46,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
|
||||
else:
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(string_to_search)
|
||||
@ -67,7 +67,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
download_series(select_title)
|
||||
|
||||
else:
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot.send_message(f"Nessun risultato trovato riprova", None)
|
||||
|
||||
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
|
||||
|
@ -1,21 +0,0 @@
|
||||
# 26.05.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
ANIME_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'anime_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
ANIME_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'anime_folder_name'))
|
||||
|
||||
TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot')
|
@ -9,6 +9,7 @@ from StreamingCommunity.Api.Template import get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .film import download_film
|
||||
|
||||
@ -19,7 +20,6 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "mp4"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -28,7 +28,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(quote_plus(string_to_search))
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 03.07.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
@ -11,6 +11,7 @@ from StreamingCommunity.Lib.Downloader import HLS_Downloader
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
@ -18,9 +19,6 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
from StreamingCommunity.Api.Player.maxstream import VideoSource
|
||||
|
||||
|
||||
# Config
|
||||
from .costant import MOVIE_FOLDER
|
||||
|
||||
|
||||
def download_film(select_title: MediaItem) -> str:
|
||||
"""
|
||||
@ -40,7 +38,7 @@ def download_film(select_title: MediaItem) -> str:
|
||||
|
||||
# Define output path
|
||||
title_name = os_manager.get_sanitize_file(select_title.name) +".mp4"
|
||||
mp4_path = os.path.join(MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
|
||||
# Get m3u8 master playlist
|
||||
master_playlist = video_source.get_playlist()
|
||||
|
@ -12,12 +12,12 @@ from StreamingCommunity.Util.table import TVShowManager
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Util import search_domain
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, DOMAIN_NOW
|
||||
media_search_manager = MediaManager()
|
||||
table_show_manager = TVShowManager()
|
||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
||||
@ -38,13 +38,13 @@ def title_search(word_to_search: str) -> int:
|
||||
table_show_manager.clear()
|
||||
|
||||
# Find new domain if prev dont work
|
||||
domain_to_use = DOMAIN_NOW
|
||||
domain_to_use = site_constant.DOMAIN_NOW
|
||||
|
||||
if not disable_searchDomain:
|
||||
domain_to_use, base_url = search_domain(SITE_NAME, f"https://{SITE_NAME}.{DOMAIN_NOW}")
|
||||
domain_to_use, base_url = search_domain(site_constant.SITE_NAME, f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}")
|
||||
|
||||
response = httpx.get(
|
||||
url=f"https://{SITE_NAME}.{domain_to_use}/?s={word_to_search}",
|
||||
url=f"https://{site_constant.SITE_NAME}.{domain_to_use}/?s={word_to_search}",
|
||||
headers={'user-agent': get_headers()},
|
||||
timeout=max_timeout
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ from StreamingCommunity.Api.Template import get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .series import download_thread
|
||||
|
||||
@ -20,7 +21,6 @@ _useFor = "serie"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "mp4"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -29,7 +29,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(quote_plus(string_to_search))
|
||||
|
@ -1,20 +0,0 @@
|
||||
# 09.06.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
COOKIE = config_manager.get_dict('SITE', SITE_NAME)['extra']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
@ -20,6 +20,7 @@ from StreamingCommunity.Api.Template.Util import (
|
||||
validate_episode_selection,
|
||||
display_episodes_list
|
||||
)
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
|
||||
|
||||
# Player
|
||||
@ -27,10 +28,6 @@ from .util.ScrapeSerie import GetSerieInfo
|
||||
from StreamingCommunity.Api.Player.ddl import VideoSource
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SERIES_FOLDER
|
||||
|
||||
|
||||
|
||||
def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo, video_source: VideoSource) -> Tuple[str,bool]:
|
||||
"""
|
||||
@ -54,7 +51,7 @@ def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo,
|
||||
title_name = os_manager.get_sanitize_file(
|
||||
f"{map_episode_title(scape_info_serie.tv_name, None, index_episode_selected, obj_episode.get('name'))}.mp4"
|
||||
)
|
||||
mp4_path = os.path.join(SERIES_FOLDER, scape_info_serie.tv_name)
|
||||
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scape_info_serie.tv_name)
|
||||
|
||||
# Create output folder
|
||||
os_manager.create_path(mp4_path)
|
||||
@ -86,8 +83,6 @@ def download_thread(dict_serie: MediaItem):
|
||||
"""
|
||||
Download all episode of a thread
|
||||
"""
|
||||
|
||||
# Start message and set up video source
|
||||
start_message()
|
||||
|
||||
# Init class
|
||||
@ -104,6 +99,7 @@ def download_thread(dict_serie: MediaItem):
|
||||
|
||||
try:
|
||||
list_episode_select = validate_episode_selection(list_episode_select, episodes_count)
|
||||
|
||||
except ValueError as e:
|
||||
console.print(f"[red]{str(e)}")
|
||||
return
|
||||
@ -113,4 +109,5 @@ def download_thread(dict_serie: MediaItem):
|
||||
for i_episode in list_episode_select:
|
||||
if kill_handler:
|
||||
break
|
||||
kill_handler = download_video(i_episode, scape_info_serie, video_source)[1]
|
||||
|
||||
kill_handler = download_video(i_episode, scape_info_serie, video_source)[1]
|
@ -16,12 +16,12 @@ from StreamingCommunity.Util.table import TVShowManager
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Util import search_domain
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, DOMAIN_NOW
|
||||
media_search_manager = MediaManager()
|
||||
table_show_manager = TVShowManager()
|
||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
||||
@ -42,22 +42,22 @@ def title_search(word_to_search: str) -> int:
|
||||
table_show_manager.clear()
|
||||
|
||||
# Find new domain if prev dont work
|
||||
domain_to_use = DOMAIN_NOW
|
||||
domain_to_use = site_constant.DOMAIN_NOW
|
||||
|
||||
if not disable_searchDomain:
|
||||
domain_to_use, base_url = search_domain(SITE_NAME, f"https://{SITE_NAME}.{DOMAIN_NOW}")
|
||||
domain_to_use, base_url = search_domain(site_constant.SITE_NAME, f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}")
|
||||
|
||||
# Send request to search for titles
|
||||
try:
|
||||
response = httpx.get(
|
||||
url=f"https://{SITE_NAME}.{domain_to_use}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11",
|
||||
url=f"https://{site_constant.SITE_NAME}.{domain_to_use}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11",
|
||||
headers={'user-agent': get_headers()},
|
||||
timeout=max_timeout
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"Site: {SITE_NAME}, request search error: {e}")
|
||||
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
|
||||
|
||||
# Create soup and find table
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
@ -86,6 +86,4 @@ def title_search(word_to_search: str) -> int:
|
||||
|
||||
else:
|
||||
logging.error("No table content found.")
|
||||
return -999
|
||||
|
||||
return -9999
|
||||
return -999
|
@ -16,11 +16,11 @@ from StreamingCommunity.Util.headers import get_headers
|
||||
|
||||
|
||||
# Logic class
|
||||
from ..site import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
# Variable
|
||||
from ..costant import COOKIE
|
||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class GetSerieInfo:
|
||||
- dict_serie (MediaItem): Dictionary containing series information (optional).
|
||||
"""
|
||||
self.headers = {'user-agent': get_headers()}
|
||||
self.cookies = COOKIE
|
||||
self.cookies = site_constant.COOKIE
|
||||
self.url = dict_serie.url
|
||||
self.tv_name = None
|
||||
self.list_episodes = None
|
||||
|
@ -9,6 +9,7 @@ from StreamingCommunity.Api.Template import get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .series import download_series
|
||||
|
||||
@ -19,7 +20,6 @@ _useFor = "serie"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -28,7 +28,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(quote_plus(string_to_search))
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 09.06.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
@ -10,6 +10,7 @@ from StreamingCommunity.Api.Template import get_select_title
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import title_search, media_search_manager, table_show_manager
|
||||
from .title import download_title
|
||||
|
||||
@ -20,7 +21,6 @@ _useFor = "film_serie"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "tor"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -29,7 +29,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = asyncio.run(title_search(quote_plus(string_to_search)))
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 09.06.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
@ -7,13 +7,13 @@ from StreamingCommunity.Util.table import TVShowManager
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Util import search_domain
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
||||
from .util.ilCorsarScraper import IlCorsaroNeroScraper
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, DOMAIN_NOW
|
||||
media_search_manager = MediaManager()
|
||||
table_show_manager = TVShowManager()
|
||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
||||
@ -34,14 +34,14 @@ async def title_search(word_to_search: str) -> int:
|
||||
table_show_manager.clear()
|
||||
|
||||
# Find new domain if prev dont work
|
||||
domain_to_use = DOMAIN_NOW
|
||||
domain_to_use = site_constant.DOMAIN_NOW
|
||||
|
||||
if not disable_searchDomain:
|
||||
domain_to_use, base_url = search_domain(SITE_NAME, f"https://{SITE_NAME}.{DOMAIN_NOW}")
|
||||
domain_to_use, base_url = search_domain(site_constant.SITE_NAME, f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}")
|
||||
|
||||
# Create scraper and collect result
|
||||
print("\n")
|
||||
scraper = IlCorsaroNeroScraper(f"https://{SITE_NAME}.{domain_to_use}/", 1)
|
||||
scraper = IlCorsaroNeroScraper(f"https://{site_constant.SITE_NAME}.{domain_to_use}/", 1)
|
||||
results = await scraper.search(word_to_search)
|
||||
|
||||
for i, torrent in enumerate(results):
|
||||
|
@ -11,12 +11,10 @@ from StreamingCommunity.Lib.Downloader import TOR_downloader
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
# Config
|
||||
from .costant import MOVIE_FOLDER
|
||||
|
||||
|
||||
def download_title(select_title: MediaItem):
|
||||
"""
|
||||
@ -32,7 +30,7 @@ def download_title(select_title: MediaItem):
|
||||
|
||||
# Define output path
|
||||
title_name = os_manager.get_sanitize_file(select_title.name)
|
||||
mp4_path = os.path.join(MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
|
||||
# Create output folder
|
||||
os_manager.create_path(mp4_path)
|
||||
@ -41,4 +39,4 @@ def download_title(select_title: MediaItem):
|
||||
manager = TOR_downloader()
|
||||
manager.add_magnet_link(select_title.url)
|
||||
manager.start_download()
|
||||
manager.move_downloaded_files(mp4_path)
|
||||
manager.move_downloaded_files(mp4_path)
|
@ -8,6 +8,7 @@ from StreamingCommunity.Util.console import console, msg
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Lib.TMBD import tmdb, Json_film
|
||||
from .film import download_film
|
||||
|
||||
@ -18,7 +19,6 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -27,7 +27,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{SITE_NAME}").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
||||
|
||||
# Not available for the moment
|
||||
if get_onylDatabase:
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 26.05.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
@ -22,14 +22,11 @@ from StreamingCommunity.Lib.Downloader import HLS_Downloader
|
||||
from StreamingCommunity.Api.Player.supervideo import VideoSource
|
||||
|
||||
|
||||
# TMBD
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Lib.TMBD import Json_film
|
||||
|
||||
|
||||
# Config
|
||||
from .costant import SITE_NAME, DOMAIN_NOW, MOVIE_FOLDER
|
||||
|
||||
|
||||
def download_film(movie_details: Json_film) -> str:
|
||||
"""
|
||||
Downloads a film using the provided tmbd id.
|
||||
@ -47,7 +44,7 @@ def download_film(movie_details: Json_film) -> str:
|
||||
|
||||
# Make request to main site
|
||||
try:
|
||||
url = f"https://{SITE_NAME}.{DOMAIN_NOW}/set-movie-a/{movie_details.imdb_id}"
|
||||
url = f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}/set-movie-a/{movie_details.imdb_id}"
|
||||
response = httpx.get(url, headers={'User-Agent': get_headers()})
|
||||
response.raise_for_status()
|
||||
|
||||
@ -69,7 +66,7 @@ def download_film(movie_details: Json_film) -> str:
|
||||
|
||||
# Define output path
|
||||
title_name = os_manager.get_sanitize_file(movie_details.title) + ".mp4"
|
||||
mp4_path = os.path.join(MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
|
||||
# Get m3u8 master playlist
|
||||
master_playlist = video_source.get_playlist()
|
||||
|
@ -12,6 +12,7 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from .site import get_version_and_domain, title_search, table_show_manager, media_search_manager
|
||||
from .film import download_film
|
||||
from .series import download_series
|
||||
@ -23,14 +24,13 @@ _useFor = "film_serie"
|
||||
_deprecate = False
|
||||
_priority = 1
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME, TELEGRAM_BOT
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
"""
|
||||
Main function of the application for film and series.
|
||||
"""
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
if string_to_search is None:
|
||||
@ -74,8 +74,8 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
else:
|
||||
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
bot.send_message(f"Nessun risultato trovato riprova", None)
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot.send_message(f"Nessun risultato trovato riprova", None)
|
||||
|
||||
# Retry
|
||||
search()
|
@ -1,21 +0,0 @@
|
||||
# 26.05.24
|
||||
|
||||
import os
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
SITE_NAME = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
DOMAIN_NOW = config_manager.get_dict('SITE', SITE_NAME)['domain']
|
||||
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
SERIES_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
MOVIE_FOLDER = os.path.join(ROOT_PATH, SITE_NAME, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot')
|
@ -12,6 +12,7 @@ from StreamingCommunity.TelegramHelp.telegram_bot import TelegramSession, get_bo
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
@ -19,10 +20,6 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
from StreamingCommunity.Api.Player.vixcloud import VideoSource
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, MOVIE_FOLDER, TELEGRAM_BOT
|
||||
|
||||
|
||||
def download_film(select_title: MediaItem) -> str:
|
||||
"""
|
||||
Downloads a film using the provided film ID, title name, and domain.
|
||||
@ -34,7 +31,7 @@ def download_film(select_title: MediaItem) -> str:
|
||||
Return:
|
||||
- str: output path
|
||||
"""
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
bot.send_message(f"Download in corso:\n{select_title.name}", None)
|
||||
|
||||
@ -51,7 +48,7 @@ def download_film(select_title: MediaItem) -> str:
|
||||
console.print(f"[yellow]Download: [red]{select_title.name} \n")
|
||||
|
||||
# Init class
|
||||
video_source = VideoSource(SITE_NAME, False)
|
||||
video_source = VideoSource(site_constant.SITE_NAME, False)
|
||||
video_source.setup(select_title.id)
|
||||
|
||||
# Retrieve scws and if available master playlist
|
||||
@ -61,7 +58,7 @@ def download_film(select_title: MediaItem) -> str:
|
||||
|
||||
# Define the filename and path for the downloaded film
|
||||
title_name = os_manager.get_sanitize_file(select_title.name) + ".mp4"
|
||||
mp4_path = os.path.join(MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
||||
|
||||
# Download the film using the m3u8 playlist, and output filename
|
||||
r_proc = HLS_Downloader(
|
||||
@ -69,7 +66,7 @@ def download_film(select_title: MediaItem) -> str:
|
||||
output_path=os.path.join(mp4_path, title_name)
|
||||
).start()
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
|
||||
# Delete script_id
|
||||
script_id = TelegramSession.get_session()
|
||||
|
@ -20,6 +20,7 @@ from StreamingCommunity.Api.Template.Util import (
|
||||
validate_episode_selection,
|
||||
display_episodes_list
|
||||
)
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
|
||||
|
||||
@ -27,10 +28,6 @@ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
||||
from StreamingCommunity.Api.Player.vixcloud import VideoSource
|
||||
|
||||
|
||||
# Variable
|
||||
from .costant import SITE_NAME, SERIES_FOLDER, TELEGRAM_BOT
|
||||
|
||||
|
||||
def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: ScrapeSerie, video_source: VideoSource) -> Tuple[str,bool]:
|
||||
"""
|
||||
Download a single episode video.
|
||||
@ -51,7 +48,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
|
||||
console.print(f"[yellow]Download: [red]{index_season_selected}:{index_episode_selected} {obj_episode.name}")
|
||||
print()
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
# Invio a telegram
|
||||
@ -67,7 +64,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
|
||||
|
||||
# Define filename and path for the downloaded video
|
||||
mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
|
||||
mp4_path = os.path.join(SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
|
||||
mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
|
||||
|
||||
# Retrieve scws and if available master playlist
|
||||
video_source.get_iframe(obj_episode.id)
|
||||
@ -144,15 +141,15 @@ def download_series(select_season: MediaItem, version: str) -> None:
|
||||
- domain (str): Domain from which to download.
|
||||
- version (str): Version of the site.
|
||||
"""
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
# Start message and set up video source
|
||||
start_message()
|
||||
|
||||
# Init class
|
||||
scrape_serie = ScrapeSerie(SITE_NAME)
|
||||
video_source = VideoSource(SITE_NAME, True)
|
||||
scrape_serie = ScrapeSerie(site_constant.SITE_NAME)
|
||||
video_source = VideoSource(site_constant.SITE_NAME, True)
|
||||
|
||||
# Setup video source
|
||||
scrape_serie.setup(version, select_season.id, select_season.slug)
|
||||
@ -165,7 +162,7 @@ def download_series(select_season: MediaItem, version: str) -> None:
|
||||
# Prompt user for season selection and download episodes
|
||||
console.print(f"\n[green]Seasons found: [red]{seasons_count}")
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
console.print("\n[cyan]Insert season number [yellow](e.g., 1), [red]* [cyan]to download all seasons, "
|
||||
"[yellow](e.g., 1-2) [cyan]for a range of seasons, or [yellow](e.g., 3-*) [cyan]to download from a specific season to the end")
|
||||
|
||||
@ -203,7 +200,7 @@ def download_series(select_season: MediaItem, version: str) -> None:
|
||||
# Otherwise, let the user select specific episodes for the single season
|
||||
download_episode(i_season, scrape_serie, video_source, download_all=False)
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot.send_message(f"Finito di scaricare tutte le serie e episodi", None)
|
||||
|
||||
# Get script_id
|
||||
|
@ -19,13 +19,11 @@ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
||||
|
||||
|
||||
# Logic class
|
||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||
from StreamingCommunity.Api.Template.Util import search_domain
|
||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
||||
|
||||
|
||||
# Config
|
||||
from .costant import SITE_NAME, DOMAIN_NOW, TELEGRAM_BOT
|
||||
|
||||
|
||||
# Variable
|
||||
media_search_manager = MediaManager()
|
||||
@ -46,7 +44,7 @@ def get_version(domain: str):
|
||||
"""
|
||||
try:
|
||||
response = httpx.get(
|
||||
url=f"https://{SITE_NAME}.{domain}/",
|
||||
url=f"https://{site_constant.SITE_NAME}.{domain}/",
|
||||
headers={'User-Agent': get_headers()},
|
||||
timeout=max_timeout
|
||||
)
|
||||
@ -74,12 +72,10 @@ def get_version_and_domain():
|
||||
- Determines the correct domain to use for the site by searching for a specific meta tag.
|
||||
- Fetches the content of the site to extract the version information.
|
||||
"""
|
||||
|
||||
# Find new domain if prev dont work
|
||||
domain_to_use = DOMAIN_NOW
|
||||
domain_to_use = site_constant
|
||||
|
||||
if not disable_searchDomain:
|
||||
domain_to_use, base_url = search_domain(SITE_NAME, f"https://{SITE_NAME}.{DOMAIN_NOW}")
|
||||
domain_to_use, base_url = search_domain(site_constant.SITE_NAME, f"https://{site_constant.SITE_NAME}.{site_constant.DOMAIN_NOW}")
|
||||
|
||||
try:
|
||||
version = get_version(domain_to_use)
|
||||
@ -102,7 +98,7 @@ def title_search(title_search: str, domain: str) -> int:
|
||||
Returns:
|
||||
int: The number of titles found.
|
||||
"""
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
bot = get_bot_instance()
|
||||
|
||||
media_search_manager.clear()
|
||||
@ -110,17 +106,17 @@ def title_search(title_search: str, domain: str) -> int:
|
||||
|
||||
try:
|
||||
response = httpx.get(
|
||||
url=f"https://{SITE_NAME}.{domain}/api/search?q={title_search.replace(' ', '+')}",
|
||||
url=f"https://{site_constant.SITE_NAME}.{domain}/api/search?q={title_search.replace(' ', '+')}",
|
||||
headers={'user-agent': get_headers()},
|
||||
timeout=max_timeout
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"Site: {SITE_NAME}, request search error: {e}")
|
||||
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
|
||||
|
||||
# Prepara le scelte per l'utente
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
choices = []
|
||||
|
||||
for i, dict_title in enumerate(response.json()['data']):
|
||||
@ -134,14 +130,14 @@ def title_search(title_search: str, domain: str) -> int:
|
||||
'score': dict_title.get('score')
|
||||
})
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
choice_text = f"{i} - {dict_title.get('name')} ({dict_title.get('type')}) - {dict_title.get('last_air_date')}"
|
||||
choices.append(choice_text)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error parsing a film entry: {e}")
|
||||
|
||||
if TELEGRAM_BOT:
|
||||
if site_constant.TELEGRAM_BOT:
|
||||
if choices:
|
||||
bot.send_message(f"Lista dei risultati:", choices)
|
||||
|
||||
|
71
StreamingCommunity/Api/Template/config_loader.py
Normal file
71
StreamingCommunity/Api/Template/config_loader.py
Normal file
@ -0,0 +1,71 @@
|
||||
# 11.02.25
|
||||
|
||||
import os
|
||||
import inspect
|
||||
|
||||
|
||||
# Internal utilities
|
||||
from StreamingCommunity.Util._jsonConfig import config_manager
|
||||
|
||||
|
||||
def get_site_name_from_stack():
|
||||
for frame_info in inspect.stack():
|
||||
file_path = frame_info.filename
|
||||
|
||||
if "__init__" in file_path:
|
||||
parts = file_path.split(f"Site{os.sep}")
|
||||
|
||||
if len(parts) > 1:
|
||||
site_name = parts[1].split(os.sep)[0]
|
||||
return site_name
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class SiteConstant:
|
||||
@property
|
||||
def SITE_NAME(self):
|
||||
return get_site_name_from_stack()
|
||||
|
||||
@property
|
||||
def ROOT_PATH(self):
|
||||
return config_manager.get('DEFAULT', 'root_path')
|
||||
|
||||
@property
|
||||
def DOMAIN_NOW(self):
|
||||
return config_manager.get_dict('SITE', self.SITE_NAME)['domain']
|
||||
|
||||
@property
|
||||
def SERIES_FOLDER(self):
|
||||
base_path = self.ROOT_PATH
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
base_path = os.path.join(base_path, self.SITE_NAME)
|
||||
return os.path.join(base_path, config_manager.get('DEFAULT', 'serie_folder_name'))
|
||||
|
||||
@property
|
||||
def MOVIE_FOLDER(self):
|
||||
base_path = self.ROOT_PATH
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
base_path = os.path.join(base_path, self.SITE_NAME)
|
||||
return os.path.join(base_path, config_manager.get('DEFAULT', 'movie_folder_name'))
|
||||
|
||||
@property
|
||||
def ANIME_FOLDER(self):
|
||||
base_path = self.ROOT_PATH
|
||||
if config_manager.get_bool("DEFAULT", "add_siteName"):
|
||||
base_path = os.path.join(base_path, self.SITE_NAME)
|
||||
return os.path.join(base_path, config_manager.get('DEFAULT', 'anime_folder_name'))
|
||||
|
||||
@property
|
||||
def COOKIE(self):
|
||||
try:
|
||||
return config_manager.get_dict('SITE', self.SITE_NAME)['extra']
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def TELEGRAM_BOT(self):
|
||||
return config_manager.get_bool('DEFAULT', 'telegram_bot')
|
||||
|
||||
|
||||
site_constant = SiteConstant()
|
Loading…
x
Reference in New Issue
Block a user