SocksPls / hltv-api

Provides an API for HLTV
GNU Affero General Public License v3.0
85 stars 37 forks source link

Add get_match_countdown() #29

Closed grantephross closed 2 years ago

grantephross commented 2 years ago

Lets you retrieve the countdown timer from the match page by passing it the match page url.

grantephross commented 2 years ago

The idea behind this is the time output from get_matches() doesn't retrieve a value from HLTV that matches the timezone of your bot. Getting the countdown timer allows for using datetime to get a current time from your machine and you can run automations knowing when a match is going to happen.

I hope you find this helpful :)

zGrav commented 2 years ago

Hey @grantephross , thanks for the contribution!

Can I ask for some screenshots/details on where the time/dates do not match? HLTV should identify your timezone accordingly and the script should not and it does not 'translate/convert' any dates, we merely just output what HLTV gives us and has seemed to match always. (at least we've never gotten any complains, unless whoever uses the script does their own magic)

e.g: image

I also think that your code makes more sense to exist within another function instead of being standalone for example within get_matches if countdown is available.

Let me know if this makes sense and I can whip something up with you :)

zGrav commented 2 years ago

https://github.com/SocksPls/hltv-api/pull/30/commits/312c96c59dd559970050f8beb2e3719b4b891fd9 - added it here, no need to re-query HLTV again since we already have the date/time in the right TZ image If this is enough for you, please tell me and I'll close this and merge my code

zGrav commented 2 years ago

I see, we are not actually, even on Portugal TZ we're getting 23h instead of 22h. Will investigate this on the side :)

zGrav commented 2 years ago

Alright, all dates/times are bounded to Europe/Copenhagen which is HLTV's preferred timezone, and get converted to your local timezone in that branch, considering that the branch has evolved a bit, I shall close this one in favor of the other.

zGrav commented 2 years ago

PS: I still think after all the rewrites, a standalone function to get a match countdown that takes in a match ID and spits out a countdown in your TZ is viable. I'll do this on Monday/Tuesday tops if @grantephross doesn't get around to it in the meantime.

grantephross commented 2 years ago

e function to get a match countdown that takes in a match ID and spits out a countdown in your TZ is viable. I'll do this on Monday/Tuesday tops if @grantephross doesn't get around to it in the me

How would you like it implemented? If my request was passable I can re-do it, if not I can try to rewrite it.

zGrav commented 2 years ago

Gimme a sec, I might be able to whip up something real quick and clean it up later that suits what you originally intended

zGrav commented 2 years ago

@grantephross added in https://github.com/SocksPls/hltv-api/pull/34 :)