bbsan2k/plugin.video.f1tv

Explore New API

TheDevFreak opened this issue ยท 8 comments

  • How do we list seasons?
  • How do we list events?
  • How do we list channels?
  • How do we get an m3u8?

It looks like the old format of
https://f1tv.formula.com/api/

Is - mostly - replaced by: https://f1tv-api.formula1.com/agl/1.0/gbr/en/all_devices/global/

The is the same.

I say mostly because some endpoints still exist under old endpoint but not under new endpoint.

I recently discovered that https://f1tv.formula1.com/api/sets/?slug=grand-prix-weekend-live contains any live events.

@SoMuchForSubtlety very interesting! I could use this to create a shortcut to whatever is live now on the front page of the add-on.

I tried digging into this a bit deeper today...
The overall concepts in this "new" API (Events, Sessions, channels, episodes) stayed pretty much the same.

M3U8

Also, getting the M3U8 stayed more or less the same.
Something more interesting though is, that if you want to get a "new" sessions m3u8 (like anything newer than 2018) requires a cookie for getting the m3u8. Probably this can be simplified a lot by using InputStream, but I first need to dig deeper into this.

Entry Point for Archive

Entry point for Archive:

  https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/archive-filters/<<year>>

year: the maximum year to be reported + 1. year = 2018 will return all seasons from beginning to 2017.

Returns list of years containing Race Season IDs + information whether content is available for that year.

example for year = 2020:

  {"objects":
    [
      {
        "uid": "race_adae76dfe011404f8c69cb3611543e2d",
        "year": 2019,
        "has_content": true
      },
      .....
      {
        "uid": "race_d87ff2fcf0cf4cd6974dc266d569901f",
        "year": 1950,
        "has_content": false
      }
    ]
  }

Good thing is that we can now filter based on content availability already at that point, as there is this "has_content" flag.

Getting UIDs for single year

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/race-season/<<year>>

year may also refer to "current".

Call returns UID for single year (2019):

    {"objects": 
        [
            {
                "self": "/api/race-season/race_adae76dfe011404f8c69cb3611543e2d/"
            }
        ]
    }

Not sure if this is any interesting if we are coming form above call...

Race Season

Entry point for each race season:

URL:
https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/archive

PARAM:

race_season_url: /api/race-season/race_adae76dfe011404f8c69cb3611543e2d

Returns Race Season for defined race_season_url

Example for season race_adae76dfe011404f8c69cb3611543e2d:

{"objects": 
    [
        {
            "race_season_url": {"year": 2019}, 
            "uid": "even_6031fc282ac2453a9c6afce85ae3b224",
            "slug": "pre-season-testing-2019"
        }, 
        {
            "race_season_url": {"year": 2019}, 
            "uid": "even_84967f9f50834d0a83b4be663bd28068",
            "slug": "australian-grand-prix"
        },
        ...
    ]
}

What bothers me here:
There must be a better way of doing this, as most other calls are now direct get calls without parameters...

Event Header data

Events describe commulated sessions during a racing season. An event may represent a racing weekend, a pre season testing or something else.

Entry point for events:

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/grand-prix-header/<<event_url>>

Returns references for events.

Example:

{  
    "image_urls": [
        {
            "type": "Thumbnail", 
            "url": "https://f1tv-images.formula1.com/media/images/stills/event-occurrence/1144/7a546326b0f9c7f5afcd51c2985d44bb.jpg"
        }
    ], 
    "race_season_url": {"year": 2019}, 
    "winner_1_url": null, 
    "winner_2_url": null, 
    "winner_3_url": null, 
    "circuit_url": "/api/circuit/circ_e3eec4234bf84a348c8e517c658938b8/",
    "sponsor_url": null, 
    "nation_url": {
        "image_urls": [
            {
                "type": "Thumbnail", 
                "url": "https://f1tv-images.formula1.com/media/images/stills/nation/199/f4d241c4fa912c23e1f67d420c4a2db0.png"
            }
        ], 
        "name": "Pre-Season Testing"
    }, 
    "sessionoccurrence_urls": [
        {
            "self": "/api/session-occurrence/sess_56ba5ef9761049e7b5e0a2d16ed72424/",
            "status": "replay",
            "start_time": "2019-02-18T08:00:00+00:00",
            "nbc_status": "replay"
        }, 
        {
            "self": "/api/session-occurrence/sess_56d53153336749fb9dfb94bbbb0a2cab/",
            "status": "replay", 
            "start_time": "2019-02-18T13:00:00+00:00", 
            "nbc_status": "replay"
        }, 
        {
            "self": "/api/session-occurrence/sess_431c79e9dc4b4dd2bea4e41627544f44/",
            "status": "replay", 
            "start_time": "2019-02-19T08:00:00+00:00", 
            "nbc_status": "replay"
        }, 
        ...
        ], 
    "uid": "even_6031fc282ac2453a9c6afce85ae3b224", 
    "start_date": "2019-02-18", 
    "end_date": "2019-03-01", 
    "name": "Pre-Season Testing 2019", 
    "official_name": "Pre-Season Testing 2019", 
    "slug": "pre-season-testing-2019"
}

