j0k3r / worldcup-slack-bot

WorldCupBot will notify a Slack channel/group for every match during a FIFA World Cup
MIT License
40 stars 29 forks source link

2018 Update? #5

Closed markrjamieson closed 6 years ago

markrjamieson commented 6 years ago

Is there any chance of an update to this bot for 2018?

j0k3r commented 6 years ago

I need to check if the official API got an update or if it still works the same as 4 years ago (I doubt).

felipeobraga commented 6 years ago

Do we have any news?

j0k3r commented 6 years ago

Looks like the api changed completely:

I'll have to wait for the match to see how it is handled.

markrjamieson commented 6 years ago

Interesting,

Thanks mate!

fmoctezuma commented 6 years ago

Hi @j0k3r do you know if there are API specifications for the api.fifa.com?

j0k3r commented 6 years ago

I don’t know. I just sniffed calls from their iOS app.

Jinkxed commented 6 years ago

Was looking to use this for our company pool. Any hope for an update and maybe english support? :)

frankakouemo commented 6 years ago

hello here any update ?

j0k3r commented 6 years ago

I won't be available at all until Monday but here what I found digging into the API (using the FIFA App on my iPhone and the Charles Proxy app on my Mac). I almost found what I need to update the bot, I just need some extra help in the mean time.

The live feed of the today's game is here (I don't think the language parameter is useful): https://api.fifa.com/api/v1/timelines/17/254645/275073/300331503?language=fr-FR

300331503 is the game id which can be found in that api call: https://api.fifa.com/api/v1/calendar/matches?idCompetition=17&idSeason=254645&idStage=275073&language=all&count=500

Anyway, from the timeline url, there are a lot of different Type:

These types are a kind of action in the game. Like a goal, the end of a period, a fault, etc. This is the bored part of the bot: find which action is each type id.

I already found:

Each action is listed under the "direct" (in french, maybe timeline in english) of a game, here is a screenshot: image

👉So, if you guys can find out which action is linked to which type id, it'll help me a lot 👍

Free kick event contains the related team, player, etc..

{
    EventId: "1131239410",
    IdTeam: "43965",
    IdPlayer: "371639",
    IdSubPlayer: "404372",
    Timestamp: "2018-06-14T16:54:13.051Z",
    MatchMinute: "90'+4'",
    Period: 5,
    HomeGoals: 5,
    AwayGoals: 0,
    Type: 39,
    TypeLocalized: [],
    PositionX: 0.621143,
    PositionY: -0.232647,
    GoalGatePositionX: 1,
    GoalGatePositionY: -0.077353,
    GoalGatePositionZ: 0.107,
    VarDetail: null,
    HomePenaltyGoals: 0,
    AwayPenaltyGoals: 0
}
0bp commented 6 years ago

There's also http://api.football-data.org/v1/fixtures/165084

andyworsley commented 6 years ago

Some educated guesses:

fmoctezuma commented 6 years ago
andyworsley commented 6 years ago

@fmoctezuma I'd have to disagree with a couple:

fmoctezuma commented 6 years ago

ok yeah let's remove those, did you compare the rest ? @andyworsley

andyworsley commented 6 years ago

@fmoctezuma I've added the other to my comments to keep them in one place, except 10? Most matches seem to start with 19 then 7 (occasionally some 71s before), and then a 7 after half time as well. So I'm guessing 19 is something to do with the start of the match, and then 7 is a period kick-off.

fmoctezuma commented 6 years ago

cool, the list looks much better, we are missing red cards and owngoals types, but so far is probably a good start.

andyworsley commented 6 years ago

I got Type 34 = own goal from the Iran game.

RickyNotaro commented 6 years ago

Here's why I found so far that have not been mentionned yet: :

BLOCKED_SHOT = 12 OFFSIDE = 15 CROSSBAR = 32 & 33 (Horizontal / Vertical?) PENALTY_MISSED = 60

j0k3r commented 6 years ago

Awesome guys, good job.

@RickyNotaro missed penalty isn't 65 as @andyworsley comments?

@andyworsley I'll soon review you PR too 👍

Wobak commented 6 years ago

Hello j0k3r,

Thanks for taking care of the update. Is there anything else we can help you with at the moment to try and get it faster ? :)

