Windows200000 / TwitchDropsMiner-updated

An app that allows you to AFK mine timed Twitch drops, with automatic drop claiming and channel switching.
MIT License
335 stars 17 forks source link

TypeError: 'NoneType' object is not subscriptable - Received this error (working fine prior to reboot) #118

Open phrostb opened 2 months ago

phrostb commented 2 months ago

Any idea what this error might be caused by? I tried doing a fresh run (no settings.json, just the EXE) and got the same result.

07:23:21: Fatal error encountered: 07:23:21: 07:23:21: Traceback (most recent call last): 07:23:21: File "main.py", line 160, in main 07:23:21: File "twitch.py", line 772, in run 07:23:21: File "twitch.py", line 923, in _run 07:23:21: File "twitch.py", line 1749, in get_live_streams 07:23:21: File "twitch.py", line 1750, in 07:23:21: File "channel.py", line 116, in from_directory 07:23:21: TypeError: 'NoneType' object is not subscriptable 07:23:21: 07:23:21: Exiting... 07:23:21: 07:23:21: Application Terminated. 07:23:21: Close the window to exit the application.

5wi5wi commented 2 months ago

me too

DzaminNayura commented 2 months ago

Same Issue here, was working just fine yesterday.

Cryptic-Soldier commented 2 months ago

I also got call back errors, but mine look different from that? I've redacted sensitive info (sensitive to me at least)...

07:56:43: Fatal error encountered: 07:56:43: 07:56:43: Traceback (most recent call last): 07:56:43: File "C:\Users\ -------------\OneDrive\Desktop\ Twitch Drops Miner\main.py", line 160, in main 07:56:43: await client.run() 07:56:43: File "C:\Users\ -----------\OneDrive\Desktop\ Twitch Drops Miner\twitch.py", line 772, in run 07:56:43: await self._run() 07:56:43: File "C:\Users\ -----------\OneDrive\Desktop\ Twitch Drops Miner\twitch.py", line 923, in _run 07:56:43: new_channels.update(await self.get_live_streams(game)) 07:56:43: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 07:56:43: File "C:\Users\ -------------\OneDrive\Desktop\ Twitch Drops Miner\twitch.py", line 1750, in get_live_streams 07:56:43: Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True) 07:56:43: File "C:\Users\ -----------\OneDrive\Desktop\ Twitch Drops Miner\channel.py", line 116, in from_directory 07:56:43: twitch, id=channel["id"], login=channel["login"], display_name=channel["displayName"] 07:56:43: ~~~^^^^^^ 07:56:43: TypeError: 'NoneType' object is not subscriptable 07:56:43: 07:56:43: Exiting... 07:56:44: 07:56:44: Application Terminated. 07:56:44: Close the window to exit the application.

xr1rx commented 2 months ago

Had the same issue, but it seems to working properly again after a fresh install (just removed settings, cookies and cache) and removing Rust from the priority list. Not sure if actually related or just a coincidence.

Cryptic-Soldier commented 2 months ago

Had the same issue, but it seems to working properly again after a fresh install (just removed settings, cookies and cache) and removing Rust from the priority list. Not sure if actually related or just a coincidence.

The current Rust drops are causing the issue. I too just removed Rust from the list, and it works just fine, I add Rust in, and I get the error above. Hopefully this gives @Windows200000 somewhere to start and sort the bug out.

Totesfleisch commented 2 months ago

I'm having the same Issue, someone had this Issue on the original Project from DevilXD aswell, and Devil said this is an Issue on twitch's Side that he cannot fix.

zelda0079 commented 2 months ago
21:24:49: Traceback (most recent call last):
21:24:49:   File "main.py", line 160, in main
21:24:49:   File "twitch.py", line 772, in run
21:24:49:   File "twitch.py", line 923, in _run
21:24:49:   File "twitch.py", line 1749, in get_live_streams
21:24:49:   File "twitch.py", line 1750, in <listcomp>
21:24:49:   File "channel.py", line 116, in from_directory
21:24:49: TypeError: 'NoneType' object is not subscriptable
21:24:49: 
21:24:49: Exiting...
21:24:49: INFO: Websocket[0] stopped.
zelda0079 commented 2 months ago

However, the "Inventory" page is still working, I can use it to know the twitch drop sequence.

5wi5wi commented 2 months ago

This error started today before i update to the latest version, so I think this is from twitch not the codes.

Nazar1ky commented 2 months ago

I know why it happen issue, because some streamer in RUST category return node without broadcaster element.

Nazar1ky commented 2 months ago

I have data from today. I suggest we need to add check if "broadcaster" in data.

