core: Enhance category selection.

This commit is contained in:
Lovi 2025-06-14 12:03:23 +02:00
parent aa6576699d
commit 5527c5d7ed
5 changed files with 73 additions and 34 deletions

View File

@ -75,7 +75,6 @@ jobs:
executable: StreamingCommunity_linux_previous executable: StreamingCommunity_linux_previous
separator: ':' separator: ':'
# ARM64 build
- os: ubuntu-latest - os: ubuntu-latest
artifact_name: StreamingCommunity_linux_arm64 artifact_name: StreamingCommunity_linux_arm64
executable: StreamingCommunity_linux_arm64 executable: StreamingCommunity_linux_arm64
@ -83,7 +82,6 @@ jobs:
architecture: arm64 architecture: arm64
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
# For ARM64, set architecture if present
defaults: defaults:
run: run:
shell: bash shell: bash

View File

@ -697,8 +697,14 @@ python test_run.py --specific_list_audio ita,eng --specific_list_subtitles eng,s
# Keep console open after download # Keep console open after download
python test_run.py --not_close true python test_run.py --not_close true
# Use global search # Use global searchAdd commentMore actions
python test_run.py --global -s "cars" python test_run.py --global -s "cars"
# Select specific category
python test_run.py --category 1 # Search in anime category
python test_run.py --category 2 # Search in movies & series
python test_run.py --category 3 # Search in series
python test_run.py --category 4 # Search in torrent category
``` ```
# Docker # Docker

View File

@ -156,7 +156,7 @@ class M3U8Manager:
If it's a master playlist, only selects video stream. If it's a master playlist, only selects video stream.
""" """
if not self.is_master: if not self.is_master:
self.video_url, self.video_res = self.m3u8_url, "0p" self.video_url, self.video_res = self.m3u8_url, "0px"
self.audio_streams = [] self.audio_streams = []
self.sub_streams = [] self.sub_streams = []
@ -165,7 +165,7 @@ class M3U8Manager:
self.video_url, self.video_res = self.parser._video.get_best_uri() self.video_url, self.video_res = self.parser._video.get_best_uri()
elif str(FILTER_CUSTOM_REOLUTION) == "worst": elif str(FILTER_CUSTOM_REOLUTION) == "worst":
self.video_url, self.video_res = self.parser._video.get_worst_uri() self.video_url, self.video_res = self.parser._video.get_worst_uri()
elif "p" in str(FILTER_CUSTOM_REOLUTION): elif "px" in str(FILTER_CUSTOM_REOLUTION):
self.video_url, self.video_res = self.parser._video.get_custom_uri(int(FILTER_CUSTOM_REOLUTION.replace("p", ""))) self.video_url, self.video_res = self.parser._video.get_custom_uri(int(FILTER_CUSTOM_REOLUTION.replace("p", "")))
else: else:
logging.error("Resolution not recognized.") logging.error("Resolution not recognized.")

View File

@ -35,7 +35,5 @@ def start_message():
if SHOW: if SHOW:
console.print(f"[purple]{msg}") console.print(f"[purple]{msg}")
separator = "_" * (console.width - 2)
# Print a decorative separator line using asterisks
separator = "_" * (console.width - 2) # Ridotto di 2 per il padding
console.print(f"[cyan]{separator}[/cyan]\n") console.print(f"[cyan]{separator}[/cyan]\n")

View File

@ -207,6 +207,13 @@ def main(script_id = 0):
"torrent": "white" "torrent": "white"
} }
category_map = {
1: "anime",
2: "film_&_serie",
3: "serie",
4: "torrent"
}
if TELEGRAM_BOT: if TELEGRAM_BOT:
bot = get_bot_instance() bot = get_bot_instance()
bot.send_message(f"Avviato script {script_id}", None) bot.send_message(f"Avviato script {script_id}", None)
@ -271,6 +278,11 @@ def main(script_id = 0):
'--global', action='store_true', help='Perform a global search across multiple sites.' '--global', action='store_true', help='Perform a global search across multiple sites.'
) )
# Add category selection argument
parser.add_argument(
'--category', type=int, help='Select category directly (1: anime, 2: film_&_serie, 3: serie, 4: torrent).'
)
# Add arguments for search functions # Add arguments for search functions
parser.add_argument('-s', '--search', default=None, help='Search terms') parser.add_argument('-s', '--search', default=None, help='Search terms')
@ -320,35 +332,60 @@ def main(script_id = 0):
except Exception as e: except Exception as e:
console.print(f"[red]Error mapping module {module_name}: {str(e)}") console.print(f"[red]Error mapping module {module_name}: {str(e)}")
# Display the category legend if args.category:
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()]) selected_category = category_map.get(args.category)
console.print(f"\n[bold green]Category Legend:[/bold green] {legend_text}") category_sites = []
for key, label in choice_labels.items():
if label[1] == selected_category:
category_sites.append((key, label[0]))
# Construct prompt with proper color mapping if len(category_sites) == 1:
prompt_message = "[green]Insert category [white](" + ", ".join( category = category_sites[0][0]
[f"[{color_map.get(label[1], 'white')}]{key}: {label[0]}[/{color_map.get(label[1], 'white')}]" console.print(f"[green]Selezionato automaticamente: {category_sites[0][1]}[/green]")
for key, label in choice_labels.items()]
) + "[white])"
if TELEGRAM_BOT: else:
category_legend_str = "Categorie: \n" + " | ".join([ sito_prompt_items = [f"[{color_map.get(selected_category, 'white')}]({k}) {v}[/{color_map.get(selected_category, 'white')}]"
f"{category.capitalize()}" for category in color_map.keys() for k, v in category_sites]
]) sito_prompt_line = ", ".join(sito_prompt_items)
prompt_message = "Inserisci il sito:\n" + "\n".join( if TELEGRAM_BOT:
[f"{key}: {label[0]}" for key, label in choice_labels.items()] console.print(f"\nInsert site: {sito_prompt_line}")
) category = bot.ask(
"select_site",
console.print(f"\n{prompt_message}") f"Insert site: {sito_prompt_line}",
None
category = bot.ask( )
"select_provider", else:
f"{category_legend_str}\n\n{prompt_message}", category = msg.ask(f"\n[cyan]Insert site: {sito_prompt_line}", choices=[k for k, _ in category_sites], show_choices=False)
None
)
else: else:
category = msg.ask(prompt_message, choices=list(choice_labels.keys()), default="0", show_choices=False, show_default=False) legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
console.print(f"\n[bold cyan]Category Legend:[/bold cyan] {legend_text}")
prompt_message = "[cyan]Insert site: " + ", ".join(
[f"[{color_map.get(label[1], 'white')}]({key}) {label[0]}[/{color_map.get(label[1], 'white')}]"
for key, label in choice_labels.items()]
)
if TELEGRAM_BOT:
category_legend_str = "Categorie: \n" + " | ".join([
f"{category.capitalize()}" for category in color_map.keys()
])
prompt_message_telegram = "Inserisci il sito:\n" + "\n".join(
[f"{key}: {label[0]}" for key, label in choice_labels.items()]
)
console.print(f"\n{prompt_message_telegram}")
category = bot.ask(
"select_provider",
f"{category_legend_str}\n\n{prompt_message_telegram}",
None
)
else:
category = msg.ask(prompt_message, choices=list(choice_labels.keys()), default="0", show_choices=False, show_default=False)
# Run the corresponding function based on user input # Run the corresponding function based on user input
if category in input_to_function: if category in input_to_function: