OpenBroadcaster Documentation
controllers / media.php

Media

Controller

The media controller manages all media on the server. It also manages acceptable formats, searching, versioning, and archiving for media items.

public  archive ( )

Archive media items. Requires the 'manage_media' permission.

Parameters
id An array of media IDs. Can be a single ID.
API Route POST /api/v2/media/archive
public  delete ( )

Delete archived or unapproved media items. Requires 'manage_media' permission. Will return an error if any of the media items aren't archived or unapproved.

Parameters
id An array of media IDs. Can be a single ID.
API Route DELETE /api/v2/media/archive
public  formats_get ( )

Return all acceptable media formats.

Returns formats
API Route GET /api/v2/media/formats
public  formats_save ( )

Update the acceptable media formats table. Video, image, and audio formats are set separately. Requires the 'manage_media_settings' permission.

Parameters
video_formats
image_formats
audio_formats
API Route POST /api/v2/media/formats
public  get ( )

Get a single media item.

Parameters
id
Returns media
API Route GET /api/v2/media/(:id:)
public  media_my_searches ( )

Return media search history and saved searches for currently logged in user.

Returns [saved, history]
API Route GET /api/v2/media/searches
public  media_my_searches_default ( )

Set a search item to be part of the default search for the current user. This means that simple searches will by default include the filters specified here.

Parameters
id
API Route POST /api/v2/media/searches/default
public  media_my_searches_delete ( )

Delete a search query from the user's saved searches.

Parameters
id
API Route DELETE /api/v2/media/searches/(:id:)
public  media_my_searches_edit ( )

Edit a search query in the user's saved searches.

Parameters
id
filters
description
API Route PUT /api/v2/media/searches/(:id:)
public  media_my_searches_save ( )

Saves an item by moving it from 'history' to 'saved' in the media searches table.

Parameters
id
API Route POST /api/v2/media/searches
public  media_my_searches_unset_default ( )

Unset a default search filter for the current user.

Parameters
id
API Route DELETE /api/v2/media/searches/default/(:id:)
public  save ( )

Edit media items. Can update more than a single item at once. User requires 'create_own_media' or 'manage_media' permissions to update media items. Also, 'media_advanced_permissions' is required to update any of the advanced permissions fields. Media gets validated, and will only be updated if validation succeeds for all provided items. This method gets information from the Uploads model and makes sure to add that to the media items.

Parameters
media The media items to update.
API Route PUT /api/v2/media
public  search ( )

Search the media tables for one or more items.

Parameters
q Query
l Limit
o Offset
sort_by
sort_dir
s Status
my Ownership. Set to filter for media items owned by user.
save_history Save to search history if set and we're in advanced search mode.
Returns [num_results, media]
API Route GET /api/v2/media/search
public  unarchive ( )

Unarchive media items. Requires 'manage_media' permission.

Parameters
id An array of media IDs. Can be a single ID.
API Route POST /api/v2/media/archive/undo
private  user_can_edit ( media )

Returns a boolean value determining whether the current user can edit the provided media item. Private method used by a number of other methods in this controller. The rules go as follows:

If the user has the 'manage_media' permission, return TRUE. If the media item is owned by the user AND the user has the 'create_own_media' permission, return TRUE. If the user is in the permissions column for the specified media item, return TRUE. If one of the user's groups is in the groups permissions column for the specified media item, return TRUE. Otherwise, return FALSE.

Parameters
media The media item to check. An associative array containing information about the item, including the ID.
Returns can_edit
public  version_add ( )

Add new media version file.

Parameters
media_id
file_id
file_key
API Route POST /api/v2/media/versions
public  version_delete ( )

Delete media version.

Parameters
media_id
created Version timestamp
API Route DELETE /api/v2/media/versions/(:media_id:)/(:created:)
public  version_edit ( )

Edit media version.

Parameters
media_id
created Version timestamp
notes
API Route PUT /api/v2/media/versions/(:media_id:)/(:created:)
public  version_set ( )

Set media active version.

Parameters
media_id
created Version timestamp
API Route PATCH /api/v2/media/versions/(:media_id:)
public  versions ( )

Get media versions.

Parameters
media_id
Returns [versions, media]
API Route GET /api/v2/media/versions/(:media_id:)
private  versions_require_permission ( media_id )

Checks that user can manage versions for media item. Does not return true or false, but can throw a permissions error using 'require_permissions'. Private method used by other version methods in this controller.

Parameters
media_id