image

    {
        "cursor": "eyJzIjoyMi4wNzUwNTQ5NDgwMDI4MTIsImQiOmZhbHNlLCJ0Ijp0cnVlfQ==",
        "node": {
            "id": "44332239611",
            "title": "\u2705RUST\ud83c\udf81|!DROPS|\ud83c\udf81RUST Bellum Redemption LOOT! |!WATCHTIME| = 4 Hours Claims the rewards Bellum - Double Door & the Bellum - Large Wooden Box",
            "viewersCount": 22,
            "previewImageURL": "https://static-cdn.jtvnw.net/previews-ttv/live_user_alternateself-440x248.jpg",
            "broadcaster": null,
            "freeformTags": [
                {
                    "id": "fft:CHANNEL:136412337:0",
                    "name": "English",
                    "__typename": "FreeformTag"
                }
            ],
            "type": "live",
            "game": {
                "id": "263490",
                "boxArtURL": "https://static-cdn.jtvnw.net/ttv-boxart/263490_IGDB-40x56.jpg",
                "name": "Rust",
                "displayName": "Rust",
                "slug": "rust",
                "__typename": "Game"
            },
            "__typename": "Stream"
        },
        "trackingID": null,
        "__typename": "StreamEdge"
    },
Windows200000 commented 2 months ago

Twitch seems to be changing a bunch of stuff lately....

I had this error, but unfortunately I only got it once and not again after restarting in debug mode.

Thanks for all your amazing work figuring out it's rust, I'll look into this asap since it seems like a pretty serious issue.

Cryptic-Soldier commented 2 months ago

Mine is now working just fine, and I changed nothing other than updating to the current version. Important to note that the error is what prompted me to update.

It seems... as always... with the Rust Drops, FacePunch likes to pick people to have drops, then they (the people picked) will do whatever they can to NOT play Rust, which is where I think this error is coming in. The program sees the streamer live that is supposed to have drops but they're playing or doing something else so they don't have to distrubite drops.

So maybe the program needs to check and see if a streamer is live that has drops, BUT they're not playing the required game, it skips them and moves on to the next person. Obviously it should return to the skipped person when they begin playing the required game for drops.

Windows200000 commented 2 months ago

image

21:12:38: Progress: 212/240 - Rust, Bellum Redemption
21:12:38: CALL: Drop progress from active search: Bellum - Double Sheet Metal Door (Rust, 212/240)
21:12:59: CALL: No drop update from the websocket received
21:13:20: CALL: No drop update from the websocket received
21:13:41: CALL: No drop update from the websocket received
21:13:41: Progress: 213/240 - Rust, Bellum Redemption

Mine is even farming the drop in question without issues...

Windows200000 commented 2 months ago

Mine is now working just fine, and I changed nothing other than updating to the current version. Important to note that the error is what prompted me to update.

It seems... as always... with the Rust Drops, FacePunch likes to pick people to have drops, then they (the people picked) will do whatever they can to NOT play Rust, which is where I think this error is coming in. The program sees the streamer live that is supposed to have drops but they're playing or doing something else so they don't have to distrubite drops.

So maybe the program needs to check and see if a streamer is live that has drops, BUT they're not playing the required game, it skips them and moves on to the next person. Obviously it should return to the skipped person when they begin playing the required game for drops.

That shouldn't be an issue, people stream all kind of things, especially in the open drops, and it works, it seems more like Facepunch changing the drop (they have an official API unlike us :,), afaik ). Also you might be right, I would just expect that during the years of TDM being a thing, this would've come up already.

mindryder commented 2 months ago

Same Issue, need fix it for farm Rust items

Nazar1ky commented 2 months ago

image

21:12:38: Progress: 212/240 - Rust, Bellum Redemption
21:12:38: CALL: Drop progress from active search: Bellum - Double Sheet Metal Door (Rust, 212/240)
21:12:59: CALL: No drop update from the websocket received
21:13:20: CALL: No drop update from the websocket received
21:13:41: CALL: No drop update from the websocket received
21:13:41: Progress: 213/240 - Rust, Bellum Redemption

Mine is even farming the drop in question without issues...

Have you checked my message earlier, sometimes Twitch give forbidden data

iXerxes commented 2 months ago

I've been having the same TypeError issue, up until somewhere between now and two hours ago. After restarting this final time however, it seems to be working fine

Windows200000 commented 2 months ago

So, from looking at the code and from what I can gather here, especially from @Nazar1ky this issue was likely a Twitch bug.

It would probably be best to just ignore this. Something like this:

    def from_directory(
        cls, twitch: Twitch, data: JsonType, *, drops_enabled: bool = False
    ) -> Channel:
        channel = data["broadcaster"]
        if channel == None:     <===
            logger.warning(f'Failed to get livestream for: {data["game"]["name"]}')     <===
            return None     <===
        self = cls(
            twitch, id=channel["id"], login=channel["login"], display_name=channel["displayName"]
        )
        self._stream = Stream.from_directory(self, data, drops_enabled=drops_enabled)
        return self
