mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 20:15:24 +00:00

* Add ENABLE_VIDEO * Fix proxy * Add error proxy * Update config.json * Fix telegram_bot (#312) * Update config.json * Fix telegram_bot * fix bug * Fix StreamingCommunity site * Delete console.log * fix doppio string_to_search * Update __init__.py * Update site.py * Update config.json * Update site.py * Update config.json * Update __init__.py * Update __init__.py * Fix proxy (#319) * Add ENABLE_VIDEO * Fix proxy * Add error proxy * Update config.json * Refactor user input handling and improve messaging in __init__.py --------- Co-authored-by: None <62809003+Arrowar@users.noreply.github.com> Co-authored-by: l1n00 <> * Fix proxy __init__ * Update os.py --------- Co-authored-by: l1n00 <delmolinonicola@gmail.com>
84 lines
2.8 KiB
Python
84 lines
2.8 KiB
Python
# 21.03.25
|
|
|
|
# External library
|
|
from rich.console import Console
|
|
from rich.prompt import Prompt
|
|
|
|
|
|
# Internal utilities
|
|
from StreamingCommunity.Api.Template import get_select_title
|
|
from StreamingCommunity.Api.Template.config_loader import site_constant
|
|
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
|
|
|
|
|
# Logic class
|
|
from .site import title_search, media_search_manager, table_show_manager
|
|
from .serie import download_series
|
|
from .film import download_film
|
|
|
|
|
|
# Variable
|
|
indice = 6
|
|
_useFor = "Anime"
|
|
_priority = 0
|
|
_engineDownload = "mp4"
|
|
_deprecate = False
|
|
|
|
msg = Prompt()
|
|
console = Console()
|
|
|
|
|
|
|
|
def process_search_result(select_title, selections=None):
|
|
"""
|
|
Handles the search result and initiates the download for either a film or series.
|
|
|
|
Parameters:
|
|
select_title (MediaItem): The selected media item
|
|
selections (dict, optional): Dictionary containing selection inputs that bypass manual input
|
|
{'season': season_selection, 'episode': episode_selection}
|
|
"""
|
|
if select_title.type == "TV":
|
|
episode_selection = None
|
|
if selections:
|
|
episode_selection = selections.get('episode')
|
|
download_series(select_title, episode_selection)
|
|
|
|
else:
|
|
download_film(select_title)
|
|
|
|
def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
|
|
"""
|
|
Main function of the application for search.
|
|
|
|
Parameters:
|
|
string_to_search (str, optional): String to search for
|
|
get_onlyDatabase (bool, optional): If True, return only the database object
|
|
direct_item (dict, optional): Direct item to process (bypass search)
|
|
selections (dict, optional): Dictionary containing selection inputs that bypass manual input
|
|
{'season': season_selection, 'episode': episode_selection}
|
|
"""
|
|
if direct_item:
|
|
select_title = MediaItem(**direct_item)
|
|
process_search_result(select_title, selections)
|
|
return
|
|
|
|
# Get the user input for the search term
|
|
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()
|
|
|
|
# Perform the database search
|
|
len_database = title_search(string_to_search)
|
|
|
|
# If only the database is needed, return the manager
|
|
if get_onlyDatabase:
|
|
return media_search_manager
|
|
|
|
if len_database > 0:
|
|
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
|
|
process_search_result(select_title, selections)
|
|
|
|
else:
|
|
# If no results are found, ask again
|
|
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
|
|
search() |