MCPcopy Create free account
hub / github.com/ellite/OneDL / select_files_interactive

Function select_files_interactive

OneDL.py:252–289  ·  view source on GitHub ↗

Unified selection handler for all debrid providers. files: list of dicts or strings (anything indexable) prompt: custom prompt string Returns: list of 0-based indexes

(files, prompt="Enter selection")

Source from the content-addressed store, hash-verified

250 return urls
251
252def select_files_interactive(files, prompt="Enter selection"):
253 """
254 Unified selection handler for all debrid providers.
255
256 files: list of dicts or strings (anything indexable)
257 prompt: custom prompt string
258
259 Returns: list of 0-based indexes
260 """
261 max_index = len(files)
262
263 print(f"{CYAN}{prompt}:{RESET}")
264 for idx, f in enumerate(files, 1):
265 if isinstance(f, dict):
266 name = f.get("name") or f.get("short_name") or f.get("path") or str(f)
267 else:
268 name = str(f)
269 size = f.get("size") if isinstance(f, dict) else None
270 if size:
271 mb = size // (1024 * 1024)
272 print(f"{YELLOW}{idx}{RESET}: {name} {CYAN}({mb} MB){RESET}")
273 else:
274 print(f"{YELLOW}{idx}{RESET}: {name}")
275
276 choice = input(
277 f"{CYAN}Enter numbers, commas, ranges (e.g. 1,3-5) or 'all' (default all): {RESET}"
278 ).strip()
279
280 # Default = all
281 if not choice or choice.lower() == "all":
282 return list(range(max_index))
283
284 # Use your existing range parser
285 raw = parse_selection(choice, max_index)
286
287 selected = [i - 1 for i in raw if 1 <= i <= max_index]
288
289 return selected
290
291def show_progress_factory():
292 start_time = [time.time()]

Callers 8

get_urls_from_fileFunction · 0.85
get_real_debrid_linksFunction · 0.85
get_alldebrid_linksFunction · 0.85
get_premiumize_linksFunction · 0.85
get_torbox_linksFunction · 0.85
get_debrid_link_linksFunction · 0.85

Calls 1

parse_selectionFunction · 0.85

Tested by

no test coverage detected