DEV Community

Jonas Birmé for Consuo Dev Blog

Posted on

Using the in-built Auto Scheduler

The quickest way to get started and creating a virtual channel is to use the in-built auto-scheduler. In this blog post we will walk you through how this is done.

In the Consuo Schedule micro service, an automatic scheduler is included that can automatically add events to a channel's schedule. The assets for the events are randomly chosen and four events at the time are added back-to-back in the schedule. This can be used to create numerous virtual channel based on a search query in the VOD library. For example a virtual channel for all news clips about a news event that is unfolding.

Using auto-scheduler

When creating a new channel you define that this channel should use the automatic scheduler and you provide an URI to an Atom RSS feed containing the assets the automatic scheduler can choose from. Between your video asset search you build an adapter that translates the response into an Atom RSS xml. The mandatory fields are <id> and <link> but a title is recommended to also be provided.

<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Content from Eyevinn</title>
  <id>urn:uuid:883e6f00-783e-46d0-bb6c-0e15e6ac4e33</id>
  <updated>2020-05-22T08:48:00Z</updated>
  <entry>
    <id>urn:uuid:23d1d228-2305-4bc8-a937-1280a0d7e33a</id>
    <title>Tears of Steel</title>
    <link>https://maitv-vod.lab.eyevinn.technology/tearsofsteel_4k.mov/master.m3u8</link>
  </entry>
  <entry>
    <id>urn:uuid:1555b26b-ecdd-4658-b527-e35b6429ef58</id>
    <title>VINN</title>
    <link>https://maitv-vod.lab.eyevinn.technology/VINN.mp4/master.m3u8</link>
  </entry>
</feed>

To create a channel with automatic scheduling enabled you issue an HTTP POST with the following JSON to the /channels endpoint.

{
  "id": "mychannel",
  "name": "My Automatic Channel",
  "config": {
    "auto_populate": true,
    "auto_populate_content": <RSS_URI>,   
    "auto_cleanup": true
  }
}

The config parameter auto_populate when set to true enables the automatic scheduler and the auto_populate_content parameter points to the RSS feed.

To verify that the automatic scheduler is working you can fetch the schedule for this channel with an HTTP GET of /channels/mychannel/schedule and you would get something similar to this:

[
  {
    "channelId": "eyevinn",
    "assetId": "urn:uuid:da80b21b-2e6e-42ae-82b8-3b1b5581b59a",
    "eventId": "735fecc8-cade-410d-993f-9860e4de9efe",
    "id": "urn:uuid:da80b21b-2e6e-42ae-82b8-3b1b5581b59a",
    "title": "TV Plus Joachim",
    "start_time": 1590226668810,
    "end_time": 1590226741810,
    "start": "2020-05-23T09:37:48.810Z",
    "end": "2020-05-23T09:39:01.810Z",
    "uri": "http://lambda.eyevinn.technology/stitch/master.m3u8?payload=eyJ1cmkiOiJodHRwczovL21haXR2LXZvZC5sYWIuZXlldmlubi50ZWNobm9sb2d5L3R2cGx1cy1hZC1qb2FjaGltLm1vdi9tYXN0ZXIubTN1OCIsImJyZWFrcyI6W3sicG9zIjowLCJkdXJhdGlvbiI6MTYwMDAsInVybCI6Imh0dHBzOi8vbWFpdHYtdm9kLmxhYi5leWV2aW5uLnRlY2hub2xvZ3kvYWRzL3NmZi0xNXMubXA0L21hc3Rlci5tM3U4In1dfQ==",
    "duration": 73
  },
  {
    "channelId": "eyevinn",
    "assetId": "urn:uuid:b8ff551a-6da3-485a-8a53-b11c5d28753f",
    "eventId": "c25f531a-3bf5-4645-b3f0-cbaf4c7f459d",
    "id": "urn:uuid:b8ff551a-6da3-485a-8a53-b11c5d28753f",
    "title": "TV Plus Johanna",
    "start_time": 1590226741810,
    "end_time": 1590226816810,
    "start": "2020-05-23T09:39:01.810Z",
    "end": "2020-05-23T09:40:16.810Z",
    "uri": "http://lambda.eyevinn.technology/stitch/master.m3u8?payload=eyJ1cmkiOiJodHRwczovL21haXR2LXZvZC5sYWIuZXlldmlubi50ZWNobm9sb2d5L3R2cGx1cy1hZC1qb2hhbm5hLm1vdi9tYXN0ZXIubTN1OCIsImJyZWFrcyI6W3sicG9zIjowLCJkdXJhdGlvbiI6MTYwMDAsInVybCI6Imh0dHBzOi8vbWFpdHYtdm9kLmxhYi5leWV2aW5uLnRlY2hub2xvZ3kvYWRzLzZjZDdkNzY4LWUyMTQtNGViYy05ZjE0LTdlZDg5NzEwMTE1ZS5tcDQvbWFzdGVyLm0zdTgifV19",
    "duration": 75
  }
]

As you see in the example above the schedule events are all back-to-back and that is taken care of by the automatic scheduler.

The config parameter auto_cleanup specifies whether old events should be automatically removed.

This automatic scheduler is at the moment very basic and does not prevent that same assets in a row are scheduled and if you intend more sophisticated logic you can build your own automatic scheduler using the APIs provided.

And how to do that, we leave room for in another blog post. Stay tune!

Discussion (0)