]>
code.delx.au - webdl/blob - grabber.py
3 from common
import load_root_node
, natural_sort
6 def choose(options
, allow_multi
):
8 for i
, (key
, value
) in enumerate(options
):
9 print("%3d) %s" % (i
+1, key
))
10 reverse_map
[i
+1] = value
14 str_values
= input("Choose> ").split()
15 if len(str_values
) == 0:
24 low
, high
= s
.split("-", 1)
25 values
.extend(range(int(low
), int(high
) + 1))
26 values
= [reverse_map
[value
] for value
in values
if value
in reverse_map
]
32 except (ValueError, IndexError):
33 print("Invalid input, please try again")
37 node
= load_root_node()
42 for n
in node
.get_children():
43 options
.append((n
.title
, n
))
44 if not n
.can_download
:
46 options
= natural_sort(options
, key
=lambda x
: x
[0])
47 result
= choose(options
, allow_multi
=will_download
)
49 if node
.parent
is not None:
56 input("Press return to continue...\n")
60 if __name__
== "__main__":
63 except (KeyboardInterrupt, EOFError):