StreamingCommunity 2.9.3__py3-none-any.whl → 2.9.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of StreamingCommunity might be problematic. Click here for more details.
- StreamingCommunity/Api/Player/Helper/Vixcloud/util.py +40 -38
- StreamingCommunity/Api/Player/maxstream.py +3 -11
- StreamingCommunity/Api/Site/1337xx/__init__.py +26 -12
- StreamingCommunity/Api/Site/1337xx/site.py +3 -10
- StreamingCommunity/Api/Site/altadefinizione/__init__.py +108 -0
- StreamingCommunity/Api/Site/altadefinizione/film.py +128 -0
- StreamingCommunity/Api/Site/altadefinizione/series.py +209 -0
- StreamingCommunity/Api/Site/altadefinizione/site.py +93 -0
- StreamingCommunity/Api/Site/altadefinizione/util/ScrapeSerie.py +72 -0
- StreamingCommunity/Api/Site/animeunity/__init__.py +53 -32
- StreamingCommunity/Api/Site/animeunity/film_serie.py +6 -2
- StreamingCommunity/Api/Site/animeunity/site.py +1 -11
- StreamingCommunity/Api/Site/cb01new/__init__.py +26 -14
- StreamingCommunity/Api/Site/cb01new/site.py +7 -16
- StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +26 -15
- StreamingCommunity/Api/Site/ddlstreamitaly/site.py +1 -9
- StreamingCommunity/Api/Site/guardaserie/__init__.py +23 -11
- StreamingCommunity/Api/Site/guardaserie/site.py +3 -10
- StreamingCommunity/Api/Site/mostraguarda/__init__.py +27 -7
- StreamingCommunity/Api/Site/streamingcommunity/__init__.py +50 -27
- StreamingCommunity/Api/Site/streamingcommunity/series.py +34 -12
- StreamingCommunity/Api/Site/streamingcommunity/site.py +14 -10
- StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +38 -17
- StreamingCommunity/Api/Template/Class/SearchType.py +1 -1
- StreamingCommunity/Api/Template/Util/__init__.py +0 -1
- StreamingCommunity/Api/Template/Util/manage_ep.py +1 -0
- StreamingCommunity/Api/Template/config_loader.py +0 -4
- StreamingCommunity/Lib/Downloader/HLS/downloader.py +2 -2
- StreamingCommunity/Lib/Downloader/HLS/segments.py +1 -1
- StreamingCommunity/Lib/Downloader/MP4/downloader.py +8 -6
- StreamingCommunity/Lib/M3U8/estimator.py +3 -3
- StreamingCommunity/Upload/version.py +1 -1
- StreamingCommunity/Util/config_json.py +2 -11
- StreamingCommunity/Util/table.py +12 -2
- StreamingCommunity/__init__.py +6 -0
- StreamingCommunity/global_search.py +315 -0
- StreamingCommunity/run.py +27 -3
- {StreamingCommunity-2.9.3.dist-info → streamingcommunity-2.9.5.dist-info}/METADATA +128 -16
- streamingcommunity-2.9.5.dist-info/RECORD +80 -0
- {StreamingCommunity-2.9.3.dist-info → streamingcommunity-2.9.5.dist-info}/WHEEL +1 -1
- StreamingCommunity/Api/Template/Util/get_domain.py +0 -100
- StreamingCommunity-2.9.3.dist-info/RECORD +0 -75
- {StreamingCommunity-2.9.3.dist-info → streamingcommunity-2.9.5.dist-info}/LICENSE +0 -0
- {StreamingCommunity-2.9.3.dist-info → streamingcommunity-2.9.5.dist-info}/entry_points.txt +0 -0
- {StreamingCommunity-2.9.3.dist-info → streamingcommunity-2.9.5.dist-info}/top_level.txt +0 -0
|
@@ -31,10 +31,6 @@ class SiteConstant:
|
|
|
31
31
|
def ROOT_PATH(self):
|
|
32
32
|
return config_manager.get('OUT_FOLDER', 'root_path')
|
|
33
33
|
|
|
34
|
-
@property
|
|
35
|
-
def DOMAIN_NOW(self):
|
|
36
|
-
return config_manager.get_site(self.SITE_NAME, 'domain')
|
|
37
|
-
|
|
38
34
|
@property
|
|
39
35
|
def FULL_URL(self):
|
|
40
36
|
return config_manager.get_site(self.SITE_NAME, 'full_url').rstrip('/')
|
|
@@ -438,13 +438,13 @@ class HLS_Downloader:
|
|
|
438
438
|
return response
|
|
439
439
|
|
|
440
440
|
if GET_ONLY_LINK:
|
|
441
|
-
console.print(f"URL: {self.m3u8_url}[/bold red]")
|
|
441
|
+
console.print(f"URL: [bold red]{self.m3u8_url}[/bold red]")
|
|
442
442
|
return {
|
|
443
443
|
'path': None,
|
|
444
444
|
'url': self.m3u8_url,
|
|
445
445
|
'is_master': getattr(self.m3u8_manager, 'is_master', None),
|
|
446
446
|
'msg': None,
|
|
447
|
-
'error':
|
|
447
|
+
'error': None,
|
|
448
448
|
'stopped': True
|
|
449
449
|
}
|
|
450
450
|
|
|
@@ -37,7 +37,7 @@ from ...M3U8 import (
|
|
|
37
37
|
# Config
|
|
38
38
|
TQDM_DELAY_WORKER = config_manager.get_float('M3U8_DOWNLOAD', 'tqdm_delay')
|
|
39
39
|
REQUEST_MAX_RETRY = config_manager.get_int('REQUESTS', 'max_retry')
|
|
40
|
-
REQUEST_VERIFY = config_manager.
|
|
40
|
+
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
|
|
41
41
|
DEFAULT_VIDEO_WORKERS = config_manager.get_int('M3U8_DOWNLOAD', 'default_video_workser')
|
|
42
42
|
DEFAULT_AUDIO_WORKERS = config_manager.get_int('M3U8_DOWNLOAD', 'default_audio_workser')
|
|
43
43
|
MAX_TIMEOOUT = config_manager.get_int("REQUESTS", "timeout")
|
|
@@ -30,7 +30,7 @@ from ...FFmpeg import print_duration_table
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
# Config
|
|
33
|
-
REQUEST_VERIFY = config_manager.
|
|
33
|
+
REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify')
|
|
34
34
|
GET_ONLY_LINK = config_manager.get_bool('M3U8_PARSER', 'get_only_link')
|
|
35
35
|
REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
|
|
36
36
|
TELEGRAM_BOT = config_manager.get_bool('DEFAULT', 'telegram_bot')
|
|
@@ -110,11 +110,12 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
|
|
|
110
110
|
interrupt_handler = InterruptHandler()
|
|
111
111
|
original_handler = signal.signal(signal.SIGINT, partial(signal_handler, interrupt_handler=interrupt_handler, original_handler=signal.getsignal(signal.SIGINT)))
|
|
112
112
|
|
|
113
|
+
# Ensure the output directory exists
|
|
114
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
115
|
+
|
|
113
116
|
try:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
with httpx.Client(transport=transport, timeout=httpx.Timeout(60)) as client:
|
|
117
|
-
with client.stream("GET", url, headers=headers, timeout=REQUEST_TIMEOUT) as response:
|
|
117
|
+
with httpx.Client() as client:
|
|
118
|
+
with client.stream("GET", url, headers=headers) as response:
|
|
118
119
|
response.raise_for_status()
|
|
119
120
|
total = int(response.headers.get('content-length', 0))
|
|
120
121
|
|
|
@@ -122,6 +123,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
|
|
|
122
123
|
console.print("[bold red]No video stream found.[/bold red]")
|
|
123
124
|
return None, False
|
|
124
125
|
|
|
126
|
+
# Create a fancy progress bar
|
|
125
127
|
progress_bar = tqdm(
|
|
126
128
|
total=total,
|
|
127
129
|
ascii='░▒█',
|
|
@@ -134,7 +136,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
|
|
|
134
136
|
unit_scale=True,
|
|
135
137
|
desc='Downloading',
|
|
136
138
|
mininterval=0.05,
|
|
137
|
-
file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment.
|
|
139
|
+
file=sys.stdout # Using file=sys.stdout to force in-place updates because sys.stderr may not support carriage returns in this environment.
|
|
138
140
|
)
|
|
139
141
|
|
|
140
142
|
downloaded = 0
|
|
@@ -119,15 +119,15 @@ class M3U8_Ts_Estimator:
|
|
|
119
119
|
|
|
120
120
|
retry_count = self.segments_instance.active_retries if self.segments_instance else 0
|
|
121
121
|
progress_str = (
|
|
122
|
-
f"{Colors.GREEN}{number_file_total_size} {Colors.
|
|
123
|
-
f"{Colors.WHITE} {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}"
|
|
122
|
+
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}"
|
|
123
|
+
f"{Colors.WHITE}, {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}"
|
|
124
124
|
f"{Colors.WHITE}, {Colors.GREEN}CRR {Colors.RED}{retry_count} "
|
|
125
125
|
)
|
|
126
126
|
|
|
127
127
|
else:
|
|
128
128
|
retry_count = self.segments_instance.active_retries if self.segments_instance else 0
|
|
129
129
|
progress_str = (
|
|
130
|
-
f"{Colors.GREEN}{number_file_total_size} {Colors.
|
|
130
|
+
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}"
|
|
131
131
|
f"{Colors.WHITE}, {Colors.GREEN}CRR {Colors.RED}{retry_count} "
|
|
132
132
|
)
|
|
133
133
|
|
|
@@ -196,6 +196,7 @@ class ConfigManager:
|
|
|
196
196
|
except Exception as e:
|
|
197
197
|
logging.error(f"Error reading configuration file: {e}")
|
|
198
198
|
console.print(f"[bold red]Failed to read configuration:[/bold red] {str(e)}")
|
|
199
|
+
sys.exit(0)
|
|
199
200
|
|
|
200
201
|
def download_requirements(self, url: str, filename: str) -> None:
|
|
201
202
|
"""
|
|
@@ -255,14 +256,7 @@ class ConfigManager:
|
|
|
255
256
|
sites_info = []
|
|
256
257
|
for site, info in examples:
|
|
257
258
|
sites_info.append(f"[cyan]{site}[/cyan]: {info.get('full_url', 'N/A')}")
|
|
258
|
-
|
|
259
|
-
console.print("[bold cyan]Sample sites:[/bold cyan]")
|
|
260
|
-
for info in sites_info:
|
|
261
|
-
console.print(f" {info}")
|
|
262
|
-
|
|
263
|
-
if site_count > 3:
|
|
264
|
-
console.print(f" ... and {site_count - 3} more")
|
|
265
|
-
|
|
259
|
+
|
|
266
260
|
else:
|
|
267
261
|
console.print("[bold yellow]API returned empty data set[/bold yellow]")
|
|
268
262
|
else:
|
|
@@ -421,9 +415,6 @@ class ConfigManager:
|
|
|
421
415
|
config_manager = ConfigManager()
|
|
422
416
|
config_manager.read_config()
|
|
423
417
|
|
|
424
|
-
|
|
425
|
-
import sys
|
|
426
|
-
|
|
427
418
|
def get_use_large_bar():
|
|
428
419
|
"""
|
|
429
420
|
Determines whether the large bar feature should be enabled.
|
StreamingCommunity/Util/table.py
CHANGED
|
@@ -147,9 +147,14 @@ class TVShowManager:
|
|
|
147
147
|
if not force_int_input:
|
|
148
148
|
prompt_msg = ("\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, "
|
|
149
149
|
"[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")
|
|
150
|
+
telegram_msg = "Menu di selezione degli episodi: \n\n" \
|
|
151
|
+
"- Inserisci il numero dell'episodio (ad esempio, 1)\n" \
|
|
152
|
+
"- Inserisci * per scaricare tutti gli episodi\n" \
|
|
153
|
+
"- Inserisci un intervallo di episodi (ad esempio, 1-2) per scaricare da un episodio all'altro\n" \
|
|
154
|
+
"- Inserisci (ad esempio, 3-*) per scaricare dall'episodio specificato fino alla fine della serie"
|
|
150
155
|
|
|
151
156
|
if is_telegram:
|
|
152
|
-
key = bot.ask("select_title_episode",
|
|
157
|
+
key = bot.ask("select_title_episode", telegram_msg, None)
|
|
153
158
|
else:
|
|
154
159
|
key = Prompt.ask(prompt_msg)
|
|
155
160
|
else:
|
|
@@ -183,9 +188,14 @@ class TVShowManager:
|
|
|
183
188
|
if not force_int_input:
|
|
184
189
|
prompt_msg = ("\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, "
|
|
185
190
|
"[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")
|
|
191
|
+
telegram_msg = "Menu di selezione degli episodi: \n\n" \
|
|
192
|
+
"- Inserisci il numero dell'episodio (ad esempio, 1)\n" \
|
|
193
|
+
"- Inserisci * per scaricare tutti gli episodi\n" \
|
|
194
|
+
"- Inserisci un intervallo di episodi (ad esempio, 1-2) per scaricare da un episodio all'altro\n" \
|
|
195
|
+
"- Inserisci (ad esempio, 3-*) per scaricare dall'episodio specificato fino alla fine della serie"
|
|
186
196
|
|
|
187
197
|
if is_telegram:
|
|
188
|
-
key = bot.ask("select_title_episode",
|
|
198
|
+
key = bot.ask("select_title_episode", telegram_msg, None)
|
|
189
199
|
else:
|
|
190
200
|
key = Prompt.ask(prompt_msg)
|
|
191
201
|
else:
|
StreamingCommunity/__init__.py
CHANGED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# 17.03.25
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
import time
|
|
6
|
+
import glob
|
|
7
|
+
import logging
|
|
8
|
+
import importlib
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# External library
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
from rich.prompt import Prompt
|
|
14
|
+
from rich.table import Table
|
|
15
|
+
from rich.progress import Progress
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Internal utilities
|
|
19
|
+
from StreamingCommunity.Util.message import start_message
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Variable
|
|
23
|
+
console = Console()
|
|
24
|
+
msg = Prompt()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# !!! DA METTERE IN COMUNE CON QUELLA DI RUN
|
|
28
|
+
def load_search_functions():
|
|
29
|
+
modules = []
|
|
30
|
+
loaded_functions = {}
|
|
31
|
+
excluded_sites = set()
|
|
32
|
+
|
|
33
|
+
# Find api home directory
|
|
34
|
+
if getattr(sys, 'frozen', False): # Modalità PyInstaller
|
|
35
|
+
base_path = os.path.join(sys._MEIPASS, "StreamingCommunity")
|
|
36
|
+
else:
|
|
37
|
+
base_path = os.path.dirname(__file__)
|
|
38
|
+
|
|
39
|
+
api_dir = os.path.join(base_path, 'Api', 'Site')
|
|
40
|
+
init_files = glob.glob(os.path.join(api_dir, '*', '__init__.py'))
|
|
41
|
+
|
|
42
|
+
# Retrieve modules and their indices
|
|
43
|
+
for init_file in init_files:
|
|
44
|
+
|
|
45
|
+
# Get folder name as module name
|
|
46
|
+
module_name = os.path.basename(os.path.dirname(init_file))
|
|
47
|
+
|
|
48
|
+
# Se il modulo è nella lista da escludere, saltalo
|
|
49
|
+
if module_name in excluded_sites:
|
|
50
|
+
continue
|
|
51
|
+
|
|
52
|
+
logging.info(f"Load module name: {module_name}")
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
# Dynamically import the module
|
|
56
|
+
mod = importlib.import_module(f'StreamingCommunity.Api.Site.{module_name}')
|
|
57
|
+
|
|
58
|
+
# Get 'indice' from the module
|
|
59
|
+
indice = getattr(mod, 'indice', 0)
|
|
60
|
+
is_deprecate = bool(getattr(mod, '_deprecate', True))
|
|
61
|
+
use_for = getattr(mod, '_useFor', 'other')
|
|
62
|
+
|
|
63
|
+
if not is_deprecate:
|
|
64
|
+
modules.append((module_name, indice, use_for))
|
|
65
|
+
|
|
66
|
+
except Exception as e:
|
|
67
|
+
console.print(f"[red]Failed to import module {module_name}: {str(e)}")
|
|
68
|
+
|
|
69
|
+
# Sort modules by 'indice'
|
|
70
|
+
modules.sort(key=lambda x: x[1])
|
|
71
|
+
|
|
72
|
+
# Load search functions in the sorted order
|
|
73
|
+
for module_name, _, use_for in modules:
|
|
74
|
+
|
|
75
|
+
# Construct a unique alias for the module
|
|
76
|
+
module_alias = f'{module_name}_search'
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
|
|
80
|
+
# Dynamically import the module
|
|
81
|
+
mod = importlib.import_module(f'StreamingCommunity.Api.Site.{module_name}')
|
|
82
|
+
|
|
83
|
+
# Get the search function from the module (assuming the function is named 'search' and defined in __init__.py)
|
|
84
|
+
search_function = getattr(mod, 'search')
|
|
85
|
+
|
|
86
|
+
# Add the function to the loaded functions dictionary
|
|
87
|
+
loaded_functions[module_alias] = (search_function, use_for)
|
|
88
|
+
|
|
89
|
+
except Exception as e:
|
|
90
|
+
console.print(f"[red]Failed to load search function from module {module_name}: {str(e)}")
|
|
91
|
+
|
|
92
|
+
return loaded_functions
|
|
93
|
+
|
|
94
|
+
def global_search(search_terms: str = None, selected_sites: list = None):
|
|
95
|
+
"""
|
|
96
|
+
Perform a search across multiple sites based on selection.
|
|
97
|
+
|
|
98
|
+
Parameters:
|
|
99
|
+
search_terms (str, optional): The terms to search for. If None, will prompt the user.
|
|
100
|
+
selected_sites (list, optional): List of site aliases to search. If None, will search all sites.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
dict: Consolidated search results from all searched sites.
|
|
104
|
+
"""
|
|
105
|
+
search_functions = load_search_functions()
|
|
106
|
+
all_results = {}
|
|
107
|
+
|
|
108
|
+
if search_terms is None:
|
|
109
|
+
search_terms = msg.ask("\n[purple]Enter search terms for global search: ").strip()
|
|
110
|
+
|
|
111
|
+
# Organize sites by category for better display
|
|
112
|
+
sites_by_category = {}
|
|
113
|
+
for alias, (func, category) in search_functions.items():
|
|
114
|
+
if category not in sites_by_category:
|
|
115
|
+
sites_by_category[category] = []
|
|
116
|
+
sites_by_category[category].append((alias, func))
|
|
117
|
+
|
|
118
|
+
# If no sites are specifically selected, prompt the user
|
|
119
|
+
if selected_sites is None:
|
|
120
|
+
console.print("\n[bold green]Select sites to search:[/bold green]")
|
|
121
|
+
console.print("[bold cyan]1.[/bold cyan] Search all sites")
|
|
122
|
+
console.print("[bold cyan]2.[/bold cyan] Search by category")
|
|
123
|
+
console.print("[bold cyan]3.[/bold cyan] Select specific sites")
|
|
124
|
+
|
|
125
|
+
choice = msg.ask("[green]Enter your choice (1-3)", choices=["1", "2", "3"], default="1")
|
|
126
|
+
|
|
127
|
+
if choice == "1":
|
|
128
|
+
# Search all sites
|
|
129
|
+
selected_sites = list(search_functions.keys())
|
|
130
|
+
|
|
131
|
+
elif choice == "2":
|
|
132
|
+
# Search by category
|
|
133
|
+
console.print("\n[bold green]Select categories to search:[/bold green]")
|
|
134
|
+
for i, category in enumerate(sites_by_category.keys(), 1):
|
|
135
|
+
console.print(f"[bold cyan]{i}.[/bold cyan] {category.capitalize()}")
|
|
136
|
+
|
|
137
|
+
category_choices = msg.ask("[green]Enter category numbers separated by commas", default="1")
|
|
138
|
+
selected_categories = [list(sites_by_category.keys())[int(c.strip())-1] for c in category_choices.split(",")]
|
|
139
|
+
|
|
140
|
+
selected_sites = []
|
|
141
|
+
for category in selected_categories:
|
|
142
|
+
for alias, _ in sites_by_category.get(category, []):
|
|
143
|
+
selected_sites.append(alias)
|
|
144
|
+
|
|
145
|
+
else:
|
|
146
|
+
# Select specific sites
|
|
147
|
+
console.print("\n[bold green]Select specific sites to search:[/bold green]")
|
|
148
|
+
|
|
149
|
+
for i, (alias, _) in enumerate(search_functions.items(), 1):
|
|
150
|
+
site_name = alias.split("_")[0].capitalize()
|
|
151
|
+
console.print(f"[bold cyan]{i}.[/bold cyan] {site_name}")
|
|
152
|
+
|
|
153
|
+
site_choices = msg.ask("[green]Enter site numbers separated by commas", default="1")
|
|
154
|
+
selected_indices = [int(c.strip())-1 for c in site_choices.split(",")]
|
|
155
|
+
selected_sites = [list(search_functions.keys())[i] for i in selected_indices if i < len(search_functions)]
|
|
156
|
+
|
|
157
|
+
# Display progress information
|
|
158
|
+
console.print(f"\n[bold green]Searching for:[/bold green] [yellow]{search_terms}[/yellow]")
|
|
159
|
+
console.print(f"[bold green]Searching across:[/bold green] {len(selected_sites)} sites")
|
|
160
|
+
|
|
161
|
+
with Progress() as progress:
|
|
162
|
+
search_task = progress.add_task("[cyan]Searching...", total=len(selected_sites))
|
|
163
|
+
|
|
164
|
+
# Search each selected site
|
|
165
|
+
for alias in selected_sites:
|
|
166
|
+
site_name = alias.split("_")[0].capitalize()
|
|
167
|
+
progress.update(search_task, description=f"[cyan]Searching {site_name}...")
|
|
168
|
+
|
|
169
|
+
func, _ = search_functions[alias]
|
|
170
|
+
try:
|
|
171
|
+
# Call the search function with get_onlyDatabase=True to get database object
|
|
172
|
+
database = func(search_terms, get_onlyDatabase=True)
|
|
173
|
+
|
|
174
|
+
# Check if database has media_list attribute and it's not empty
|
|
175
|
+
if database and hasattr(database, 'media_list') and len(database.media_list) > 0:
|
|
176
|
+
# Store media_list items with additional source information
|
|
177
|
+
all_results[alias] = []
|
|
178
|
+
for element in database.media_list:
|
|
179
|
+
# Convert element to dictionary if it's an object
|
|
180
|
+
if hasattr(element, '__dict__'):
|
|
181
|
+
item_dict = element.__dict__.copy()
|
|
182
|
+
else:
|
|
183
|
+
item_dict = {} # Fallback for non-object items
|
|
184
|
+
|
|
185
|
+
# Add source information
|
|
186
|
+
item_dict['source'] = site_name
|
|
187
|
+
item_dict['source_alias'] = alias
|
|
188
|
+
all_results[alias].append(item_dict)
|
|
189
|
+
|
|
190
|
+
console.print(f"[green]Found {len(database.media_list)} results from {site_name}")
|
|
191
|
+
|
|
192
|
+
except Exception as e:
|
|
193
|
+
console.print(f"[bold red]Error searching {site_name}:[/bold red] {str(e)}")
|
|
194
|
+
|
|
195
|
+
progress.update(search_task, advance=1)
|
|
196
|
+
|
|
197
|
+
# Display the consolidated results
|
|
198
|
+
if all_results:
|
|
199
|
+
all_media_items = []
|
|
200
|
+
for alias, results in all_results.items():
|
|
201
|
+
for item in results:
|
|
202
|
+
all_media_items.append(item)
|
|
203
|
+
|
|
204
|
+
# Display consolidated results
|
|
205
|
+
display_consolidated_results(all_media_items, search_terms)
|
|
206
|
+
|
|
207
|
+
# Allow user to select an item
|
|
208
|
+
selected_item = select_from_consolidated_results(all_media_items)
|
|
209
|
+
if selected_item:
|
|
210
|
+
# Process the selected item - download or further actions
|
|
211
|
+
process_selected_item(selected_item, search_functions)
|
|
212
|
+
|
|
213
|
+
else:
|
|
214
|
+
console.print(f"\n[bold red]No results found for:[/bold red] [yellow]{search_terms}[/yellow]")
|
|
215
|
+
|
|
216
|
+
# Optionally offer to search again or return to main menu
|
|
217
|
+
if msg.ask("[green]Search again? (y/n)", choices=["y", "n"], default="y") == "y":
|
|
218
|
+
global_search()
|
|
219
|
+
|
|
220
|
+
return all_results
|
|
221
|
+
|
|
222
|
+
def display_consolidated_results(all_media_items, search_terms):
|
|
223
|
+
"""
|
|
224
|
+
Display consolidated search results from multiple sites.
|
|
225
|
+
|
|
226
|
+
Parameters:
|
|
227
|
+
all_media_items (list): List of media items from all searched sites.
|
|
228
|
+
search_terms (str): The search terms used.
|
|
229
|
+
"""
|
|
230
|
+
time.sleep(1)
|
|
231
|
+
start_message()
|
|
232
|
+
|
|
233
|
+
console.print(f"\n[bold green]Search results for:[/bold green] [yellow]{search_terms}[/yellow] \n")
|
|
234
|
+
|
|
235
|
+
table = Table(show_header=True, header_style="bold cyan")
|
|
236
|
+
table.add_column("#", style="dim", width=4)
|
|
237
|
+
table.add_column("Title", min_width=20)
|
|
238
|
+
table.add_column("Type", width=15)
|
|
239
|
+
table.add_column("Source", width=25)
|
|
240
|
+
|
|
241
|
+
for i, item in enumerate(all_media_items, 1):
|
|
242
|
+
|
|
243
|
+
# Extract values from item dict, with fallbacks if keys don't exist
|
|
244
|
+
title = item.get('title', item.get('name', 'Unknown'))
|
|
245
|
+
media_type = item.get('type', item.get('media_type', 'Unknown'))
|
|
246
|
+
source = item.get('source', 'Unknown')
|
|
247
|
+
|
|
248
|
+
table.add_row(
|
|
249
|
+
str(i),
|
|
250
|
+
str(title),
|
|
251
|
+
str(media_type),
|
|
252
|
+
str(source),
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
console.print(table)
|
|
256
|
+
|
|
257
|
+
def select_from_consolidated_results(all_media_items):
|
|
258
|
+
"""
|
|
259
|
+
Allow user to select an item from consolidated results.
|
|
260
|
+
|
|
261
|
+
Parameters:
|
|
262
|
+
all_media_items (list): List of media items from all searched sites.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
dict: The selected media item or None if no selection was made.
|
|
266
|
+
"""
|
|
267
|
+
if not all_media_items:
|
|
268
|
+
return None
|
|
269
|
+
|
|
270
|
+
max_index = len(all_media_items)
|
|
271
|
+
choice = msg.ask(
|
|
272
|
+
f"[green]Select item # (1-{max_index}) or 0 to cancel",
|
|
273
|
+
choices=[str(i) for i in range(max_index + 1)],
|
|
274
|
+
default="1",
|
|
275
|
+
show_choices=False
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
if choice == "0":
|
|
279
|
+
return None
|
|
280
|
+
|
|
281
|
+
return all_media_items[int(choice) - 1]
|
|
282
|
+
|
|
283
|
+
def process_selected_item(selected_item, search_functions):
|
|
284
|
+
"""
|
|
285
|
+
Process the selected item - download the media using the appropriate site API.
|
|
286
|
+
|
|
287
|
+
Parameters:
|
|
288
|
+
selected_item (dict): The selected media item.
|
|
289
|
+
search_functions (dict): Dictionary of search functions by alias.
|
|
290
|
+
"""
|
|
291
|
+
source_alias = selected_item.get('source_alias')
|
|
292
|
+
if not source_alias or source_alias not in search_functions:
|
|
293
|
+
console.print("[bold red]Error: Cannot process this item - source information missing.[/bold red]")
|
|
294
|
+
return
|
|
295
|
+
|
|
296
|
+
# Get the appropriate search function for this source
|
|
297
|
+
func, _ = search_functions[source_alias]
|
|
298
|
+
|
|
299
|
+
console.print(f"\n[bold green]Processing selection from:[/bold green] {selected_item.get('source')}")
|
|
300
|
+
|
|
301
|
+
# Extract necessary information to pass to the site's search function
|
|
302
|
+
item_id = selected_item.get('id', selected_item.get('media_id'))
|
|
303
|
+
item_type = selected_item.get('type', selected_item.get('media_type', 'unknown'))
|
|
304
|
+
item_title = selected_item.get('title', selected_item.get('name', 'Unknown'))
|
|
305
|
+
|
|
306
|
+
if item_id:
|
|
307
|
+
console.print(f"[bold green]Selected item:[/bold green] {item_title} (ID: {item_id}, Type: {item_type})")
|
|
308
|
+
|
|
309
|
+
# Call the site's search function with direct_item parameter to process download
|
|
310
|
+
try:
|
|
311
|
+
func(direct_item=selected_item)
|
|
312
|
+
except Exception as e:
|
|
313
|
+
console.print(f"[bold red]Error processing download:[/bold red] {str(e)}")
|
|
314
|
+
else:
|
|
315
|
+
console.print("[bold red]Error: Item ID not found.[/bold red]")
|
StreamingCommunity/run.py
CHANGED
|
@@ -18,6 +18,7 @@ from rich.prompt import Prompt
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
# Internal utilities
|
|
21
|
+
from .global_search import global_search
|
|
21
22
|
from StreamingCommunity.Util.message import start_message
|
|
22
23
|
from StreamingCommunity.Util.config_json import config_manager
|
|
23
24
|
from StreamingCommunity.Util.os import os_summary
|
|
@@ -54,6 +55,7 @@ def run_function(func: Callable[..., None], close_console: bool = False, search_
|
|
|
54
55
|
func(search_terms)
|
|
55
56
|
|
|
56
57
|
|
|
58
|
+
# !!! DA METTERE IN COMUNE CON QUELLA DI GLOBAL
|
|
57
59
|
def load_search_functions():
|
|
58
60
|
modules = []
|
|
59
61
|
loaded_functions = {}
|
|
@@ -237,6 +239,11 @@ def main(script_id = 0):
|
|
|
237
239
|
'--specific_list_subtitles', type=str, help='Comma-separated list of specific subtitle languages to download (e.g., eng,spa).'
|
|
238
240
|
)
|
|
239
241
|
|
|
242
|
+
# Add global search option
|
|
243
|
+
parser.add_argument(
|
|
244
|
+
'--global', action='store_true', help='Perform a global search across multiple sites.'
|
|
245
|
+
)
|
|
246
|
+
|
|
240
247
|
# Add arguments for search functions
|
|
241
248
|
color_map = {
|
|
242
249
|
"anime": "red",
|
|
@@ -253,6 +260,7 @@ def main(script_id = 0):
|
|
|
253
260
|
parser.add_argument(f'-{short_option}', f'--{long_option}', action='store_true', help=f'Search for {alias.split("_")[0]} on streaming platforms.')
|
|
254
261
|
|
|
255
262
|
parser.add_argument('-s', '--search', default=None, help='Search terms')
|
|
263
|
+
|
|
256
264
|
# Parse command-line arguments
|
|
257
265
|
args = parser.parse_args()
|
|
258
266
|
|
|
@@ -280,6 +288,11 @@ def main(script_id = 0):
|
|
|
280
288
|
|
|
281
289
|
config_manager.write_config()
|
|
282
290
|
|
|
291
|
+
# Check if global search is requested
|
|
292
|
+
if getattr(args, 'global'):
|
|
293
|
+
global_search(search_terms)
|
|
294
|
+
return
|
|
295
|
+
|
|
283
296
|
# Map command-line arguments to functions
|
|
284
297
|
arg_to_function = {alias: func for alias, (func, _) in search_functions.items()}
|
|
285
298
|
|
|
@@ -295,13 +308,18 @@ def main(script_id = 0):
|
|
|
295
308
|
# Create dynamic prompt message and choices
|
|
296
309
|
choice_labels = {str(i): (alias.split("_")[0].capitalize(), use_for) for i, (alias, (_, use_for)) in enumerate(search_functions.items())}
|
|
297
310
|
|
|
311
|
+
# Add global search option to the menu
|
|
312
|
+
#global_search_key = str(len(choice_labels))
|
|
313
|
+
#choice_labels[global_search_key] = ("Global Search", "all")
|
|
314
|
+
#input_to_function[global_search_key] = global_search
|
|
315
|
+
|
|
298
316
|
# Display the category legend in a single line
|
|
299
317
|
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
|
|
300
318
|
console.print(f"\n[bold green]Category Legend:[/bold green] {legend_text}")
|
|
301
319
|
|
|
302
320
|
# Construct the prompt message with color-coded site names
|
|
303
321
|
prompt_message = "[green]Insert category [white](" + ", ".join(
|
|
304
|
-
[f"{key}: [{color_map
|
|
322
|
+
[f"{key}: [{color_map.get(label[1], 'white')}]{label[0]}[/{color_map.get(label[1], 'white')}]" for key, label in choice_labels.items()]
|
|
305
323
|
) + "[white])"
|
|
306
324
|
|
|
307
325
|
if TELEGRAM_BOT:
|
|
@@ -330,10 +348,16 @@ def main(script_id = 0):
|
|
|
330
348
|
|
|
331
349
|
# Run the corresponding function based on user input
|
|
332
350
|
if category in input_to_function:
|
|
333
|
-
|
|
351
|
+
"""if category == global_search_key:
|
|
352
|
+
# Run global search
|
|
353
|
+
run_function(input_to_function[category], search_terms=search_terms)
|
|
354
|
+
|
|
355
|
+
else:"""
|
|
356
|
+
|
|
357
|
+
# Run normal site-specific search
|
|
358
|
+
run_function(input_to_function[category], search_terms=search_terms)
|
|
334
359
|
|
|
335
360
|
else:
|
|
336
|
-
|
|
337
361
|
if TELEGRAM_BOT:
|
|
338
362
|
bot.send_message(f"Categoria non valida", None)
|
|
339
363
|
|