Fixed excessive blank lines during scanning

This should fix all the extra blank lines that appear between videos when there are multiple being scanned.
This commit is contained in:
ThioJoe
2024-01-01 17:40:55 -07:00
parent a355916b45
commit b774de2f2d
4 changed files with 26 additions and 16 deletions

View File

@@ -205,7 +205,7 @@ def main(communityPostID=None, limit=1000, sort=SORT_BY_RECENT, language=None, p
if postScanProgressDict:
i = postScanProgressDict['scanned']
j = postScanProgressDict['total']
print(f'\n\n [{i}/{j}] Post ID: {communityPostID}')
print(f'[{i}/{j}] Post ID: {communityPostID}')
else:
print(f'\n Loading Comments For Post: {communityPostID}')

View File

@@ -153,12 +153,12 @@ def get_comments(current, filtersDict, miscData, config, allVideoCommentsDict, s
if filtersDict['filterMode'].lower() in dupeCheckModes:
print(" Analyzing For Duplicates ", end="\r")
check_duplicates(current, config, miscData, allVideoCommentsDict, scanVideoID)
print(" ")
print(" ", end="\r")
repostCheckModes = utils.string_to_list(config['stolen_comments_check_modes'])
if filtersDict['filterMode'].lower() in repostCheckModes:
print(" Analyzing For Reposts ", end="\r")
check_reposts(current, config, miscData, allVideoCommentsDict, scanVideoID)
print(" ")
print(" ", end="\r")
current.allScannedCommentsDict.update(allVideoCommentsDict)
return RetrievedNextPageToken, allVideoCommentsDict
@@ -649,7 +649,7 @@ def check_duplicates(current, config, miscData, allVideoCommentsDict, videoID):
scannedCount +=1
print(f" Analyzing For Duplicates: [ {scannedCount/authorCount*100:.2f}% ] (Can be Disabled & Customized With Config File)".ljust(75, " "), end="\r")
print("".ljust(110, " ")) # Erase line
print("".ljust(110, " "), end='\r') # Erase line
############################# Check Text Reposts #####################################
@@ -1492,7 +1492,7 @@ def print_count_stats(current, miscData, videosToScan, final):
matchCount = str(len(current.matchedCommentsDict) + len(current.spamThreadsDict))
if final == True:
print(f" {progress} Comments Scanned: {F.YELLOW}{comScanned}{S.R} | Replies Scanned: {F.YELLOW}{repScanned}{S.R} | Matches Found So Far: {F.LIGHTRED_EX}{matchCount}{S.R}\n")
print(f" {progress} Comments Scanned: {F.YELLOW}{comScanned}{S.R} | Replies Scanned: {F.YELLOW}{repScanned}{S.R} | Matches Found So Far: {F.LIGHTRED_EX}{matchCount}{S.R}", end = "\r")
else:
print(f" {progress} Comments Scanned: {F.YELLOW}{comScanned}{S.R} | Replies Scanned: {F.YELLOW}{repScanned}{S.R} | Matches Found So Far: {F.LIGHTRED_EX}{matchCount}{S.R}", end = "\r")

View File

@@ -88,7 +88,16 @@ def check_list_against_string(listInput, stringInput, caseSensitive=False):
return True
else:
return False
######################### Clear multiple previous lines #########################
def clear_lines(up, down=0):
LINE_UP = '\033[1A'
LINE_CLEAR = '\x1b[2K'
print(LINE_CLEAR, end="")
for i in range(up):
print(LINE_UP, end=LINE_CLEAR)
if down > 0:
print("\n"*down, end="\r")
################### Process Comma-Separated String to List ####################
# Take in string, split by commas, remove whitespace and empty items, and return list

View File

@@ -1147,7 +1147,7 @@ def main():
authorKeyAllCommentsDict = {}
allCommunityCommentsDict = get_community_comments(communityPostID=communityPostID, limit=limit, postScanProgressDict=postScanProgressDict, postText=postText)
retrievedCount = len(allCommunityCommentsDict)
print(f"\nRetrieved {retrievedCount} comments from post.\n")
print(f"Retrieved {retrievedCount} comments from post.")
scannedCount = 0
threadDict = {}
@@ -1183,7 +1183,7 @@ def main():
percent = ((scannedCount / retrievedCount) * 100)
progressStats = f"[ {str(scannedCount)} / {str(retrievedCount)} ]".ljust(15, " ") + f" ({percent:.2f}%)"
print(f' {progressStats} - Analyzing Comments For Spam ', end='\r')
print(" ")
print(" ", end='\r')
dupeCheckModes = utils.string_to_list(config['duplicate_check_modes'])
if filtersDict['filterMode'].lower() in dupeCheckModes:
@@ -1191,7 +1191,7 @@ def main():
# repostCheckModes = utils.string_to_list(config['stolen_comments_check_modes'])
# if filtersDict['filterMode'].lower() in repostCheckModes:
# operations.check_reposts(current, config, miscData, allCommunityCommentsDict, communityPostID)
print(" ")
print(" ", end='\r')
if scanMode == "communityPost":
scan_community_post(current, config, communityPostID, maxScanNumber)
@@ -1213,16 +1213,10 @@ def main():
# Goes to get comments for first page
print("\n------------------------------------------------------------------------------")
print("(Note: If the program appears to freeze, try right clicking within the window)\n")
print(" --- Scanning --- \n")
print(" --- Scanning --- \n\n")
# ----------------------------------------------------------------------------------------------------------------------
def scan_video(miscData, config, filtersDict, scanVideoID, videosToScan=None, currentVideoDict=None, videoTitle=None, showTitle=False, i=1):
if currentVideoDict is None:
currentVideoDict = {}
nextPageToken, currentVideoDict = operations.get_comments(current, filtersDict, miscData, config, currentVideoDict, scanVideoID, videosToScan=videosToScan)
if nextPageToken == "Error":
return "Error"
if showTitle == True and len(videosToScan) > 0:
# Prints video title, progress count, adds enough spaces to cover up previous stat print line
offset = 95 - len(videoTitle)
@@ -1230,7 +1224,14 @@ def main():
spacesStr = " " * offset
else:
spacesStr = ""
utils.clear_lines(up=1, down=0)
print(f"Scanning {i}/{len(videosToScan)}: " + videoTitle + spacesStr + "\n")
if currentVideoDict is None:
currentVideoDict = {}
nextPageToken, currentVideoDict = operations.get_comments(current, filtersDict, miscData, config, currentVideoDict, scanVideoID, videosToScan=videosToScan)
if nextPageToken == "Error":
return "Error"
operations.print_count_stats(current, miscData, videosToScan, final=False) # Prints comment scan stats, updates on same line
# After getting first page, if there are more pages, goes to get comments for next page