From 0387dd524369b7a53762dc9352c16274c07b61a3 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Tue, 24 Jul 2018 14:16:46 +0300 Subject: [PATCH 1/5] Tweaked 'What it can do' --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d057ca..51da1c0 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ This program downloads imgur, gfycat and direct image and video links of saved p ## What it can do - Can get posts from: frontpage, subreddits, multireddits, redditor's submissions, upvoted and saved posts; search results or just plain reddit links - Sorts posts by hot, top, new and so on -- Downloads imgur albums, gfycat links, [self posts](#how-do-i-open-self-post-files) and any link to a direct image +- Downloads **REDDIT** images and videos, **IMGUR** images and albums, **GFYCAT** links, **EROME** images and albums, **SELF POSTS** and any link to a **DIRECT IMAGE** - Skips the existing ones -- Puts post titles to file's name +- Puts post title and OP's name in file's name - Puts every post to its subreddit's folder - Saves a reusable copy of posts' details that are found so that they can be re-downloaded again - Logs failed ones in a file to so that you can try to download them later From 821383c465f29a7b944f7e3a7e456f426ae8fe28 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Tue, 24 Jul 2018 19:09:45 +0300 Subject: [PATCH 2/5] Deleted # char from file names --- src/tools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools.py b/src/tools.py index 4965e71..b33c3a8 100644 --- a/src/tools.py +++ b/src/tools.py @@ -132,7 +132,7 @@ def nameCorrector(string): if len(string.split('\n')) > 1: string = "".join(string.split('\n')) - BAD_CHARS = ['\\','/',':','*','?','"','<','>','|','.',] + BAD_CHARS = ['\\','/',':','*','?','"','<','>','|','.','#'] if any(x in string for x in BAD_CHARS): for char in string: From 1781ab8ffe8588f6450af1b16ed101b08718af07 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Tue, 24 Jul 2018 19:10:34 +0300 Subject: [PATCH 3/5] Update changelog --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 51da1c0..e81d7a1 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ It should redirect to a page which shows your **imgur_client_id** and **imgur_cl them, there. ## Changes on *master* +### [24/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/821383c465f29a7b944f7e3a7e456f426ae8fe28) +- Deleted # char from file names + ### [23/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/7314e17125aa78fd4e6b28e26fda7ec7db7e0147) - Split download() function - Added erome support From 21533bb78ce24359eb638991f3ec79a572a4a555 Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Tue, 24 Jul 2018 19:27:52 +0300 Subject: [PATCH 4/5] Improved exception handling --- script.py | 36 ++++++++++++++++++++++++++++-------- src/downloader.py | 20 +++++++++++++++++--- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/script.py b/script.py index fd97735..a40c878 100644 --- a/script.py +++ b/script.py @@ -546,12 +546,26 @@ def download(submissions): sys.exit() except ImgurLimitError as exception: - FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]}) + FAILED_FILE.add({int(i+1):[ + "{class_name}: {info}".format( + class_name=exception.__class__.__name__,info=str(exception) + ), + submissions[i] + ]}) downloadedCount -= 1 except NotADownloadableLinkError as exception: - print(exception) - FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]}) + print( + "{class_name}: {info}".format( + class_name=exception.__class__.__name__,info=str(exception) + ) + ) + FAILED_FILE.add({int(i+1):[ + "{class_name}: {info}".format( + class_name=exception.__class__.__name__,info=str(exception) + ), + submissions[i] + ]}) downloadedCount -= 1 except NoSuitablePost: @@ -560,8 +574,17 @@ def download(submissions): except Exception as exception: # raise exception - print(exception) - FAILED_FILE.add({int(i+1):[str(exception),submissions[i]]}) + print( + "{class_name}: {info}".format( + class_name=exception.__class__.__name__,info=str(exception) + ) + ) + FAILED_FILE.add({int(i+1):[ + "{class_name}: {info}".format( + class_name=exception.__class__.__name__,info=str(exception) + ), + submissions[i] + ]}) downloadedCount -= 1 if duplicates: @@ -587,9 +610,6 @@ def main(): checkConflicts() except ProgramModeError as err: PromptUser() - except Exception as err: - print(err) - sys.exit() if not Path(GLOBAL.configDirectory).is_dir(): os.makedirs(GLOBAL.configDirectory) diff --git a/src/downloader.py b/src/downloader.py index 705e259..55eb370 100644 --- a/src/downloader.py +++ b/src/downloader.py @@ -139,9 +139,16 @@ class Erome: howManyDownloaded -= 1 except Exception as exception: - raise exception + # raise exception print("\n Could not get the file") - print(" " + str(exception) + "\n") + print( + " " + + "{class_name}: {info}".format( + class_name=exception.__class__.__name__, + info=str(exception) + ) + + "\n" + ) exceptionType = exception howManyDownloaded -= 1 @@ -290,7 +297,14 @@ class Imgur: except Exception as exception: print("\n Could not get the file") - print(" " + str(exception) + "\n") + print( + " " + + "{class_name}: {info}".format( + class_name=exception.__class__.__name__, + info=str(exception) + ) + + "\n" + ) exceptionType = exception howManyDownloaded -= 1 From fc6787aa2838052a1c4ab3e7e3081df9c667290d Mon Sep 17 00:00:00 2001 From: Ali Parlakci Date: Tue, 24 Jul 2018 19:28:48 +0300 Subject: [PATCH 5/5] Update changelog --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e81d7a1..79a0703 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,9 @@ It should redirect to a page which shows your **imgur_client_id** and **imgur_cl them, there. ## Changes on *master* -### [24/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/821383c465f29a7b944f7e3a7e456f426ae8fe28) +### [24/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/21533bb78ce24359eb638991f3ec79a572a4a555) - Deleted # char from file names +- Imroved exception handling ### [23/07/2018](https://github.com/aliparlakci/bulk-downloader-for-reddit/tree/7314e17125aa78fd4e6b28e26fda7ec7db7e0147) - Split download() function