rdavydov / Twitch-Channel-Points-Miner-v2

[NEW] A simple script that will watch a stream for you and earn the channel points. A successor of Tkd-Alex's original repo.
GNU General Public License v3.0
1.23k stars 358 forks source link

KeyError: 'data' & UnboundLocalError: cannot access local variable 'campaigns' #149

Closed BarboPT closed 1 year ago

BarboPT commented 1 year ago

Traceback (most recent call last): File "run.py", line 93, in twitch_miner.mine( File "/home/runner/bot/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 180, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "/home/runner/bot/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 268, in run self.twitch.load_channel_points_context(streamer) File "/home/runner/bot/TwitchChannelPointsMiner/classes/Twitch.py", line 548, in load_channel_points_context if response["data"]["community"] is None: KeyError: 'data'

BarboPT commented 1 year ago

are possible make something like this. If i run run.py:

os.remove("logs/T.log") shutil.rmtree('Twitch-Channel-Points-Miner-v2/*pycache') shutil.rmtree('Twitch-Channel-Points-Miner-v2/pycache') shutil.rmtree('Twitch-Channel-Points-Miner-v2/TwitchChannelPointsMiner/classes/pycache')

gusgrub commented 1 year ago

SAME ERROR HERE

17/02/23 12:12:06 - INFO - [set_offline]: 😴 Streamer(username=flanalistaa, channel_id=232604150, channel_points=7.82k) is Offline! 17/02/23 12:12:07 - INFO - [set_offline]: 😴 Streamer(username=suuckmydragon, channel_id=655210981, channel_points=0) is Offline! Traceback (most recent call last): File "C:\Users\Administrator\Desktop\Twitch-Channel-Points-Miner-v2-master\run.py", line 78, in twitch_miner.mine( File "C:\Users\Administrator\Desktop\Twitch-Channel-Points-Miner-v2-master\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 180, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "C:\Users\Administrator\Desktop\Twitch-Channel-Points-Miner-v2-master\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 268, in run self.twitch.load_channel_points_context(streamer) File "C:\Users\Administrator\Desktop\Twitch-Channel-Points-Miner-v2-master\TwitchChannelPointsMiner\classes\Twitch.py", line 548, in load_channel_points_context if response["data"]["community"] is None:


KeyError: 'data'
VitaliShilov commented 1 year ago

same problem

rdavydov commented 1 year ago

Yep, the issue was probably in the pycache. And it still continues mining even with this error, so this is not really a problem.

Windows users can try DELETE_PYCACHE.bat

Linux users should know what to do. :)

Beardedcontent commented 1 year ago

Hello,

Just wanted to post in that I am getting the same error as well. I am using this on windows 10 however, running the delete_pycache.bat file did not solve the issue. I also cannot keep mining, it's a dead stop and exits after.

Traceback (most recent call last): File "C:\Users\user\TwitchMiner-V2\run.py", line 82, in twitch_miner.mine( File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 180, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 268, in run self.twitch.load_channel_points_context(streamer) File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\classes\Twitch.py", line 548, in load_channel_points_context if response["data"]["community"] is None: KeyError: 'data' Press any key to continue . . .

I don't use a follower list, I use Followers=True, and the error is random, there's no one set streamer it errors on...sometimes it loads up to 80% of them before that error throws.

Windows 10 22H2 19045.2604 Python 3.8

Hope this info helps!

reanoff commented 1 year ago

18/02 04:39:34 - Error while syncing inventory: 'data' Exception in thread Sync campaigns/inventory: Traceback (most recent call last): File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "c:\twitch farm2\Twitch-Channel-Points-Miner-v2-1.7.0\TwitchChannelPointsMiner\classes\Twitch.py", line 797, in sync_campaigns campaigns = self.__sync_campaigns(campaigns) ^^^^^^^^^ UnboundLocalError: cannot access local variable 'campaigns' where it is not associated with a value

rdavydov commented 1 year ago

Hello,

Just wanted to post in that I am getting the same error as well. I am using this on windows 10 however, running the delete_pycache.bat file did not solve the issue. I also cannot keep mining, it's a dead stop and exits after.

Traceback (most recent call last): File "C:\Users\user\TwitchMiner-V2\run.py", line 82, in twitch_miner.mine( File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 180, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\TwitchChannelPointsMiner.py", line 268, in run self.twitch.load_channel_points_context(streamer) File "C:\Users\user\TwitchMiner-V2\TwitchChannelPointsMiner\classes\Twitch.py", line 548, in load_channel_points_context if response["data"]["community"] is None: KeyError: 'data' Press any key to continue . . .

I don't use a follower list, I use Followers=True, and the error is random, there's no one set streamer it errors on...sometimes it loads up to 80% of them before that error throws.

Windows 10 22H2 19045.2604 Python 3.8

Hope this info helps!

Hello,

What is your miner version?

Beardedcontent commented 1 year ago

Hello,

What is your miner version?

Oops my mistake. 1.7.0, the most current I believe.

rdavydov commented 1 year ago

Looks like it happens when you're using new accounts with the TV login method. Well, they've made some changes again. Need to do some experiments..

rdavydov commented 1 year ago

Hmm.. I did a new login, it stopped with that error, I started it again and it is mining with no problems, except for these errors.

rdavydov commented 1 year ago

A few restarts even got rid of the errors. Interesting..

rdavydov commented 1 year ago

Guys, try a few restarts and report back.

reanoff commented 1 year ago

Some of the miners start up for me and they get points, but when starting up, the error is:

18/02 04:39:33 - Twitch Channel Points Miner v2-1.7.0 (fork by rdavydov) 18/02 04:39:33 - https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2 18/02 04:39:33 - Start session: '3203e068-6cdd-4b7f-bddc-4238430cb4c5' 18/02 04:39:33 - Loading data for 1 streamers. Please wait... 18/02 04:39:39 - Join IRC Chat: hitsquadgodfather 18/02 04:39:39 - hitsquadgodfather (677.96k points) is Online! 18/02 04:39:40 - Error while syncing inventory: 'data' Exception in thread Sync campaigns/inventory: Traceback (most recent call last): File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "c:\twitch farm2\Twitch-Channel-Points-Miner-v2-1.7.0\TwitchChannelPointsMiner\classes\Twitch.py", line 797, in sync_campaigns campaigns = self.__sync_campaigns(campaigns) ^^^^^^^^^ UnboundLocalError: cannot access local variable 'campaigns' where it is not associated with a value

Guys, try a few restarts and report back.

rdavydov commented 1 year ago

@reanoff delete pycache and try a few more restarts.

reanoff commented 1 year ago

@reanoff delete pycache and try a few more restarts.

18/02 05:04:21 - Error while syncing inventory: 'data' Exception in thread Sync campaigns/inventory: Traceback (most recent call last): File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner self.run() File "C:\Users\den85\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "c:\twitch farm2\Twitch-Channel-Points-Miner-v2-1.7.0\TwitchChannelPointsMiner\classes\Twitch.py", line 797, in sync_campaigns campaigns = self.__sync_campaigns(campaigns) ^^^^^^^^^ UnboundLocalError: cannot access local variable 'campaigns' where it is not associated with a value 18/02 05:05:59 - +10 --> hitsquadgodfather (60.56k points) - Reason: WATCH.

PKollenborg commented 1 year ago

I assumed it was a problem with the original branch and tried this one after rolling back with the same results from a backup. Fresh install. Same behavior under Linux - Ubuntu 22.04. pycache deleted and restarts attempted. Similar error as OP.

Traceback (most recent call last): File "/home/Twitch-Channel-Points-Miner-v2/run.py", line 82, in <module> twitch_miner.mine( File "/home/Twitch-Channel-Points-Miner-v2/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 180, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "/home/Twitch-Channel-Points-Miner-v2/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 268, in run self.twitch.load_channel_points_context(streamer) File "/home/Twitch-Channel-Points-Miner-v2/TwitchChannelPointsMiner/classes/Twitch.py", line 548, in load_channel_points_context if response["data"]["community"] is None: KeyError: 'data' root@twitchbot:/home/Twitch-Channel-Points-Miner-v2#

rdavydov commented 1 year ago

Any posts with duplicate error messages as before and not useful messages like "same problem" will be deleted/hidden after this post.

@reanoff it is mining, that is a good sign.

ra1yuga commented 1 year ago

@reanoff delete pycache and try a few more restarts.

this didnt work i used find . | grep -E "(/pycache$|.pyc$|.pyo$)" | xargs rm -rf to delete it im not familiar with linux so please tell me if i did it wrong

rdavydov commented 1 year ago

No, I don't think pycache was the reason. I think only the restarts do the trick. My experiments show that a couple of restarts fix the errors.

rdavydov commented 1 year ago

Try to delete cookies and obtain new ones, might also help.

reanoff commented 1 year ago

Try to delete cookies and obtain new ones, might also help.

When I run miners using bat file, some of them crash

rdavydov commented 1 year ago

When I run miners using bat file, some of them crash

Not really a useful message, doesn't help at all.

m4gnify commented 1 year ago

Deleting cookies (and pycache) does not fix it for me.

rdavydov commented 1 year ago

Deleting cookies (and pycache) does not fix it for me.

No, I don't think pycache was the reason. I think only the restarts do the trick. My experiments show that a couple of restarts fix the errors.

m4gnify commented 1 year ago

Maybe Twitch changed something, maybe it's on outage. Maybe it'll work tomorrow? After trying to start it again around 15 times it's still not working, so I'll pause my tries for today. Thanks

reanoff commented 1 year ago

@rdavydov crashed miner log helpful information? 18/02/23 05:42:03 - DEBUG - urllib3.connectionpool - [_new_conn]: Starting new HTTPS connection (1): raw.githubusercontent.com:443 18/02/23 05:42:04 - DEBUG - urllib3.connectionpool - [_make_request]: https://raw.githubusercontent.com:443 "GET /rdavydov/Twitch-Channel-Points-Miner-v2/master/TwitchChannelPointsMiner/init.py HTTP/1.1" 200 125 18/02/23 05:42:04 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [init]: Twitch Channel Points Miner v2-1.7.0 (fork by rdavydov) 18/02/23 05:42:04 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [init]: https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2 18/02/23 05:42:04 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [run]: Start session: 'f689a806-e14b-45fb-9e35-babd2b2eb214' 18/02/23 05:42:04 - INFO - TwitchChannelPointsMiner.TwitchChannelPointsMiner - [run]: Loading data for 1 streamers. Please wait... 18/02/23 05:42:04 - DEBUG - urllib3.connectionpool - [_new_conn]: Starting new HTTPS connection (1): www.twitch.tv:443 18/02/23 05:42:04 - DEBUG - urllib3.connectionpool - [_make_request]: https://www.twitch.tv:443 "GET / HTTP/1.1" 200 None 18/02/23 05:42:04 - DEBUG - TwitchChannelPointsMiner.classes.Twitch - [update_client_version]: Client version: a239ace6-3751-4c42-b4e2-841763447cf0 18/02/23 05:42:04 - DEBUG - urllib3.connectionpool - [_new_conn]: Starting new HTTPS connection (1): gql.twitch.tv:443 18/02/23 05:42:05 - DEBUG - urllib3.connectionpool - [_make_request]: https://gql.twitch.tv:443 "POST /gql HTTP/1.1" 200 203 18/02/23 05:42:05 - DEBUG - TwitchChannelPointsMiner.classes.Twitch - [post_gql_request]: Data: {'operationName': 'ReportMenuItem', 'extensions': {'persistedQuery': {'version': 1, 'sha256Hash': '8f3628981255345ca5e5453dfd844efffb01d6413a9931498836e6268692a30c'}}, 'variables': {'channelLogin': 'hitsquadgodfather'}}, Status code: 200, Content: {"data":{"requestInfo":{"countryCode":"RU","typename":"RequestInfo"},"user":{"id":"137616647","stream":{"id":"41861159195","createdAt":"2023-02-17T12:05:10Z","typename":"Stream"},"__typename":"User"}},"extensions":{"durationMilliseconds":45,"operationName":"ReportMenuItem","requestID":"01GSGRNC7YDWYQ08C513FK0A95"}} 18/02/23 05:42:05 - DEBUG - urllib3.connectionpool - [_new_conn]: Starting new HTTPS connection (1): www.twitch.tv:443 18/02/23 05:42:06 - DEBUG - urllib3.connectionpool - [_make_request]: https://www.twitch.tv:443 "GET / HTTP/1.1" 200 None 18/02/23 05:42:06 - DEBUG - TwitchChannelPointsMiner.classes.Twitch - [update_client_version]: Client version: a239ace6-3751-4c42-b4e2-841763447cf0 18/02/23 05:42:06 - DEBUG - urllib3.connectionpool - [_new_conn]: Starting new HTTPS connection (1): gql.twitch.tv:443 18/02/23 05:42:07 - DEBUG - urllib3.connectionpool - [_make_request]: https://gql.twitch.tv:443 "POST /gql HTTP/1.1" 200 169 18/02/23 05:42:07 - DEBUG - TwitchChannelPointsMiner.classes.Twitch - [post_gql_request]: Data: {'operationName': 'ChannelPointsContext', 'extensions': {'persistedQuery': {'version': 1, 'sha256Hash': '9988086babc615a918a1e9a722ff41d98847acac822645209ac7379eecb27152'}}, 'variables': {'channelLogin': 'hitsquadgodfather'}}, Status code: 200, Content: {"errors":[{"message":"PersistedQueryNotFound"}],"extensions":{"durationMilliseconds":2,"operationName":"ChannelPointsContext","requestID":"01GSGRNE62Z4W4M8AR3C8C3E72"}}

rdavydov commented 1 year ago

Now that's useful. PersistedQueryNotFound. I'll fire up a debugger tomorrow and see what can be done.

rdavydov commented 1 year ago

Related to: https://github.com/Rakambda/ChannelPointsMiner/issues/428 https://github.com/Rakambda/ChannelPointsMiner/pull/429 https://github.com/DevilXD/TwitchDropsMiner/issues/138

smackincheeks commented 1 year ago

yes same bugs for me also I have tried restarting ait probably 50 times it goes to a different amount of streams before error. I have also tried changing the response time it waits for a reply and that didnt help either cleared cache no help. When I changed it from all following to only a couple select streams (3) I had a lot more success. thanks for the bot tho was working great until now since twitch changed something.

rdavydov commented 1 year ago

Hi Roman! Thank you so much for the time and effort you put into this! I have a suggestion that I don't want to post publicly. Is there any way I can private message you? I can't seem to do it here or on Twitter. Thanks!

Hi. There is this thing called Telegram. It is not guaranteed that I will reply but there is a chance that I will read it.

rdavydov commented 1 year ago

Oops, looks like it's not fixed.

Research info: __get_inventory response:

{'errors': [{'message': 'could not unmarshal "true" (string) into bool: incompatible type'}],
'data': {'currentUser': {'id': '111111111', 'inventory': {'dropCampaignsInProgress': [{...}], 'gameEventDrops': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}], 'completedRewardCampaigns': [], '__typename': 'Inventory'}, '__typename': 'User'}},
'extensions': {'durationMilliseconds': 58, 'operationName': 'Inventory', 'requestID': 'XXX'}}
VitaliShilov commented 1 year ago

i deleted pycache and try a few more restarts, dont work, version 1.7.1

rdavydov commented 1 year ago

i deleted pycache and try a few more restarts, dont work, version 1.7.1

I know, it's not fixed yet, in progress.

rdavydov commented 1 year ago

While I'm trying to fix it, the workaround that you can try is to disable anything related to drops.

Set:

claim_drops_startup=False,
...
claim_drops=False,
PKollenborg commented 1 year ago

While I'm trying to fix it, the workaround that you can try is to disable anything related to drops.

Set:

claim_drops_startup=False,
...
claim_drops=False,

I gave it a go, but it still exits on the same error. Lines 82,180,268 and 548. - Under Linux

As mentioned I ran the original branch up until yesterday, so I think this might be a change on twitch's end. Seeing that we are all getting the error now. Thanks for your hard work!

Another note: I'm also seeing the same behavior. The bug can show up after loading 3 streamers, or a near complete list. It seems random.

VitaliShilov commented 1 year ago

While I'm trying to fix it, the workaround that you can try is to disable anything related to drops.

Set:

claim_drops_startup=False,
...
claim_drops=False,

does not work

rdavydov commented 1 year ago

While I'm trying to fix it, the workaround that you can try is to disable anything related to drops. Set:

claim_drops_startup=False,
...
claim_drops=False,

does not work

Debug log is needed.

rdavydov commented 1 year ago

Another note: I'm also seeing the same behavior. The bug can show up after loading 3 streamers, or a near complete list. It seems random.

Yeah, pretty strange. I thought it was related to drops. That's why it is very hard to catch this bug, really seems random.

I've updated some sha hashes, seems like it helped, but it is not clear, still experimenting.

Some accounts don't have this bug at all, some throw it randomly. Need to find a correlation.

VitaliShilov commented 1 year ago

14.log

rdavydov commented 1 year ago

14.log

Try 1.7.2.

reanoff commented 1 year ago

14.log

Try 1.7.2. Now all manners are launched without breakdowns, thank you!

PKollenborg commented 1 year ago

Major improvement, as it got through the whole list before any errors were thrown. A quick restart of the host seems to have fixed it, with no current error. I'll include the last one for anyone else. I'll report back if anything changes.

Last error:

"18/02/23 09:17:44 - ERROR - [sync_campaigns]: Error while syncing inventory: 'data' Exception in thread Sync campaigns/inventory: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/home/Twitch-Channel-Points-Miner-v2/TwitchChannelPointsMiner/classes/Twitch.py", line 797, in sync_campaigns campaigns = self.__sync_campaigns(campaigns) UnboundLocalError: local variable 'campaigns' referenced before assignment"

cajkovskip commented 1 year ago

whats the linux command to updated miner to 1.7.2?

rdavydov commented 1 year ago

whats the linux command to updated miner to 1.7.2?

If you used git clone to get it, then you can just git pull to pull the latest changes. Otherwise download the release archive and unpack it over.

PKollenborg commented 1 year ago

Ok, just restored my initial config with all my custom changes. No issues. Ubuntu 22.04 - 1.7.2. Thank you once again @rdavydov!

rdavydov commented 1 year ago

@gustavogrubba No worries, it's mining. Try a few restarts if this error message bothers you.

cajkovskip commented 1 year ago

All good but no +50 :(

BarboPT commented 1 year ago

Have something for auto delete the logs and rmdir /s /q pycache rmdir /s /q TwitchChannelPointsMiner__pycache rmdir /s /q TwitchChannelPointsMiner\classes\pycache rmdir /s /q TwitchChannelPointsMiner\classes\entities\pycache__

from replit