Skip to content

Commit 5527c5d

Browse files
committed
core: Enhance category selection.
1 parent aa65766 commit 5527c5d

File tree

5 files changed

+70
-31
lines changed

5 files changed

+70
-31
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ jobs:
7575
executable: StreamingCommunity_linux_previous
7676
separator: ':'
7777

78-
# ARM64 build
7978
- os: ubuntu-latest
8079
artifact_name: StreamingCommunity_linux_arm64
8180
executable: StreamingCommunity_linux_arm64
8281
separator: ':'
8382
architecture: arm64
8483

8584
runs-on: ${{ matrix.os }}
86-
# For ARM64, set architecture if present
8785
defaults:
8886
run:
8987
shell: bash

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,14 @@ python test_run.py --specific_list_audio ita,eng --specific_list_subtitles eng,s
697697
# Keep console open after download
698698
python test_run.py --not_close true
699699

700-
# Use global search
700+
# Use global searchAdd commentMore actions
701701
python test_run.py --global -s "cars"
702+
703+
# Select specific category
704+
python test_run.py --category 1 # Search in anime category
705+
python test_run.py --category 2 # Search in movies & series
706+
python test_run.py --category 3 # Search in series
707+
python test_run.py --category 4 # Search in torrent category
702708
```
703709

704710
# Docker

StreamingCommunity/Lib/Downloader/HLS/downloader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def select_streams(self):
156156
If it's a master playlist, only selects video stream.
157157
"""
158158
if not self.is_master:
159-
self.video_url, self.video_res = self.m3u8_url, "0p"
159+
self.video_url, self.video_res = self.m3u8_url, "0px"
160160
self.audio_streams = []
161161
self.sub_streams = []
162162

@@ -165,7 +165,7 @@ def select_streams(self):
165165
self.video_url, self.video_res = self.parser._video.get_best_uri()
166166
elif str(FILTER_CUSTOM_REOLUTION) == "worst":
167167
self.video_url, self.video_res = self.parser._video.get_worst_uri()
168-
elif "p" in str(FILTER_CUSTOM_REOLUTION):
168+
elif "px" in str(FILTER_CUSTOM_REOLUTION):
169169
self.video_url, self.video_res = self.parser._video.get_custom_uri(int(FILTER_CUSTOM_REOLUTION.replace("p", "")))
170170
else:
171171
logging.error("Resolution not recognized.")

StreamingCommunity/Util/message.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@ def start_message():
3535

3636
if SHOW:
3737
console.print(f"[purple]{msg}")
38-
39-
# Print a decorative separator line using asterisks
40-
separator = "_" * (console.width - 2) # Ridotto di 2 per il padding
38+
separator = "_" * (console.width - 2)
4139
console.print(f"[cyan]{separator}[/cyan]\n")

StreamingCommunity/run.py

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ def main(script_id = 0):
207207
"torrent": "white"
208208
}
209209

210+
category_map = {
211+
1: "anime",
212+
2: "film_&_serie",
213+
3: "serie",
214+
4: "torrent"
215+
}
216+
210217
if TELEGRAM_BOT:
211218
bot = get_bot_instance()
212219
bot.send_message(f"Avviato script {script_id}", None)
@@ -271,6 +278,11 @@ def main(script_id = 0):
271278
'--global', action='store_true', help='Perform a global search across multiple sites.'
272279
)
273280

281+
# Add category selection argument
282+
parser.add_argument(
283+
'--category', type=int, help='Select category directly (1: anime, 2: film_&_serie, 3: serie, 4: torrent).'
284+
)
285+
274286
# Add arguments for search functions
275287
parser.add_argument('-s', '--search', default=None, help='Search terms')
276288

@@ -320,35 +332,60 @@ def main(script_id = 0):
320332
except Exception as e:
321333
console.print(f"[red]Error mapping module {module_name}: {str(e)}")
322334

323-
# Display the category legend
324-
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
325-
console.print(f"\n[bold green]Category Legend:[/bold green] {legend_text}")
335+
if args.category:
336+
selected_category = category_map.get(args.category)
337+
category_sites = []
338+
for key, label in choice_labels.items():
339+
if label[1] == selected_category:
340+
category_sites.append((key, label[0]))
326341

327-
# Construct prompt with proper color mapping
328-
prompt_message = "[green]Insert category [white](" + ", ".join(
329-
[f"[{color_map.get(label[1], 'white')}]{key}: {label[0]}[/{color_map.get(label[1], 'white')}]"
330-
for key, label in choice_labels.items()]
331-
) + "[white])"
342+
if len(category_sites) == 1:
343+
category = category_sites[0][0]
344+
console.print(f"[green]Selezionato automaticamente: {category_sites[0][1]}[/green]")
332345

333-
if TELEGRAM_BOT:
334-
category_legend_str = "Categorie: \n" + " | ".join([
335-
f"{category.capitalize()}" for category in color_map.keys()
336-
])
346+
else:
347+
sito_prompt_items = [f"[{color_map.get(selected_category, 'white')}]({k}) {v}[/{color_map.get(selected_category, 'white')}]"
348+
for k, v in category_sites]
349+
sito_prompt_line = ", ".join(sito_prompt_items)
350+
351+
if TELEGRAM_BOT:
352+
console.print(f"\nInsert site: {sito_prompt_line}")
353+
category = bot.ask(
354+
"select_site",
355+
f"Insert site: {sito_prompt_line}",
356+
None
357+
)
358+
else:
359+
category = msg.ask(f"\n[cyan]Insert site: {sito_prompt_line}", choices=[k for k, _ in category_sites], show_choices=False)
337360

338-
prompt_message = "Inserisci il sito:\n" + "\n".join(
339-
[f"{key}: {label[0]}" for key, label in choice_labels.items()]
361+
else:
362+
legend_text = " | ".join([f"[{color}]{category.capitalize()}[/{color}]" for category, color in color_map.items()])
363+
console.print(f"\n[bold cyan]Category Legend:[/bold cyan] {legend_text}")
364+
365+
prompt_message = "[cyan]Insert site: " + ", ".join(
366+
[f"[{color_map.get(label[1], 'white')}]({key}) {label[0]}[/{color_map.get(label[1], 'white')}]"
367+
for key, label in choice_labels.items()]
340368
)
341369

342-
console.print(f"\n{prompt_message}")
370+
if TELEGRAM_BOT:
371+
category_legend_str = "Categorie: \n" + " | ".join([
372+
f"{category.capitalize()}" for category in color_map.keys()
373+
])
343374

344-
category = bot.ask(
345-
"select_provider",
346-
f"{category_legend_str}\n\n{prompt_message}",
347-
None
348-
)
375+
prompt_message_telegram = "Inserisci il sito:\n" + "\n".join(
376+
[f"{key}: {label[0]}" for key, label in choice_labels.items()]
377+
)
349378

350-
else:
351-
category = msg.ask(prompt_message, choices=list(choice_labels.keys()), default="0", show_choices=False, show_default=False)
379+
console.print(f"\n{prompt_message_telegram}")
380+
381+
category = bot.ask(
382+
"select_provider",
383+
f"{category_legend_str}\n\n{prompt_message_telegram}",
384+
None
385+
)
386+
387+
else:
388+
category = msg.ask(prompt_message, choices=list(choice_labels.keys()), default="0", show_choices=False, show_default=False)
352389

353390
# Run the corresponding function based on user input
354391
if category in input_to_function:
@@ -372,4 +409,4 @@ def main(script_id = 0):
372409
# Delete script_id
373410
script_id = TelegramSession.get_session()
374411
if script_id != "unknown":
375-
TelegramSession.deleteScriptId(script_id)
412+
TelegramSession.deleteScriptId(script_id)

0 commit comments

Comments
 (0)