spotify2subsonic/utils.py
2026-01-01 21:34:03 +02:00

14 lines
416 B
Python

def parse_selection(inp, max_index):
if inp.strip().lower() == "all":
return list(range(max_index))
result = set()
for part in inp.split(","):
part = part.strip()
if "-" in part:
a, b = part.split("-")
result.update(range(int(a) - 1, int(b)))
else:
result.add(int(part) - 1)
return sorted(i for i in result if 0 <= i < max_index)