From c9626aae2e852488eb3cac48230ec656537e87de Mon Sep 17 00:00:00 2001 From: ThioJoe <12518330+ThioJoe@users.noreply.github.com> Date: Tue, 28 Dec 2021 15:05:09 -0500 Subject: [PATCH] Update Script - Remove community max scan number -Remove asking user for max number of community post comments to scan. Assuming want to scan all. -Fixed version number -Changed community comments loading from 'downloading' to 'loading' --- YouTubeSpammerPurge.py | 39 ++++++++++++++++++++++----------------- community_downloader.py | 6 +++--- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/YouTubeSpammerPurge.py b/YouTubeSpammerPurge.py index 458687dc..d79516b6 100644 --- a/YouTubeSpammerPurge.py +++ b/YouTubeSpammerPurge.py @@ -35,7 +35,7 @@ ### IMPORTANT: I OFFER NO WARRANTY OR GUARANTEE FOR THIS SCRIPT. USE AT YOUR OWN RISK. ### I tested it on my own and implemented some failsafes as best as I could, ### but there could always be some kind of bug. You should inspect the code yourself. -version = "2.4.0" +version = "2.4.2" configVersion = 11 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# @@ -2355,7 +2355,6 @@ def main(): confirm = False while confirm == False: communityPostInput = input("\nEnter the ID or link of the community post: ") - # Validate post ID or link, get additional info about owner, and useable link isValid, communityPostID, postURL, postOwnerID, postOwnerUsername = validate_post_id(communityPostInput) if isValid == True: @@ -2366,28 +2365,34 @@ def main(): confirm = choice("Continue?") else: print("Problem interpreting the post information, please check the link or ID.") - miscData['channelOwnerID'] = postOwnerID miscData['channelOwnerName'] = postOwnerUsername - # Checking config for max comments, or get from user input - validInteger = False - if config: validConfigSetting = True - while validInteger == False: + # Checking config for max comments in config + if config and config['max_comments'] != 'ask': + validInteger = False try: - if validConfigSetting == True and config and config['max_comments'] != 'ask': - maxScanNumber = int(config['max_comments']) - else: - maxScanNumber = int(input(f"\nEnter the maximum {F.YELLOW}number of comments{S.R} to scan: ")) + maxScanNumber = int(config['max_comments']) if maxScanNumber > 0: - validInteger = True # If it gets here, it's an integer, otherwise goes to exception + validInteger = True else: - print("\nInvalid Input! Number must be greater than zero.") - validConfigSetting = False + pass except: - print("\nInvalid Input! - Must be a whole number.") - validConfigSetting = False - + pass + + if validInteger == False: + print("\nInvalid max_comments setting in config! Number must a whole number be greater than zero.") + while validInteger == False: + maxScanInput = input(f"\nEnter the maximum {F.YELLOW}number of comments{S.R} to scan: ") + try: + maxScanNumber = int(maxScanInput) + if maxScanNumber > 0: + validInteger = True # If it gets here, it's an integer, otherwise goes to exception + else: + print("\nInvalid Input! Number must a whole number be greater than zero.") + except: + print("\nInvalid Input! - Must be a whole number greater than zero.") + # Create config file elif scanMode == "makeConfig": create_config_file() diff --git a/community_downloader.py b/community_downloader.py index 910b7d6e..d291cc27 100644 --- a/community_downloader.py +++ b/community_downloader.py @@ -151,9 +151,9 @@ def main(communityPostID=None, limit=1000, sort=SORT_BY_RECENT, language=None): if not communityPostID: raise ValueError('you need to specify a Youtube ID') - print('Loading Youtube comments for post:', communityPostID) + print('\nLoading Youtube comments for post:', communityPostID) count = 0 - sys.stdout.write('Loaded %d comment(s)\r' % count) + sys.stdout.write(' Loaded %d comment(s)\r' % count) sys.stdout.flush() start_time = time.time() @@ -167,7 +167,7 @@ def main(communityPostID=None, limit=1000, sort=SORT_BY_RECENT, language=None): #comment_json = json.dumps(comment, ensure_ascii=False) count += 1 - sys.stdout.write('Downloaded %d comment(s)\r' % count) + sys.stdout.write(' Loaded %d comment(s)\r' % count) sys.stdout.flush() if limit and count >= limit: break