Skip to content

Commit fbe7dc1

Browse files
nodeeeeeeclaude
andcommitted
Fix --download-material to accept list numbers (not just filenames)
The material list shows numbered rows (# column), but --download-material only accepted filename substrings. Entering "18" searched for files containing "18" in their name instead of selecting item #18. Now tries the input as a 1-based list index first, falling back to filename substring matching. This matches how --download-video already works with numbers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1956282 commit fbe7dc1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

downloader.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,13 +1378,26 @@ def main() -> None:
13781378
print_material_list(files, logs)
13791379
return
13801380

1381-
# ── --download-material FILENAME [FILENAME ...] ────────────────────────────
1381+
# ── --download-material NUMBER_OR_FILENAME [NUMBER_OR_FILENAME ...] ────────
13821382
if args.download_material:
13831383
print(f"\nDiscovering materials{' for course ' + str(args.course) if args.course else ''}...")
13841384
files = discover_materials(canvas, args.course)
13851385

13861386
targets: list[dict] = []
13871387
for query in args.download_material:
1388+
# Try as a 1-based list number first (matches the # column from --material-list)
1389+
try:
1390+
idx = int(query)
1391+
if 1 <= idx <= len(files):
1392+
targets.append(files[idx - 1])
1393+
print(f" #{idx}: {files[idx - 1]['display_name']}")
1394+
continue
1395+
else:
1396+
print(f" [warn] Number {idx} out of range (1–{len(files)})")
1397+
continue
1398+
except ValueError:
1399+
pass
1400+
# Fall back to filename substring matching
13881401
matches = [f for f in files
13891402
if query.lower() in f["display_name"].lower()]
13901403
if not matches:

0 commit comments

Comments
 (0)