async def get_live_streams(self, game: Game, *, limit: int = 30) -> list[Channel]:
        try:
            response = await self.gql_request(
                GQL_OPERATIONS["GameDirectory"].with_variables({
                    "limit": limit,
                    "slug": game.slug,
                    "options": {
                        "includeRestricted": ["SUB_ONLY_LIVE"],
                        "systemFilters": ["DROPS_ENABLED"],
                    },
                })
            )
        except MinerException as exc:
            raise MinerException(f"Game: {game.slug}") from exc
        if "game" in response["data"]:
            return [
                channel for stream_channel_data in response["data"]["game"]["streams"]["edges"]     <===
                if (channel := Channel.from_directory(self, stream_channel_data["node"], drops_enabled=True)) is not None     <===
            ]
        return []
zelda0079 commented 2 months ago

The miner works again.

5wi5wi commented 2 months ago

its working now

Windows200000 commented 2 months ago

Since this works rn, I want to implement this properly.

I think this should be reported without any debug logging and the part of the code where this issue happens didn't currently have access to mamager.print. This will be the next thing I work on, unless a critical issue comes up.

5wi5wi commented 2 months ago

The error is back, and to fix it, i added rust to the excluded list, and it's working now.

Windows200000 commented 2 months ago

The best I could do to "emulate" this thing was:

if stream_channel_data["node"]["broadcaster"]["login"] == 'incon':
    stream_channel_data["node"]["broadcaster"] = None

The fix is in https://github.com/Windows200000/TwitchDropsMiner-updated/commit/77099431d568f34f00a4f624eda6de987ecd9894: https://github.com/Windows200000/TwitchDropsMiner-updated/blob/77099431d568f34f00a4f624eda6de987ecd9894/twitch.py#L1748-L1756

Inside the GUI, even without any additional logging enabled, it will look like this: image

Please run the latest in-dev. If I can confirm, that someone got the above log message "in the wild", I'll close this as completed.

@5wi5wi @zelda0079 @Nazar1ky @Cryptic-Soldier @phrostb

PatrickJnr commented 2 months ago

been testing out the latest version https://github.com/Windows200000/TwitchDropsMiner-updated/commit/58b903516d31ed9e15c66baa316b7f7872fd94af

image

it seemed to error out, but recovered and carried on.

Windows200000 commented 2 months ago
def set_result(self, result):
        """Mark the future done and set its result.

        If the future is already done when this method is called, raises
        InvalidStateError.
        """
        if self._state != _PENDING:
            raise exceptions.InvalidStateError(f'{self._state}: {self!r}')
        self._result = result
        self._state = _FINISHED
        self.__schedule_callbacks()

@PatrickJnr TBH time travel is kinda over my head, but according to the comment it's just trying to do something now, that is actually already done in the future, so I guess it's fine?

Windows200000 commented 2 months ago

@PatrickJnr Just noticed, it looks like you didn't get the Could not load Channel... line, so this might be unrelated. Unless you get that line, which you should always get when Twitch returns "broadcaster": null, the code should act exactly the same as before.

PatrickJnr commented 2 months ago

In any case @Windows200000 I'll keep you posted for any other errors

PatrickJnr commented 2 months ago
00:15:14: Progress: 119/120 - Rust, Bellum - Ricoy Boltie
00:16:12: Progress: 120/120 - Rust, Bellum - Ricoy Boltie
00:16:21: Fatal error encountered:
00:16:21: 
00:16:21: Traceback (most recent call last):
00:16:21:   File "main.py", line 160, in main
00:16:21:   File "twitch.py", line 772, in run
00:16:21:   File "twitch.py", line 828, in _run
00:16:21:   File "inventory.py", line 237, in claim
00:16:21:   File "inventory.py", line 138, in claim
00:16:21:   File "inventory.py", line 154, in _claim
00:16:21:   File "twitch.py", line 1575, in gql_request
00:16:21: exceptions.MinerException: GQL error: [{'message': 'service error', 'path': ['claimDropRewards']}]
00:16:21: 
00:16:21: Exiting...
00:16:22: 
00:16:22: Application Terminated.
00:16:22: Close the window to exit the application.
Windows200000 commented 2 months ago

@PatrickJnr There's a separate issue for that.

PatrickJnr commented 2 months ago

@PatrickJnr There's a separate issue for that.

Ah my bad!

zelda0079 commented 2 months ago

The best I could do to "emulate" this thing was:

if stream_channel_data["node"]["broadcaster"]["login"] == 'incon':
    stream_channel_data["node"]["broadcaster"] = None

The fix is in 7709943:

https://github.com/Windows200000/TwitchDropsMiner-updated/blob/77099431d568f34f00a4f624eda6de987ecd9894/twitch.py#L1748-L1756

Inside the GUI, even without any additional logging enabled, it will look like this: image

Please run the latest in-dev. If I can confirm, that someone got the above log message "in the wild", I'll close this as completed.

@5wi5wi @zelda0079 @Nazar1ky @Cryptic-Soldier @phrostb

I don't get the message, am I just wait it?

Windows200000 commented 2 months ago

@zelda0079 Well, twitch has to return an invalid thing. This message should be printed whenever the miner would previously crash. So we are waiting on Twitch screwing up again. Since it happened, then didn't for a while, and then did again, I'm hoping for it to happen once more, so I can confirm the fix.