mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +00:00
Add command back
This commit is contained in:
parent
8d221a8ce8
commit
1b099441a4
@ -18,6 +18,7 @@ _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):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,6 +18,7 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,12 +18,13 @@ _useFor = "anime"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "mp4"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
|
||||
if string_to_search is None:
|
||||
string_to_search = msg.ask("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,6 +18,7 @@ _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):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,6 +18,7 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "mp4"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -19,6 +19,7 @@ _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 +30,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
if string_to_search is None:
|
||||
|
||||
# Make request to site to get content that corrsisponde to that string
|
||||
string_to_search = msg.ask("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,6 +18,7 @@ _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 +29,7 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
if string_to_search is None:
|
||||
|
||||
# Make request to site to get content that corrsisponde to that string
|
||||
string_to_search = msg.ask("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -18,6 +18,7 @@ _useFor = "film"
|
||||
_deprecate = False
|
||||
_priority = 2
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Not available for the moment
|
||||
if get_onylDatabase:
|
||||
|
@ -18,6 +18,7 @@ _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):
|
||||
@ -26,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Search on database
|
||||
len_database = title_search(unidecode(string_to_search))
|
||||
|
@ -19,6 +19,7 @@ _useFor = "film_serie"
|
||||
_deprecate = False
|
||||
_priority = 1
|
||||
_engineDownload = "hls"
|
||||
from .costant import SITE_NAME
|
||||
|
||||
|
||||
def search(string_to_search: str = None, get_onylDatabase: bool = False):
|
||||
@ -27,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("\n[purple]Insert word to search in all site").strip()
|
||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [red]{SITE_NAME}").strip()
|
||||
|
||||
# Get site domain and version and get result of the search
|
||||
site_version, domain = get_version_and_domain()
|
||||
|
@ -50,15 +50,15 @@ def get_final_redirect_url(initial_url, max_timeout):
|
||||
# Create a client with redirects enabled
|
||||
try:
|
||||
with httpx.Client(
|
||||
follow_redirects=True,
|
||||
timeout=max_timeout,
|
||||
headers={
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
||||
'accept-language': 'it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7',
|
||||
'User-Agent': get_headers()
|
||||
}
|
||||
},
|
||||
follow_redirects=True,
|
||||
timeout=max_timeout
|
||||
|
||||
) as client:
|
||||
|
||||
response = client.get(initial_url)
|
||||
response.raise_for_status()
|
||||
|
||||
@ -97,8 +97,8 @@ def search_domain(site_name: str, base_url: str):
|
||||
},
|
||||
follow_redirects=True,
|
||||
timeout=max_timeout
|
||||
|
||||
) as client:
|
||||
|
||||
response_follow = client.get(f"{base_url}.{domain}")
|
||||
response_follow.raise_for_status()
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
# 03.03.24
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import importlib
|
||||
|
||||
|
||||
# External library
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
from rich.prompt import Prompt
|
||||
@ -9,15 +16,13 @@ from typing import Dict, List, Any
|
||||
|
||||
# Internal utilities
|
||||
from .message import start_message
|
||||
from .call_stack import get_call_stack
|
||||
|
||||
|
||||
class TVShowManager:
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize TVShowManager with provided column information.
|
||||
|
||||
Parameters:
|
||||
- column_info (Dict[str, Dict[str, str]]): Dictionary containing column names, their colors, and justification.
|
||||
"""
|
||||
self.console = Console()
|
||||
self.tv_shows: List[Dict[str, Any]] = [] # List to store TV show data as dictionaries
|
||||
@ -80,7 +85,6 @@ class TVShowManager:
|
||||
|
||||
self.console.print(table) # Use self.console.print instead of print
|
||||
|
||||
|
||||
def run(self, force_int_input: bool = False, max_int_input: int = 0) -> str:
|
||||
"""
|
||||
Run the TV show manager application.
|
||||
@ -101,9 +105,16 @@ class TVShowManager:
|
||||
# Display table
|
||||
self.display_data(self.tv_shows[self.slice_start:self.slice_end])
|
||||
|
||||
# Find research function from call stack
|
||||
research_func = None
|
||||
for reverse_fun in get_call_stack():
|
||||
if reverse_fun['function'] == 'search' and reverse_fun['script'] == '__init__.py':
|
||||
research_func = reverse_fun
|
||||
logging.info(f"Found research_func: {research_func}")
|
||||
|
||||
# Handling user input for loading more items or quitting
|
||||
if self.slice_end < total_items:
|
||||
self.console.print(f"\n\n[yellow][INFO] [green]Press [red]Enter [green]for next page, or [red]'q' [green]to quit.")
|
||||
self.console.print(f"\n\n[yellow][INFO] [green]Press [red]Enter [green]for next page, [red]'q' [green]to quit, or [red]'back' [green]to search.")
|
||||
|
||||
if not force_int_input:
|
||||
key = Prompt.ask(
|
||||
@ -113,7 +124,7 @@ class TVShowManager:
|
||||
|
||||
else:
|
||||
choices = [str(i) for i in range(0, max_int_input)]
|
||||
choices.extend(["q", ""])
|
||||
choices.extend(["q", "", "back"])
|
||||
|
||||
key = Prompt.ask("[cyan]Insert media [red]index", choices=choices, show_choices=False)
|
||||
last_command = key
|
||||
@ -127,22 +138,62 @@ class TVShowManager:
|
||||
if self.slice_end > total_items:
|
||||
self.slice_end = total_items
|
||||
|
||||
elif key.lower() == "back" and research_func:
|
||||
try:
|
||||
# Find the project root directory
|
||||
current_path = research_func['folder']
|
||||
while not os.path.exists(os.path.join(current_path, 'StreamingCommunity')):
|
||||
current_path = os.path.dirname(current_path)
|
||||
|
||||
# Add project root to Python path
|
||||
project_root = current_path
|
||||
#print(f"[DEBUG] Project Root: {project_root}")
|
||||
|
||||
if project_root not in sys.path:
|
||||
sys.path.insert(0, project_root)
|
||||
|
||||
# Import using full absolute import
|
||||
module_path = 'StreamingCommunity.Api.Site.streamingcommunity'
|
||||
#print(f"[DEBUG] Importing module: {module_path}")
|
||||
|
||||
# Import the module
|
||||
module = importlib.import_module(module_path)
|
||||
|
||||
# Get the search function
|
||||
search_func = getattr(module, 'media_search_manager')
|
||||
|
||||
# Ask for search string
|
||||
string_to_search = Prompt.ask(f"\n[purple]Insert word to search in [red]{research_func['folder_base']}").strip()
|
||||
|
||||
# Call the search function with the search string
|
||||
search_func(string_to_search)
|
||||
|
||||
except Exception as e:
|
||||
self.console.print(f"[red]Error during search: {e}")
|
||||
|
||||
# Print detailed traceback
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Optionally remove the path if you want to clean up
|
||||
if project_root in sys.path:
|
||||
sys.path.remove(project_root)
|
||||
|
||||
else:
|
||||
break
|
||||
|
||||
else:
|
||||
# Last slice, ensure all remaining items are shown
|
||||
self.console.print(f"\n\n[yellow][INFO] [red]You've reached the end. [green]Press [red]Enter [green]for next page, or [red]'q' [green]to quit.")
|
||||
self.console.print(f"\n\n[yellow][INFO] [green]You've reached the end. [red]Enter [green]for first page, [red]'q' [green]to quit, or [red]'back' [green]to search.")
|
||||
if not force_int_input:
|
||||
key = Prompt.ask(
|
||||
"\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, "
|
||||
"[yellow](e.g., 1-2) [cyan]for a range of media, or [yellow](e.g., 3-*) [cyan]to download from a specific index to the end"
|
||||
)
|
||||
|
||||
|
||||
else:
|
||||
choices = [str(i) for i in range(0, max_int_input)]
|
||||
choices.extend(["q", ""])
|
||||
choices.extend(["q", "", "back"])
|
||||
|
||||
key = Prompt.ask("[cyan]Insert media [red]index", choices=choices, show_choices=False)
|
||||
last_command = key
|
||||
@ -154,10 +205,51 @@ class TVShowManager:
|
||||
self.slice_start = 0
|
||||
self.slice_end = self.step
|
||||
|
||||
elif key.lower() == "back" and research_func:
|
||||
try:
|
||||
# Find the project root directory
|
||||
current_path = research_func['folder']
|
||||
while not os.path.exists(os.path.join(current_path, 'StreamingCommunity')):
|
||||
current_path = os.path.dirname(current_path)
|
||||
|
||||
# Add project root to Python path
|
||||
project_root = current_path
|
||||
#print(f"[DEBUG] Project Root: {project_root}")
|
||||
|
||||
if project_root not in sys.path:
|
||||
sys.path.insert(0, project_root)
|
||||
|
||||
# Import using full absolute import
|
||||
module_path = 'StreamingCommunity.Api.Site.streamingcommunity'
|
||||
#print(f"[DEBUG] Importing module: {module_path}")
|
||||
|
||||
# Import the module
|
||||
module = importlib.import_module(module_path)
|
||||
|
||||
# Get the search function
|
||||
search_func = getattr(module, 'media_search_manager')
|
||||
|
||||
# Ask for search string
|
||||
string_to_search = Prompt.ask(f"\n[purple]Insert word to search in [red]{research_func['folder_base']}").strip()
|
||||
|
||||
# Call the search function with the search string
|
||||
search_func(string_to_search)
|
||||
|
||||
except Exception as e:
|
||||
self.console.print(f"[red]Error during search: {e}")
|
||||
|
||||
# Print detailed traceback
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Optionally remove the path if you want to clean up
|
||||
if project_root in sys.path:
|
||||
sys.path.remove(project_root)
|
||||
|
||||
else:
|
||||
break
|
||||
|
||||
return last_command
|
||||
|
||||
def clear(self):
|
||||
self.tv_shows = []
|
||||
self.tv_shows = []
|
@ -119,12 +119,12 @@ def initialize():
|
||||
console.log("[red]Install python version > 3.7.16")
|
||||
sys.exit(0)
|
||||
|
||||
# Attempting GitHub update
|
||||
"""# Attempting GitHub update
|
||||
try:
|
||||
git_update()
|
||||
print()
|
||||
except:
|
||||
console.log("[red]Error with loading github.")
|
||||
console.log("[red]Error with loading github.")"""
|
||||
|
||||
# Show trending film and series
|
||||
if SHOW_TRENDING:
|
||||
|
Loading…
x
Reference in New Issue
Block a user