diff options
author | icoz <icoz.vt@gmail.com> | 2015-05-24 14:44:31 +0300 |
---|---|---|
committer | icoz <icoz.vt@gmail.com> | 2015-05-24 14:44:31 +0300 |
commit | 06ad5a60347b1abe879c5a73089f959857ed942d (patch) | |
tree | 5346757142f96b0c0028364b21c7d6946b6f1442 | |
parent | e90c3a1dd80003cfc0db3a3fe5645d85a0e184dc (diff) |
Added checks:
Check for PostDeleted
Check for already downloaded files.
-rwxr-xr-x | habraparse.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/habraparse.py b/habraparse.py index af9a662..8ec5a6a 100755 --- a/habraparse.py +++ b/habraparse.py @@ -96,6 +96,9 @@ def save_pdf(topic_id, filename, with_comments=False, project = 'h'): dir = os.path.dirname(filename) if dir != '' and not os.path.exists(dir): os.mkdir(dir) + elif os.path.exists(filename): + print("File {} is in target dir, skipping...") + return if project == 'g': ht = GeektimesTopic(topic_id) elif project == 'm': @@ -178,7 +181,10 @@ def create_url_list(username, filename, project='h'): urls = list() favs_id = hu.favorites() for topic_name in favs_id: - urls.append(T(favs_id[topic_name]).getTopicUrl()) + try: + urls.append(T(favs_id[topic_name]).getTopicUrl()) + except PostDeleted: + print('Post {} is deleted!'.format(favs_id[topic_name])) urls.sort() with open(filename, 'wt') as f: f.write('\n'.join(urls)) |