Sessions for Event

All sessions for one event can be queried using following scheme.

Note: To get actual data for a session, the session occurence needs to be called.

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/video-collection/<<event_uri>>/sessions

Episodes for Event

All episodes for one event can be queried using following scheme.

Note: To get actual data for an episode, the eipsode needs to be queried by its UID.

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/video-collection/<<event_uri>>/episodes

Sessions

A session is a defined time strip where action at a track is happening. A session is refered to by its Occurence URL.

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/session-occurrence/<<session_uid>>/

Example (https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/session-occurrence/sess_c450e68632244eb89b01759a79a26638/):

{
    "available_for_user":false,
    "image_urls":[
        {
            "type":"Thumbnail",
            "url":"https://f1tv-images.formula1.com/media/images/stills/session-occurrence/5259/50575363d44e60ce92a6ce3792e8e8c2.jpg"
        }
    ],
    "self":"/api/session-occurrence/sess_c450e68632244eb89b01759a79a26638/",
    "session_type_url":{
        "data_source_id":"9999",
        "name":"High Speed Test"
    },
    "status":"expired",
    "channel_urls":[
        "/api/channels/chan_5115a858e978497b837d7524730c45cd/"],
        "content_urls":[
            "/api/episodes/epis_a797aeb7098e46d48faeedf427328df8/",
            "/api/episodes/epis_7c57d9f78f424229b2ffd4c54035736d/",
            "/api/episodes/epis_111fdea5af974d55add99f58530b57eb/"
        ],
        "eventoccurrence_url":{
            "race_season_url":{"year":2019},
            "nation_url":{"name":"Pre-Season Testing"},
            "official_name":"Pre-Season Testing 2019",
            "slug":"pre-season-testing-2019"},
            "series_url":null,
            "uid":"sess_c450e68632244eb89b01759a79a26638",
            "live_sources_path":"/ingest-data/live_sources_403090_latest.json",
            "start_time":"2019-02-21T13:00:00+00:00",
            "end_time":"2019-02-21T18:00:00+00:00",
            "editorial_start_time":"2019-02-21T12:50:00+00:00",
            "nbc_pid":403090,
            "nbc_status":"expired",
            "name":"Day 4, Session 2",
            "session_name":"2019 Pre-Season Testing 2019 High Speed Test",
            "slug":"pre-season-testing-day-4-session-2"
        }

Episodes

An Episode is additional material that is provided at some events, like analysis, trailers etc.
Older races are modeled as Episodes, as they don't need additional data like individual cams for each driver.

URL:

https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/episodes/<<episode_uid>>/

Example (https://f1tv-api.formula1.com/agl/1.0/unk/en/all_devices/global/episodes/epis_0fe33e0052f14903afac9aec1ee9c556/):

{
  "image_urls": [
    {
      "type": "Thumbnail",
      "url": "https://f1tv-images.formula1.com/media/images/stills/content/7339/8dae7c4746df7bcac94d8e9762f4cd57.jpg"
    }
  ],
  "items": [
    {
      "duration": "0:35:13"
    }
  ],
  "self": "/api/episodes/epis_0fe33e0052f14903afac9aec1ee9c556/",
  "uid": "epis_0fe33e0052f14903afac9aec1ee9c556",
  "created": "2019-02-22T20:00:14.908958+00:00",
  "title": "Paddock Pass: 2019 Pre-Season Testing, Week 1",
  "slug": "2019-pre-season-testing-week-1-paddock-pass",
  "synopsis": "Will Buxton brings us the all the news, views, and paddock chat from the first pre-season test in Barcelona.",
  "subtitle": "",
  "series_urls": [],
  "vod_type_tag_urls": [
    {
      "data_source_id": "4",
      "name": "Feature"
    }
  ],
  "sessionoccurrence_urls": [
    {
      "eventoccurrence_url": {
        "official_name": "Pre-Season Testing 2019"
      }
    }
  ]
}

Playback

This call ist used to retrieve the asset_id for a given episode by its "slug". Playback retrieves the asset_id of an episode.

URL:

https://f1tv-api.formula1.com/agl/1.0/deu/en/all_devices/global/episodes/<<episode_slug>>/playback

Need to add another comment, as the first one might get too big.

TODOs I see right now:

  • Generate and pass Cookie from requests to player / inputstream somehow. This will hopefully fix live playback a little better #27
  • Refactor all API calls
  • Refactor Menu structure
  • Only use Authentication when required; Browsing of API does not require to be authenticated, as authentication is only necessary for generating the m3u8 + playing for channels

I can help you to refactor the API-calls to the new api-endpoints.
In fact: I had written a little research paper about developing a kodi plugin for F1 TV (in German) ๐Ÿ˜…๐Ÿ˜…

@lage2104 You can probably Message me in discord (bbsan#6190) - Iโ€˜m also German btw๐Ÿ˜‰

This is related to 2020s "new api" there is now another "New API" for 2021 with much better qualities available (1080p50fps) I'll be closing this in favor of the projects board for tracking.