diff --git a/README.md b/README.md index 992dfd4..f35e1f3 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 **REDDIT** images and videos, **IMGUR** images and albums, **GFYCAT** links, **EROME** images and albums, **SELF POSTS** 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 @@ -52,6 +52,10 @@ 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/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 - Added erome support diff --git a/script.py b/script.py index 8092d38..d33b452 100644 --- a/script.py +++ b/script.py @@ -561,12 +561,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: @@ -575,8 +589,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: @@ -602,9 +625,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 1908468..4973051 100644 --- a/src/downloader.py +++ b/src/downloader.py @@ -142,9 +142,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 @@ -304,7 +311,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 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: