rdavydov / Twitch-Channel-Points-Miner-v2

A simple script that will watch a stream for you and earn the channel points.
GNU General Public License v3.0
1.1k stars 324 forks source link

time data format error when starting the bot #467

Closed duey closed 4 months ago

duey commented 4 months ago

Describe the bug

This just started happening today (Feb 28, 2024). Originally the bot was running (started at 11:55am PST). When I went to check on it tonight (after several hours), I noticed it was getting an error, so, I stopped it. Now I can't get it to run again.

I believe this is the relevant part of the log outputted when starting the bot:

  File "/[my folders snipped]/TwitchChannelPointsMiner/classes/entities/Drop.py", line 41, in __init__
    self.end_at = datetime.strptime(dict["endAt"], "%Y-%m-%dT%H:%M:%SZ")
  File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-03-01T01:29:59.999Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

I'm just a novice programmer, but, I'm wondering if it's having a problem with the leap day tomorrow, Feb 29th?

Steps to reproduce

cd to main bot folder and execute: python3 run.py

Expected behavior

the bot start-up like it normally does

Operating system

Ubuntu 20.04.6 LTS

Python version

3.8.10

Miner version

Python 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0]

Other relevant software versions

No response

Logs

Here's the text of what I see when I start the bot: https://gist.github.com/duey/d3f9400e0b18e675d70e3eb15d8a35b3

Here's my full log file output for today (over 6000 lines): https://gist.github.com/duey/c134daca09c84b4a2b50e00fc8e2b205

Here's my run.py for the bot: https://gist.github.com/duey/a5f66013b27d3c75d31eed57b5f983a9

Additional context

I also tried doing a git pull to make sure that I had the latest update, and it only updated the README.md and assets/charts.html files. Output from git pull command here: https://gist.github.com/duey/3e9961bca63273e09e9ec8e58663f5f0

It's been running fine for several weeks now. I tend to only run it a couple of times during the week, and, so, the last time I ran it was Fri, Feb 23, 2024. There was no errors then.

duey commented 4 months ago

I forgot to mention the error that I saw when I went back to check on it while it was running. I'm not 100% sure (I don't have the screen any more), but, I believe it was similar to what I'm getting now when I try to run the bot.

SkipTheDragon commented 4 months ago

I have the same problem:

Portainer logs here:

29/02/24 08:56:23 - INFO - [__init__]: Twitch Channel Points Miner v2-1.9.3 (fork by rdavydov) 29/02/24 08:56:23 - INFO - [__init__]: https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2 29/02/24 08:56:23 - INFO - [run]: 💣 Start session: '33dbc07b-dff8-43b7-80ba-bcf16bd7e673' Traceback (most recent call last): File "/usr/src/app/run.py", line 82, in <module> twitch_miner.mine( File "/usr/src/app/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 210, in mine self.run(streamers=streamers, blacklist=blacklist, followers=followers) File "/usr/src/app/TwitchChannelPointsMiner/TwitchChannelPointsMiner.py", line 231, in run self.twitch.claim_all_drops_from_inventory() File "/usr/src/app/TwitchChannelPointsMiner/classes/Twitch.py", line 792, in claim_all_drops_from_inventory drop = Drop(drop_dict) ^^^^^^^^^^^^^^^ File "/usr/src/app/TwitchChannelPointsMiner/classes/entities/Drop.py", line 41, in __init__ self.end_at = datetime.strptime(dict["endAt"], "%Y-%m-%dT%H:%M:%SZ") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/_strptime.py", line 555, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/_strptime.py", line 333, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '2024-03-01T01:29:59.999Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

Full logs here : tw-miner.log

SkipTheDragon commented 4 months ago

It's probably related to this section of the website https://prnt.sc/EI9gk8IJI5Gj (i didn't study the repo to know for sure)

duey commented 4 months ago

@SkipTheDragon are you following Warframe as well? I'm wondering if that's a common cause. My run.py only has "warframe" and "warframeinternational". (However, I just tried removing them and putting random user I found on twitch in and I'm still getting the error, so, maybe not?)

[edit to add Gist link of snippet of the log file from this morning runs: https://gist.github.com/duey/1dd151d8f7a4f396b89a7807764c998d ]

Also, I just remembered I had to reboot the Ubuntu computer earlier that day because it did some updates. Here's the list of recently upgraded packages: https://gist.github.com/duey/1b78e4e83fe411f992e3aa3baf7aa357

SkipTheDragon commented 4 months ago

@duey I have it in a docker container, so I don't think it's a problem with your packages, but actually with an update to twitch's interface/backend, they must've changed the date format to be more user-friendly on that page/request.

If you have cloned this repository, you could try to make the following changes to the codebase:

Open TwitchChannelPointsMiner/classes/entities/Drop.py

Replace all occurrences of "%Y-%m-%dT%H:%M:%SZ" with "%a, %b %d, %I:%M %p %Z%z"

The file in question: https://github.com/rdavydov/Twitch-Channel-Points-Miner-v2/blob/master/TwitchChannelPointsMiner/classes/entities/Drop.py

I didn't have time to test this yet.

Edit: spelling and string to include a dynamic timezone instead of GMT only.

rdavydov commented 4 months ago

Yep, looks like the format '%Y-%m-%dT%H:%M:%SZ' is no longer valid. This issue is related to the inventory only. I'll try to make a fix.

rdavydov commented 4 months ago

Hmm, no, I looked at the requests in the browser for the Drops/Inventory, and the responses seem to be containing the same datetime format as before, like:

                        "startAt": "2024-02-29T15:15:00Z",
                        "endAt": "2024-02-29T18:00:00Z",
rdavydov commented 4 months ago

Ahh, I see now. It is in the error:

Error while syncing inventory: time data '2024-03-01T01:29:59.999Z' does not match format '%Y-%m-%dT%H:%M:%SZ'

rdavydov commented 4 months ago

.999 is the culprit, I think.

rdavydov commented 4 months ago

I'll leave this open. Please report back whether this issue is fixed now.

duey commented 4 months ago

I've updated my copy with your fix, and it is working now. I can start the bot with no apparent errors. Thank you for the quick turn-around and for maintaining this software, I really appreciate it.

edit to add: Just checked in on the bot after my pre-programmed run for this afternoon. No errors. Worked just like it used to. Perfect!

SkipTheDragon commented 4 months ago

Updated my docker image to the latest version, no errors for now, will come back if anything goes wrong.

Thanks for the prompt update, rdavydow!

duey commented 4 months ago

My copy is still working fine after your update. This can be closed.