How to create/access MediaSpace channel playlist with API

Hello All,
I am trying to create MediaSpace channel playlists and set its entitlements with Kaltura API. I manually created new Mediaspace channel and playlist under it. I can see it automatically created new category with the channel name and new playlist in KMC and they are connected with unknown property channelPlaylistsIds inside the category metadata. I believe I can now set entitlements on this category and it controls access to channel playlist and its media. My question is which API to use to create such channel and channel playlist? I was out of luck searching API docs.
Thanks for any ideas,
Zbynek

Hi @z.dusatko,

In regards to KMS channels, please see my explanation here:

As for creating playlists, the APIs for that are here:

In MediaSpace, you can also configure which playlist will be used for the carousel module but that requires access to the KMS admin console.
Playlists can be static (containing a fixed list of entries) or dynamic (baseed on a rules).

Hi Jess,
thanks for a quick response. I am assuming I can search for metadata for particular category id and particular metadataProfileId with metadata.list but I am confused how to get metadataProfileId for metadata property “channelPlaylistsIds”. I see metadataProfile.list but I am not sure which filter to use.
Thanks,
Zbynek

Hi @z.dusatko,

Not sure I understand your end goal. Can you please explain what it is you’re trying to achieve?
If you want to filter playlists according to categories, you can use:

$filter = new KalturaPlaylistFilter();
$result = $client->playlist->listAction($filter, $pager);

Where the following category related filters are available:

$filter->categoriesFullNameIn= 
$filter->categoriesIdsMatchAnd=     
$filter->categoriesIdsNotContains=  
$filter->categoriesMatchOr=         
$filter->categoriesIdsEmpty=        
$filter->categoriesIdsMatchOr=      
$filter->categoriesMatchAnd=        
$filter->categoriesNotContains=

As you can see, you can filter by category IDs or by category names. For the logical AND and OR operations, a comma separated list can be passed, as in:
"$catId0, $catId1"
or:
$catName0, $catName1"

The above is PHP code but of course, this is available for any of the Kaltura API clients.
You can look at:

Which exposes all filtering options and will also generate code in the selected language.

Hi Jess,
my end goal is to create Mediaspace channel playlist with API. If I understand it correctly I need to create category and playlist. To glue it together I need to create metadata for this category with field named “channelPlaylistsIds”. Now to create metadata I need metadataProfile, my question is how do I find this metadataProfile knowing only its field name “channelPlaylistsIds”? Not sure if I just made it more confusing. Thanks for your patience.
Z.

Hi @z.dusatko,

Below are the requests needed to create a new playlist and attach it to a given channel. I’ve annotated each request, explaining the parameters. Note of course that the IDs will be different in your case and that you should call the list() action for the relevant service with the correct filter to obtain the right IDs.

The requests are in pure HTTP form since I don’t know which API client you using, you should call the corresponding service and action pair from your code.

You can generate the code samples for making each such request for your client by going to developer.kaltura.com and typing the SERVICE.ACTION in the search box and then clicking on “Try it out”.

# create a playlist called "myplay":
/api_v3/index.php?service=playlist&action=add&playlist:objectType=KalturaPlaylist&playlist:playlistType=3&playlist:name=myplay&playlist:description=&playlist:userId=__kmsInternalChannelPlaylistUser__&playlist:tags=&updateStats=&partnerId=101&ks=

# get a list of sub categories under MediaSpace>playlists:
/api_v3/index.php?service=category&action=list&filter:objectType=KalturaCategoryFilter&filter:fullNameEqual=MediaSpace>playlists&partnerId=101&ks=

# add a new category entry record/object with entryId=0_wbm71z1c, 0_wbm71z1c is the playlist ID returned from the 
service=playlist&action=add request, categoryId=50 is MediaSpace>playlists on my ENV: 
/api_v3/index.php?service=categoryentry&action=add&categoryEntry:objectType=KalturaCategoryEntry&categoryEntry:categoryId=50&categoryEntry:entryId=0_wbm71z1c&partnerId=101&ks=

# update the relevant metadata object:
# metadata ID 5 has:
# metadata_profile_id: 12 - that's the ID for the profile whose name is CategoryAdditionalInfo on my ENV]
# objectIdIn: 140 - the category ID for MediaSpace>site>channels>mbp which is the channel I want this playlist to be attached to
# <Value>0_wbm71z1c,0_jlpl1snw,0_9fxaraxx,</Value> - since this channel already has 2 priorly created playlists, we need to concat the new one, 0_wbm71z1c to those who already exist, hence the metadata->list request from before]

/api_v3/index.php?service=metadata_metadata&action=update&id=5&xmlData=<?xml version="1.0"?>
<metadata><Detail><Key>commentsPrivate</Key><Value/></Detail><Detail><Key>isSharedRepository</Key><Value>isSharedRepository_false</Value></Detail><Detail><Key>channelPlaylistsIds</Key><Value>0_wbm71z1c,0_jlpl1snw,0_9fxaraxx,</Value></Detail></metadata>

Hope this helps,

Hi Jess,

I can’t get it working for playlist.
I created new playlist, created new categoryEntry with this new playlist id and channel (=category) id, then successfully found Meta object for that category and updated its xmlData channelPlaylistsIds.
Now if I check categoryEntry.list for my category in addition to already existing media there I see my new playlist there. I also checked metadata object for the category and the only change is that my playlist id was added to channelPlaylistsIds.
Unfortunately it is still not showing under my Mediaspace channels.

There is one thing that makes me wonder, I already have playlist attached to the channel but categoryEntry.list shows only single media ids there and not the existing playlist id?

Thanks,
Zbynek

This is just post update. We found that in addition to all above we need also all media in the playlist to be added to channel’s categoryEntry one by one. Otherwise the channel playlist would either not show at all or with some “500” server errors being displayed. Also for some reason it takes between a half an hour or hour to see the result after running above APIs.

Hi @z.dusatko,

The reason it takes a while is the caching mechanism. Should be about 15 minutes but if you’ve made several such requests at varying intervals, it may take longer before all the changes are reflected in the front end.