]> code.delx.au - webdl/blobdiff - grabber.py
Fixed iView downloads
[webdl] / grabber.py
index 72b39b27ac95343d7b416a3d727a87846b194746..d887472483634cb6dfd0280762c2b98d20f100fa 100755 (executable)
@@ -1,13 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from common import load_root_node, natural_sort
 
-# Python2 compatibility
-try:
-    raw_input
-except NameError:
-    raw_input = input
-
 
 def choose(options, allow_multi):
     reverse_map = {}
@@ -17,11 +11,18 @@ def choose(options, allow_multi):
     print("  0) Back")
     while True:
         try:
-            values = list(map(int, raw_input("Choose> ").split()))
-            if len(values) == 0:
+            str_values = input("Choose> ").split()
+            if len(str_values) == 0:
                 continue
-            if 0 in values:
+            if "0" in str_values:
                 return
+            values = []
+            for s in str_values:
+                if s.isdigit():
+                    values.append(int(s))
+                else:
+                    low, high = s.split("-", 1)
+                    values.extend(range(int(low), int(high) + 1))
             values = [reverse_map[value] for value in values if value in reverse_map]
             if allow_multi:
                 return values
@@ -52,7 +53,7 @@ def main():
         elif will_download:
             for n in result:
                 if not n.download():
-                    raw_input("Press return to continue...\n")
+                    input("Press return to continue...\n")
         else:
             node = result