bbsan2k/plugin.video.f1tv

2021 API Update

TheDevFreak opened this issue · 26 comments

Investigate the new API.

We need to know:

  • Authentication
  • List Seasons
  • List Events
  • List Sessions
  • List channels of sessions
  • Get M3U8 links.

Unfortunately, it seems that the new API doesn't contain any generic functions for retrieving seasons/events/sessions. Or at least, I haven't been able to find them. Instead, the API is now used to retrieve the actual layout of the website.

For example this page:
https://f1tv.formula1.com/page/392/2020-season

Uses the following API call to get the contents of the page:
https://f1tv.formula1.com/2.0/R/ENG/WEB_DASH/ALL/PAGE/392/F1_TV_Pro_Annual/2

This returns a JSON structure with all kinds of headers, titles, subtitles, links that are used to render the page.

Eventually you end up with a contentId that can be used to generate a tokenized stream URL.

@robvdpol Unfortunately, can confirm..... The closest I got was

https://f1tv.formula1.com/2.0/R/ENG/WEB_DASH/ALL/PAGE/SEARCH/VOD/F1_TV_Pro_Monthly/2?filter_objectSubtype=Meeting&orderBy=meeting_End_Date&sortOrder=asc&filter_season=2021&filter_meetingsUpcoming=Y&filter_orderByFom=Y

Which is by no means perfect because, even with 2021 set, if you set filter_meetingsUpcoming to N it shows every session for 2021; but not pre season testing while when set to Y it does show pre season testing AND all other events (or rather, "Meetings" now)

@TheDevFreak One problem i've found, is that their search function only returns the first 100 results from your query, and there's no way to paginate through it or anything like that. So if I asked it to give me all videos (by default it orders alphabetically by title), it will only return 100, and there's no way to request more. I can add a &maxResults=10 option, which will give me the 1st 10, but if I go above 100, it still only returns up to 100.

Yeah, I noticed this too I've not worked out how you're supposed to step past 100; I guess you just don't :/ worth noting the &filter_orderByFom=Y does seem to make it chronological, sort of.

Someone is doing Python work here: https://github.com/kodosexe/F1Hub

Not sure if it's useful, but I wanted to pass it along.

AppleTV app using new API: https://github.com/NoahFetz/F1AppleTV
I don't have an AppleTV so didn't try, but might be useful as well.

AppleTV app using new API: https://github.com/NoahFetz/F1AppleTV
I don't have an AppleTV so didn't try, but might be useful as well.

https://github.com/NoahFetz/F1AppleTV/blob/5378a0f3e0547a955b8fa1b3799df114cf6e1fe5/F1A-TV/Networking/NetworkRouter.swift#L139

Seems to still be using the old API

It would be interesting to investigate what API the android app uses. I wouldn't be surprised it that still uses the old API.

It would be interesting to investigate what API the android app uses. I wouldn't be surprised it that still uses the old API.

Yeah, I think that will make it easier - whenever they update the app..... I've not received one yet.

It would be interesting to investigate what API the android app uses. I wouldn't be surprised it that still uses the old API.

Yeah, I think that will make it easier - whenever they update the app..... I've not received one yet.

It's due in the first half of the season, so don't get too excited ha...

I've managed to find some better API calls to make tools for the new API.

I've got it all in this mostly proof-of-concept level tool here: https://github.com/TheDevFreak/pyF1Viewer

This may be especially interesting to @SoMuchForSubtlety

I just released an updated version of Race Control with support for the new API, might be interesting to you guys as well. Most of it works, still struggling a bit with the video on demand archive.

https://github.com/robvdpol/RaceControl

Thanks everyone for feedback already - it’s really appreciated!!
There are currently 2 different issues we need to be careful not to mix up-

MATRIX Support

Thanks to @joeyberkovitz (#47), the old caching has now been removed an replaced with a more „generic“ approach, which was a major issue with Leia- Matrix Transition. This can be tested with branch Matrix_Support. After some minor adjustments this will probably be part of the release.

New API (2.0)

@TheDevFreak put huge efforts in reverse engineering the new API.
Most certainly we will use the navigation structure that is provided on F1TV main page.
Unfortunately this means, that most of the plug-ins inner working needs to be changed. In the Long Term this will hopefully lead to better maintainability.
Also, the new API and 50FPS etc will only be supported with Matrix, as Leia does not support some special player URLs.
Thanks to everybody involved so far!!!

I upgraded to Kodi 19 (Matrix) yesterday and found out the version I had installed 0.1.7 did not work any longer.
I tried if the current version from the Matrix_support branch to see its current status and how I perhaps can contribute with testing.

The plugin is able to start, however directly gives me a account authentication failed error. With debug enabled I don't get any more info revealed. Credentials are working fine in the official F1 app and website. I also tried restoring everything to default settings, it did not make a difference.
Is this a known issue? If I can contribute on testing something please let me know.

The Matrix branch is still being built out, hopefully before the start of session 2 of today's testing you will be able to watch it live.

If you install the Matrix_Support version now to your Kodi install you will be able to watch the current live event, being served from the new API (50fps!). There is currently no functionality for anything else (replays, etc)

Awesome! Authentication issue is resolved. I can indeed watch the pre-session live.

It seems to load also quicker then in the previous version. Nice!

By the way I took a look at the android app, and it's still using the old API for everything.

Big thanks to all the contributors for getting this usable in time! 50fps is a huge improvement. So far, what works runs flawlessly.

Is it possible to install this addon on Kodi 18.x? Thank you for our answer.

Is it possible to install this addon on Kodi 18.x? Thank you for our answer.

The problem with supporting Leia (18.x) is, that due to the changes in F1TVs API, the player in Leia is not able to correctly parse the live stream m3u8. The addon itself does not have any dependencies for Matrix.

The problem with supporting Leia (18.x) is, that due to the changes in F1TVs API, the player in Leia is not able to correctly parse the live stream m3u8. The addon itself does not have any dependencies for Matrix.

Thank you very much for clarification.

I'm wondering how are Streaming sites able to distribute all of this to everyone for free.

https://f1tv.formula1.com/1.0/R/ENG/WEB_HLS/ALL/CONTENT/PLAY?contentId=1000004200

^This URL has inside a .m3u8 that is protected via a token. My guess that they somehow authenticate to that URL and curl the .m3u8 inside. Then they forward that to others. Each person gets its own Token aswell.

Here we go:
Beta release 0.1.99

https://github.com/bbsan2k/plugin.video.f1tv/releases/tag/0.1.99

This should work with the current API and also display Live if possible

Edit: FIxed Live: https://github.com/bbsan2k/plugin.video.f1tv/releases/tag/0.1.100

Thank you, it's working well with 0.1.100

I just tried it with this week-end Grand Prix and it worked beautifully. 1080p@50Hz, no hickups.
Great job !

Fantastic job - thanks for resolving this 🥇

Is there an updated repo so that updates can be pulled automatically? https://bbsan2k.github.io/repository.f1tv/repo/ does not work on Matrix anymore.