Changing the 'created' property of a Video object

Hi all,

I would like to know if I could change the ‘created’ property of a video object, so as to be able to use the stream API and call the objects according to the date of creation, as set by me. This is to pipe the process with a date-time widget and call specific videos. The problem is, my video library has been uploaded by me, all at once and possesses the same ‘created’ property which is not usable for me.

I saw a similar topic, that has been closed earlier on the forum, that talks about changing the name and requiredSignedURL property, but it did not serve me.

Any help would be great.

Thanks in advance.

It doesn’t appear to be possible with the API. Unless this is changed, I suspect this’d be solved by a local database, with video ID’s corresponding with customisable date records.

1 Like

Created field is read-only because it contains the timestamp of when the video was uploaded to Stream.

You can use the meta field of the video which is editable to store arbitrary json value such as a timestamp field.

1 Like

Oh cool. Just had a play with that. This command was able to set a meta data value for “date”:

curl -X POST -H "Authorization: Bearer $API_TOKEN"$ACCOUNT_ID/stream/$VIDEO_ID -H "Content-Type: application/json" --data '{"meta":{"date":"2014-01-02T02:20:00Z"}}'

Note $API_TOKEN, $ACCOUNT_ID and $VIDEO_ID that need to be adjusted to your own values.

being able to add a custom meta-data is cool. However, the API wouldn’t act on it, though. It’s restricted to work on just the ‘created’ property, to fetch multiple videos at once. The need to have a local database and custom functions, still remains.

@Bink @zaid

I imagine it would be possible to pull a full list of videos (which will include your custom meta data), then parse the JSON data to your needs, circumventing the need for a local database.

1 Like

As per the above issue, there is a limit of 1000 objects when fetching ALL the available videos. So, parsing JSON is a solution, but not all that scalable, when the quantity of videos, would increase.

Appreciate your input on the problem, though. It’s just that, I think the Stream API needs to be more dynamic.

The API actually supports pagination, specifically following parameters:

  • limit (default=1000)
  • end (timestamp; only videos posted after this timestamp will be listed)
  • include_counts (default=false; when set to true, you will see two new properties: total and range that tell you where you are while paginating)

As an example, let’s say. you want to get a list of videos and you have more than 1000. videos:

First call:{{ cf_account_id }}/stream/?include_counts=true

This will get the first 1000 videos. By reading the total property, you’ll know if you have more than 1000. videos. If you have >1000, you can take the created timestamp from the last video and make the next call:{{ cf_account_id }}/stream/?include_counts=true&end=2019-05-28T09:23:11.038118Z

This way you can traverse through all the videos.

We will document this more thoroughly in the docs.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

@ashutosh I see what you mean. You’d like to see a way to filter by the custom metadata you would set in the Stream API? How does your datetime widget work? For example, if we provided a simple string equality check for metadata fields as a filter in the API would this solve your requirement in the datetime widget?

as @bink suggested, the local database approach seems to be the right one if you require more advanced filtering or ordering.