aboutsummaryrefslogtreecommitdiff
path: root/mkbinder.py
diff options
context:
space:
mode:
Diffstat (limited to 'mkbinder.py')
-rwxr-xr-xmkbinder.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/mkbinder.py b/mkbinder.py
index eddca9e..1222376 100755
--- a/mkbinder.py
+++ b/mkbinder.py
@@ -16,19 +16,19 @@ parser.add_argument('--force', '-f', help = 'force download all links', action='
args = parser.parse_args()
-for filename in os.listdir('Links'):
- print('Examining: ' + filename)
- os.makedirs(filename, exists_ok=True)
+for category in os.listdir('Links'):
+ print('Examining: ' + category)
+ os.makedirs(category, exist_ok=True)
section = ''
- for link in open(os.path.join('Links', filename), 'r').readlines():
+ for link in open(os.path.join('Links', category), 'r').readlines():
if link[0:2] == '# ':
- section = link[2:]
+ section = link[2:-1]
if link[0] == '#' or link[0] == '\n':
continue
- name = section + ' - ' + re.sub(r'(?u)[^-\w.]', '', link[5:]) + '.pdf'
- if not os.path.exists(os.path.join('Links', name)) or args.force:
+ name = os.path.join(category, section + ' - ' + re.sub(r'(?u)[^-\w.]', '', link[5:]) + '.pdf')
+ if not os.path.exists(name) or args.force:
print('Downloading: ' + link[:-1])
print('Destination: ' + name)