Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Fix: #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianleeclark committed Nov 18, 2015
1 parent 4d46e96 commit df6a477
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@

##### --download-all STARTS

def sanitize_description(desc):
return ''.join([i for i in desc if i.isdigit() or i.isalpha()])

def download_all():
'''
Downloads all the XKCD's and stores them in apporopriate folders.
Expand Down Expand Up @@ -68,7 +71,7 @@ def download_all():

xkcd_url = "{base}/{xkcd_num}".format(base=BASE_URL, xkcd_num=xkcd_number)
new_folder = '{home_folder}/xkcd_archive/{name}'.format(home_folder=HOME, name=xkcd_number)
new_description = description.replace(" ","_").replace(":", "_")
new_description = sanitize_filename(description)

print("Downloading xkcd from '{img_url}' and storing it under '{path}'".format(
img_url=xkcd_url,
Expand Down Expand Up @@ -242,7 +245,7 @@ def download_xkcd_number():
date=json_content[xkcd_number]['date-published']
description=json_content[xkcd_number]['description']

new_description = description.replace(" ","_").replace(":", "_")
new_description = sanitize_description(description)

new_folder = '{home_folder}/xkcd_archive/{name}'.format(home_folder=HOME, name=xkcd_number)

Expand Down Expand Up @@ -323,4 +326,4 @@ def main():
print(__doc__)

if __name__ == '__main__':
main()
main()

0 comments on commit df6a477

Please sign in to comment.