Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5701c87

Browse files
check for max_likes value
Added a check for max_likes value so that it is not bigger than the number of pictures in a hashtag
1 parent 4b066c7 commit 5701c87

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎instaAPI-bot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
parser.add_argument('-p', '--password', help='instagram password')
2424
parser.add_argument('-l', '--likes', type=int, default=600, help='likes per day')
2525
parser.add_argument('-min', '--minlikes', type=int, default=24, help='min likes per tag round')
26-
parser.add_argument('-max', '--maxlikes', type=int, default=79, help='max likes per tag round')
26+
parser.add_argument('-max', '--maxlikes', type=int, default=44, help='max likes per tag round')
2727
parser.add_argument('-ht', '--hashtags', nargs='+', default=["l4l", "f4f"], help='hashtags to like')
2828
parser.add_argument('-bl', '--blacklist', nargs='+', default=["sex", "nsfw"], help='blacklist hashtags')
2929
parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.1')
@@ -33,6 +33,7 @@ def cleanup(): #logout and exit when CTRL + C is pressed
3333
InstagramAPI.logout()
3434
print('\n\n')
3535
print('Start time: {}'.format(start_time))
36+
print('End time: {}'.format(datetime.now().strftime('%A, %d. %B %Y %I:%M%p')))
3637
print('Total likes: {}'.format(total_like))
3738
print('\n\n')
3839

@@ -106,9 +107,11 @@ def cleanup(): #logout and exit when CTRL + C is pressed
106107
time.sleep(random.randint(2,4))
107108

108109
media_id = InstagramAPI.LastJson
110+
if max_likes_per_tag > len(media_id['items']): #check hashtag picture count
111+
max_likes_per_tag = (len(media_id)['items'])
109112

110113
likes_per_tag = random.randint(min_likes_per_tag,max_likes_per_tag)
111-
for element in media_id['items'][:likes_per_tag]:
114+
for element in media_id['items'][:likes_per_tag+1]:
112115
like = True
113116
if 'caption' in element:
114117
for hashtag in re.split(r'#|\s', element['caption']['text']): #blacklist

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /