Mark users as processed and check when printing

This commit is contained in:
Thomas Wade 2018-09-25 19:03:44 +09:30
parent 0c496ecd71
commit 7de170efc9

View File

@ -54,6 +54,7 @@ class User:
followers = None
following = None
processed = False
def __init__(self):
self.tracks = []
@ -253,6 +254,7 @@ for i in range(2):
# Skip any users that have already been passed over to avoid infinite loops
if user_str in user_dict.keys():
if user_dict[user_str].processed:
print(' Already processed, skipping')
continue
@ -278,7 +280,8 @@ for i in range(2):
user.followers = Get_Follows('https://soundcloud.com/' + user.url_username + '/followers', 10)
users_to_process_next.extend(user.followers)
# Finally add the user to the dictionary
# Finally add the user to the dictionary and mark them as processed
user.processed = True
user_dict[user.url_username] = user
driver.quit()
@ -287,6 +290,9 @@ print('Done scraping, here\'s what we got')
print('==================================')
for _, user in user_dict.items():
if not user.processed:
continue
print(user.username)
print(' ' + str(user.track_count) + ' tracks')
print(' ' + str(user.like_count) + ' likes')