ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

Ultimate.py error #545

Closed kifirkin closed 6 years ago

kifirkin commented 6 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?

The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here: Python 2.7.13

Code:

schedule.every(2).hours.do(run_threaded, follow_users_from_hastag_file)

Error/Debug Log:

2018-05-14 19:15:33,241 - ERROR - Request returns 404 error!
Exception in thread Thread-49:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 60, in follow_users_from_hastag_file
    bot.follow_users(bot.get_hashtag_users(random_hashtag_file.random()))
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 318, in get_hashtag_users
    return get_hashtag_users(self, hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 127, in get_hashtag_users
    return [str(i['user']['pk']) for i in self.api.last_json['items']]
KeyError: 'items'

Describe your issue

Sometimes I've got this error while running ultimate_schedule.py script, but not always

I've got non-English letters in hashtag_database.txt

kifirkin commented 6 years ago

Works fine with python 3

Dan-Wood commented 6 years ago

I don't know why this is closed .. It's pretty concerning as it happens daily and things aren't being ran..

I got hit with three in a row ..

Python 2.7.3

2018-06-20 17:36:49,065 - INFO - Commenting on hashtag: figtree                                                                                                                      | 0/29 [00:00<?, ?it/s]
 hashtag20 17:36:49,069 - INFO - Going to comment medias by figtree
                                          2018-06-20 17:36:49,595 - ERROR - Request returns 404 error!

Exception in thread Thread-99:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 36, in like_hashtags
    bot.like_hashtag(random_hashtag_file.random(), amount=700 // 24)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 383, in like_hashtag
    return like_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_like.py", line 62, in like_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-20 17:36:49,605 - ERROR - Request returns 404 error!
                                          Exception in thread Thread-100:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 66, in comment_hashtag
    bot.comment_hashtag(hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 506, in comment_hashtag
    return comment_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_comment.py", line 46, in comment_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-20 17:36:49,607 - ERROR - Request returns 404 error!
Exception in thread Thread-98:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 60, in follow_users_from_hastag_file
    bot.follow_users(bot.get_hashtag_users(random_hashtag_file.random()))
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 318, in get_hashtag_users
    return get_hashtag_users(self, hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 127, in get_hashtag_users
    return [str(i['user']['pk']) for i in self.api.last_json['items']]
KeyError: 'items'

2018-06-20 17:37:09,086 - INFO - Stats saved at 2018-06-20 17:37:09.
basnijholt commented 6 years ago

@Dan-Wood, could you try https://github.com/instagrambot/instabot/pull/575?

Dan-Wood commented 6 years ago

@basnijholt sure, it's intermittent though. I'll keep an eye on it.

Dan-Wood commented 6 years ago

@basnijholt

2018-06-21 18:37:44,124 - INFO - ULTIMATE script. Safe to run 24/7!
2018-06-21 19:37:45,183 - INFO - Stats saved at 2018-06-21 19:37:45.
.018-06-21 20:37:44,538 - INFO - Going to like media with hashtag #shellharbour
2018-06-21 20:37:44,547 - INFO - Commenting on hashtag: portkembla
Getting hashtag media.:   0%|                                                                                                                                                        | 0/29 [00:00<?, ?it/s] hashtag21 20:37:44,549 - INFO - Going to comment medias by portkembla
                                          2018-06-21 20:37:45,064 - ERROR - Request returns 404 error!
Getting hashtag media.: 0it [00:00, ?it/s]Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 66, in comment_hashtag
    bot.comment_hashtag(hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 506, in comment_hashtag
    return comment_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_comment.py", line 46, in comment_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-21 20:37:45,185 - ERROR - Request returns 404 error!
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 36, in like_hashtags
    bot.like_hashtag(random_hashtag_file.random(), amount=700 // 24)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 383, in like_hashtag
    return like_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_like.py", line 62, in like_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-21 20:37:45,545 - INFO - Stats saved at 2018-06-21 20:37:45.
2018-06-21 21:37:46,204 - INFO - Stats saved at 2018-06-21 21:37:46.
/instabot# git branch
* fix_545
  master
python --version
Python 2.7.3
Dan-Wood commented 6 years ago
.018-06-21 22:37:44,874 - INFO - Going to like media with hashtag #travel
2018-06-21 22:37:44,877 - INFO - Commenting on hashtag: figtree
Getting hashtag media.:   0%|                                                                                                                                                        | 0/29 [00:00<?, ?it/s]
 hashtag21 22:37:44,878 - INFO - Going to comment medias by figtree
                                          2018-06-21 22:37:45,366 - ERROR - Request returns 404 error!
Getting hashtag media.: 0it [00:00, ?it/s]Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 66, in comment_hashtag
    bot.comment_hashtag(hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 506, in comment_hashtag
    return comment_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_comment.py", line 46, in comment_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-21 22:37:45,421 - ERROR - Request returns 404 error!
Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 60, in follow_users_from_hastag_file
    bot.follow_users(bot.get_hashtag_users(random_hashtag_file.random()))
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 318, in get_hashtag_users
    return get_hashtag_users(self, hashtag)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 127, in get_hashtag_users
    return [str(i['user']['pk']) for i in self.api.last_json['items']]
KeyError: 'items'

2018-06-21 22:37:45,473 - ERROR - Request returns 404 error!
Exception in thread Thread-8:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 36, in like_hashtags
    bot.like_hashtag(random_hashtag_file.random(), amount=700 // 24)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 383, in like_hashtag
    return like_hashtag(self, hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_like.py", line 62, in like_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-21 22:37:46,878 - INFO - Stats saved at 2018-06-21 22:37:46.
2018-06-21 23:37:47,571 - INFO - Stats saved at 2018-06-21 23:37:47.

I stand corrected, seems to happen ... a lot...

basnijholt commented 6 years ago

From your error message I can see that you are not using the code from the PR:

  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 127, in get_hashtag_users
    return [str(i['user']['pk']) for i in self.api.last_json['items']]
KeyError: 'items'

OTOH I see that I only fixed one of the two errors

there is also this one that I should address:

  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
basnijholt commented 6 years ago

@Dan-Wood I updated the code of #575 to fix both errors. I am pretty sure that it works now. Could you try it?

Dan-Wood commented 6 years ago

Sure, it's the weekend here so expect delayed responses :)

git pull
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 33 (delta 16), reused 30 (delta 13), pack-reused 0
Unpacking objects: 100% (33/33), done.
From https://github.com/instagrambot/instabot
   0e3ce53..895541c  fix_545    -> origin/fix_545
 * [new branch]      version    -> origin/version
Updating 0e3ce53..895541c
Fast-forward
 instabot/api/api.py |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
Dan-Wood commented 6 years ago

    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run                             self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 36, in like_hashtags
    bot.like_hashtag(random_hashtag_file.random(), amount=700 // 24)                 File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 383, in like_hashtag
    return like_hashtag(self, hashtag, amount)                                       File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_like.py", line 62, in like_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)                          File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-23 06:45:27,061 - ERROR - Request returns 404 error!
Exception in thread Thread-28:
Traceback (most recent call last):                                                   File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run                             self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 66, in comment_hashtag
    bot.comment_hashtag(hashtag)                                                     File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 506, in comment_hashtag
    return comment_hashtag(self, hashtag, amount)                                    File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_comment.py", line 46, in comment_hashtag
    medias = self.get_total_hashtag_medias(hashtag, amount)                          File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 303, in get_total_hashtag_medias
    return get_total_hashtag_medias(self, hashtag, amount, filtration)
  File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 83, in get_total_hashtag_medias
    medias = self.api.get_total_hashtag_feed(hashtag, amount)
  File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 624, in get_total_hashtag_feed
    items = last_json['items']
KeyError: 'items'

2018-06-23 06:45:30,679 - INFO - Stats saved at 2018-06-23 06:45:30.```
basnijholt commented 6 years ago

You're not using my code, still.

You should pip uninstall instabot.

Dan-Wood commented 6 years ago

@basnijholt whoops forgot about that!


.018-06-23 20:24:42,212 - INFO - Going to like media with hashtag #sutherland      Getting hashtag media.:   0%|                               | 0/29 [00:00<?, ?it/s]2018-06-23 20:24:42,218 - INFO - Commenting on hashtag: nowra
 hashtag23 20:24:42,218 - INFO - Going to comment medias by nowra
                                          2018-06-23 20:24:43,593 - ERROR - Request returns 404 error!ia.: 0it [00:00, ?it/s]
                                          2018-06-23 20:24:43,594 - INFO - Going to comment 0 medias.
2018-06-23 20:24:43,594 - INFO - DONE: Total commented on 0 medias.
2018-06-23 20:24:43,648 - ERROR - Request returns 404 error!
2018-06-23 20:24:43,684 - INFO - Nothing to like.
2018-06-23 20:24:44,149 - INFO - Stats saved at 2018-06-23 20:24:44.
2018-06-23 21:24:45,101 - INFO - Stats saved at 2018-06-23 21:24:45.```
Dan-Wood commented 6 years ago
2018-06-24 02:24:44,678 - ERROR - Request returns 404 error!
2018-06-24 02:24:44,728 - INFO - Going to comment 0 medias.
0it [00:00, ?it/s]                                                                 2018-06-24 02:24:44,729 - INFO - DONE: Total commented on 0 medias.
2018-06-24 02:24:47,726 - INFO - Stats saved at 2018-06-24 02:24:47.               2018-06-24 03:24:49,103 - INFO - Stats saved at 2018-06-24 03:24:49.
.018-06-24 04:24:43,678 - INFO - Going to like media with hashtag #travel
2018-06-24 04:24:43,678 - INFO - Commenting on hashtag: portkembla
 hashtag24 04:24:43,679 - INFO - Going to comment medias by portkembla
Getting hashtag media.:   0%|             2018-06-24 04:24:45,040 - ERROR - Request returns 404 error!ia.: 0it [00:00, ?it/s]
                                          2018-06-24 04:24:45,041 - INFO - Going to comment 0 medias.
2018-06-24 04:24:45,041 - INFO - DONE: Total commented on 0 medias.
2018-06-24 04:24:45,238 - ERROR - Request returns 404 error!                       2018-06-24 04:24:45,248 - INFO - Nothing to like.
2018-06-24 04:24:49,090 - INFO - Stats saved at 2018-06-24 04:24:49.               2018-06-24 05:24:50,543 - INFO - Stats saved at 2018-06-24 05:24:50.
.018-06-24 06:24:44,127 - INFO - Going to like media with hashtag #visitnsw
2018-06-24 06:24:44,127 - INFO - Commenting on hashtag: gymea
 hashtag24 06:24:44,131 - INFO - Going to comment medias by gymea
Getting hashtag media.:   0%|             2018-06-24 06:24:45,432 - ERROR - Request returns 404 error!ia.: 0it [00:00, ?it/s]
                                          2018-06-24 06:24:45,432 - INFO - Going to comment 0 medias.
2018-06-24 06:24:45,433 - INFO - DONE: Total commented on 0 medias.
2018-06-24 06:24:45,492 - ERROR - Request returns 404 error!
Exception in thread Thread-35:
Traceback (most recent call last):                                                   File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 505, in run                             self.__target(*self.__args, **self.__kwargs)
  File "ultimate.py", line 60, in follow_users_from_hastag_file                        bot.follow_users(bot.get_hashtag_users(random_hashtag_file.random()))
  File "/instabot/examples/dan/../../instabot/bot/bot.py", line 339, in get_hashtag_users
    return get_hashtag_users(self, hashtag)
  File "/instabot/examples/dan/../../instabot/bot/bot_get.py", line 141, in get_hashtag_users
    return [str(i['user']['pk']) for i in self.api.last_json['items'] if i.get('user')]
KeyError: 'items'

2018-06-24 06:24:45,503 - ERROR - Request returns 404 error!
2018-06-24 06:24:45,506 - INFO - Nothing to like.
2018-06-24 06:24:50,517 - INFO - Stats saved at 2018-06-24 06:24:50.