2025-02-11 12:49:12 +01:00

53 lines
1.2 KiB
Python

# 09.06.24
from urllib.parse import quote_plus
# Internal utilities
from StreamingCommunity.Util.console import console, msg
from StreamingCommunity.Api.Template import get_select_title
# Logic class
from .site import title_search, media_search_manager, table_show_manager
from .film import download_film
# Variable
indice = 9
_useFor = "film"
_deprecate = False
_priority = 2
_engineDownload = "mp4"
from .costant import SITE_NAME
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()
# Search on database
len_database = title_search(quote_plus(string_to_search))
# Return list of elements
if get_onylDatabase:
return media_search_manager
if len_database > 0:
# Select title from list
select_title = get_select_title(table_show_manager, media_search_manager)
# !!! ADD TYPE DONT WORK FOR SERIE
download_film(select_title)
else:
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
# Retry
search()