Thanks !

andyworsley commented 6 years ago

Been running this in the cloud for a day or so, and today I'm seeing some sort of rate-limiting/caching of the backend requests by the FIFA API CDN (Akamai). It keeps returning stale responses to the /matches endpoint at least i.e. the whole Belgium-Panama game it did not update the match to 3 = 'in progress'. But when I made the request from my machine, it was correct.

Might just be that query though, so maybe refactor to use the /live/football/now instead to see live matches, and filter out non World Cup (competition = 17) ones. Or just grab a static list of the match IDs?

Hopefully the /timelines endpoint isn't as affected, although I did see it get behind a bit earlier too.

j0k3r commented 6 years ago

I think we should better use If-None-Match with the ETAG from a previous call to avoid too many request. If the server respond a 304, we don't have to go further.

GET  /api/v1/calendar/matches?from=2018-06-17T20:00:00Z&to=2018-06-18T21:59:59Z&language=all&count=500

In response header we have:

ETag "2297675789"

Then, on the next request:

GET  /api/v1/calendar/matches?from=2018-06-17T20:00:00Z&to=2018-06-18T21:59:59Z&language=all&count=500
If-None-Match "2297675789"

We'll receive:

HTTP/1.1 304 Not Modified
Content-Type: application/json; charset=utf-8
ETag: "2297675789"
Cache-Control: must-revalidate, no-cache
Date: Mon, 18 Jun 2018 20:08:08 GMT
Access-Control-Allow-Origin: *
Connection: keep-alive
andyworsley commented 6 years ago

@j0k3r Agreed, anything to reduce requests (especially on the /matches or /live endpoints) is good. I didn't realise it returned those headers. Well spotted!

j0k3r commented 6 years ago

FMPOV the bot is now ready for the 2018 edition. Thanks all for the help and enjoy the game! ⚽️🇷🇺

iabuhilal commented 2 years ago

the full list

Goal = 0 Assist = 1 YellowCard = 2 RedCard = 3 Red2Yellow = 4 Substitution = 5 Penalty = 6 StartTime = 7 EndTime = 8 PauseTime = 9 ResumeTime = 10 Suspension = 11 Shot = 12 BigChance = 13 FreeKick = 14 Offside = 15 Corner = 16 Save = 17 Foul = 18 TossCoin = 19 Dribbling = 20 Skill = 21 Tackle = 22 DroppedBall = 23 ThrowIn = 24 Clearance = 25 EndMatch = 26 AerialDuel = 27 BallOut = 28 Punch = 29 Claim = 30 TimeOut = 31 HitBar = 32 HitPost = 33 OwnGoal = 34 PenaltyShootOut = 35 SecondPenalty = 36 HandBall = 37 Simulation = 38 GoalFromFreeKick = 39 GoalFromIndirectKick = 40 GoalFromPenalty = 41 GoalFromSecondPenalty = 42 GoalOverhead = 43 HitBarFromFreeKick = 44 HitBarFromIndirectKick = 45 HitBarFromPenalty = 46 HitBarFromSecondPenalty = 47 HitBarOverhead = 48 HitPostFromFreeKick = 49 HitPostFromIndirectKick = 50 HitPostFromPenalty = 51 HitPostFromSecondPenalty = 52 HitPostOverhead = 53 ShotFromIndirectKick = 54 ShotFromPenalty = 55 ShotOverhead = 56 SaveByGoalKeeper = 57 SaveFromFreeKick = 58 SaveFromIndirectKick = 59 SaveFromPenalty = 60 SaveFromSecondPenalty = 61 SaveOverhead = 62 BallOutFromFreeKick = 63 BallOutFromIndirectKick = 64 BallOutFromPenalty = 65 BallOutFromSecondPenalty = 66 BallOutOverhead = 67 EndTimeWithExtra = 68 EndTimeWithPSO = 69 StartMatch = 70 VarNotification = 71 FoulCausingPenalty = 72 Unknown = 9999

j0k3r commented 2 years ago

@iabuhilal interesting, where did you get the list?

iabuhilal commented 2 years ago

From the fifa.com website, I picked one of the games, lists the match events and I dig into their files. They are using client-side scripts to display events.