Adding a MediaSapce channel to a category via API


#1

I’m currently looking for a way to associate a MediaSpace channel with and existing MediaSpace Gallery/category via the API. I know this can be done through MediaSpace’s web interface, however I haven’t yet found out how to do this from the API.


How to create/access MediaSpace channel playlist with API
Define group relation to categories\channels
Private videos in media list response
#2

Hi @jvlogwood,

This is accomplished by a combination of calls to the category, categoryuser and metadata APIs.
Just so we’re sure, can you describe the exact flow in MediaSpace you’d like to automate using API calls?
I’ll then allocate some time to put together a code sample later today.


#3

Hey Jess,
Not to far in the future I’m going to need to set up about a hundred different MediaSpace channels, and probably more later on. I’m looking to essentially automate the functionality that is provided on the “Create a New Channel” page in order to save time. On the “Create a New Channel Page” in MediaSpace you are allowed to set a name, description, tags, privacy context, moderation, if comments are enabled or not, and the categories that this channel falls under. I’ve figured out how to do pretty much everything everything except for that last piece which is associating a channel to a category.

Also currently I’m not worried about associating users with the channels, other than the owner of the channel of course.

Any help you can give would be great.

Thanks,
James


#4

Hey James,

Below are the needed API calls in raw form [you can use whatever language you are most comfortable with and the relevant client lib to do the same using code].

Channels are implemented as categories, the first call creates a category, passing 701 as parentId.
In your case, the ID will be different, of course. Here is what category ID 701 looks like on my ENV:

*************************** 1. row ***************************
                         id: 701
                  parent_id: 699
                      depth: 2
                 partner_id: 102
                       name: channels
                  full_name: MediaSpace>site>channels
...

You can find the right ID for your case with category->list().
Optionally, you can pass a channel description to the call if you wish, my partner ID is 102, I am not including the KS but the gist of the call looks like this:

api_v3/index.php?service=category&action=add&format=2&ignoreNull=1&category:objectType=KalturaCategory&category:parentId=701&category:name=mbp&category:description=&category:tags=&partnerId=102

Next up is setting the custom metadata for whether or not to allow comments.
metadataProfileId=31 is the ChannelComments custom metadata profile on my ENV. This is created by KMS during deployment. You can find yours with a call to service=metadata_metadataprofile&action=list, passing the name “ChannelComments” as filter, or you can go to $MEDIASPACE_URL/admin/config/tab/comments#channelCommentsProfileId and find it there.
the add() action accepts an XML, similar to the below.

api_v3/index.php?service=metadata_metadata&action=add&format=2&ignoreNull=1&metadataProfileId=31&objectType=2&objectId=884&xmlData=<metadata><AllowCommentsInChannel>true</AllowCommentsInChannel></metadata>&partnerId=102

You also need a call to add metadata to the categoryAdditionalInfo ProfileId, which in my case, is 24:

*************************** 1. row ***************************
               id: 24
       created_at: 2015-12-21 16:52:59
       updated_at: 2015-12-21 16:52:59
          version: 2
file_sync_version: 2
    views_version: 2
       partner_id: 102
             name: CategoryAdditionalInfo
      system_name: CategoryAdditionalInfo`

The call looks like this:
api_v3/index.php?service=metadata_metadata&action=add&format=2&ignoreNull=1&metadataProfileId=24&objectType=2&objectId=884&xmlData=<?xml version="1.0"?>
<metadata><Detail><Key>commentsPrivate</Key><Value/></Detail></metadata>

Then, we also need to decide about the moderation type, in my case, I chose 0, which means no moderation. If moderation is required, you can set it to 1 instead.

api_v3/index.php?service=category&action=update&format=2&ignoreNull=1&id=884&category:objectType=KalturaCategory&category:id=884&category:moderation=0&partnerId=102

And here is the resulting category/channel:

id: 884
parent_id: 701
depth: 3
partner_id: 102
name: mbp
full_name: MediaSpace>site>channels>mbp

Hope this helps,


#5

Hey Thanks! I’ll give it a shot and let you know how it goes.


#6

Well I’m very glad to report that this was a huge help, which got me on the right path to manipulating the “ChannelCategories” metadata which was my ultimate goal all along.

Thanks again!


#7

Hi James,

Great. Glad to hear it helped:)


#8

hi Jess, I couldn’t follow your steps ):
The first error I got was adding data by the matedate service - when I input the same thing xml data - "?xml version=“1.0” I get error - "invalid metadata data: The document has no document element. at line 0."
If I remove the line the error stays the same.

And in the last call I get the error - “Current User is not entitled to update this category”.
When I am the only client, only admin and creator.
Additionally, in the last call - how do I choose moderation type? I Can’t see it.

Is there a simple way to see all the channels in a category?
Is there a way to get the channel ID by name?
Or assign a channel to a category?
Or see all channels for client? (In Category.Objects there are no channels, only categories)

Any one these tasks will be good for me, I failed to find any documentation on how it is done.
Thanks ahead, Dor.


#9

Hi Dor,

The best place to go to for API documentation is https://developer.kaltura.com.
Under https://developer.kaltura.com/recipes, you’ll find step by step code examples for various tasks, including adding metadata: https://developer.kaltura.com/recipes/metadata#/start

As for entitlement, you can set:
privileges = “disableentitlement”;
and then pass privileges as the last parameter of the session.start() call. This will disable any entitlement enforcement.

As I said, channels are just categories with special attributes, look at the HTTP requests I posted above for examples.
If you have specific code snippets that do not work, feel free to post them.


#10

Hi Jess, first of all thanks for the quick replay,
I have already visited https://developer.kaltura.com, it contains no information regarding channels and/or their connection to categories,
I tried looking into matedate because you referred to it in the answer above, but in the linked documentation is just information on how to upload or download files…
Nothing regarding channels…

I need to get a list of channels, and I couldn’t find it anywhere :confused:
Its like the whole channels section is entirety different from the category’s.
Dor.


#11

Hi Dor,

There is no specific info about channels because, as I said, channels is a KMS concept, not an API one. Channels are just categories with “special” attributes. That is, they are categories that reside under specific parent categories KMS is configured to look at and they have specific entitlement and moderation options set on them.

This URL https://developer.kaltura.com/recipes/metadata#/start will walk you through using the metadata APIs, which KMS makes vast use of, for several important functions.
Please see the calls I am referring to in my original answer to James. If there are specific questions you have or code that is not working for you, feel free to post it.