OpenBroadcaster Documentation
models / media_model.php

MediaModel

Model

Manages general media data, not including various types of metadata (which have their own models).

public  media_info ( args = [] )

Return info about uploaded file.

Originally in upload.php, moved here so it can be used elsewhere.

Parameters
filename
Returns [type, duration, format]
public  get_init_what ( args = [] )

Initialize database query by adding several parts in advance, such as what items to get (media ID, title, artist, some custom metadata, etc).

public  get_init_join ( args = [] )

Initialize database by adding parts in advance, by joining the media table with the media categories, media languages, media countries, media genres, media metadata, and users tables.

public  get_init ( args = [] )

Combine the get_init_what and get_init_join methods to set up the initial part of a media query.

public  get_by_id ( args = [] )

Get a media item.

Parameters
id
Returns media
public  get_permissions ( args = [] )

Get permissions linked to a media item.

Parameters
media_id
Returns [groups, users]
public  search_get_default_filters ( args = [] )

Get a user's default filters for searching media.

Parameters
user_id
Returns filters
public  search_default ( args = [] )

Set a user's saved search as the default search.

Parameters
id ID of the search to set as default.
user_id
Returns success
public  search_unset_default ( args = [] )

Unset any custom searches set as the default for a user.

Parameters
user_id
public  search_save ( args = [] )

Save a search query. Uses the currently logged in user's ID to determine the user_id for the saved search, rather than accepting it as a parameter.

Parameters
query
public  search_get_saved ( args = [] )

Retrieve a saved search of the currently logged in user (does not accept a user ID parameter) of the provided type.

Parameters
type
Returns searches
public  search_save_history ( args = [] )

Save a search query in the history as a saved search.

Parameters
id
user_id Optional. Additional WHERE qualifier to find the search.
public  search_delete_saved ( args = [] )

Delete an item in the media searches table.

Parameters
id
user_id Optional. Additional WHERE qualifier to find the search.
public  search_edit ( args = [] )

Edit an item in the media searches table.

Parameters
id
filters
description
user_id Optional. Additional WHERE qualifier to find the search.
public  search ( args = [] )

Search media items.

Parameters
params
player_id Optional. Specify player to search associated media items.
random_order Dont bother ordering data. FALSE by default.
include_private Bypass private media restriction (shows private media not owned by current owner, does not require manage media permission or player_id).
Returns [media, total_media_found]
public  search_filters_validate ( args = [] )

Validate search filters. Ensures that filters only contain recognized fields and operators.

Parameters
filters
Returns is_valid
public  search_filters_where_array ( args = [] )

Return a 'WHERE' SQL array from a search filters array.

Parameters
filters
Returns where_array
public  where_used ( args = [] )

Get information about where media is used.

Parameters
id
include_dynamic Include dynamic selections. FALSE by default.
Returns [used, id, can_delete]
public  validate ( args = [] )

Validate a media item before inserting or updating.

Parameters
item Media item to validate.
skip_upload_check Upload check is done by default, set to TRUE to skip.
is_valid
public  save ( args = [] )

Insert or update a media item.

Parameters
item
Returns id
public  versions ( args = [] )

Get version information about a media item.

Parameters
data Media item, should contain 'media_id' to check for versions.
Returns versions
public  version_add_original ( args = [] )

Add the original version of the media item to the versioning table. Will do nothing if an original version already exists.

Parameters
data Media item, should contain 'media_id' for versions table.
public  version_add ( args = [] )

Add a version item.

Parameters
data Should contain 'media_id', 'file_id', and 'file_key' at least.
public  version_edit ( args = [] )

Update a version.

Parameters
data Should contain 'media_id' to identify item and 'created' to identify version.
public  version_delete ( args = [] )

Delete a version.

Parameters
data Should contain 'media_id' to identify item and 'created' to identify version.
public  version_set ( args = [] )

Set the version for a media item.

Parameters
data Should contain 'media_id' to identify item and 'created' to identify version.
public  versions_delete_all ( args = [] )

Remove all versions for a media item.

Parameters
data Should contain 'media_id' to identify associated versions.
public  archive ( args = [] )

Move approved media items to archive.

Parameters
ids Array of media item IDs.
public  unarchive ( args = [] )

Unarchive media IDs.

Parameters
ids Array of media item IDs.
public  delete ( args = [] )

Delete media items. Can only remove archived or unapproved items.

Parameters
ids Array of media item IDs.
Returns success
public  delete_cached ( args = [] )

Delete cached media item.

Parameters
media
public  formats_validate ( args = [] )

Validate media formats.

Parameters
data Array of format strings.
Returns [is_valid, msg]
public  formats_save ( args = [] )

Save accepted media formats.

Parameters
data Multidimensional ('audio_formats', etc.) array of accepted formats.
public  formats_get_all ( args = [] )

Retrieve all accepted formats.

Returns [audio_formats, video_formats, image_formats]
public  remove_where_used ( args = [] )

Remove all associated instances where a media item is used. Note that we cannot rely on CASCADE in the database to update this for us, as the media IDs will still exist when moved to the archive, but we want to remove the media IDs from the associated tables anyway.

Parameters
id
public  format_allowed ( args = [] )

Check whether a given type/format is allowed and valid.

Parameters
type Image, audio, or video.
format
Returns is_valid
public  rand_file_location ( args = [] )

Generate a random file location (splitting files up into directories). Also create directories in upload.

Returns rand_chars
public  getid3 ( args = [] )

Retrieve ID3 tag.

[artist, album, title, comments]

Parameters
filename
private  id3makesafe ( array )

Make ID3 tags safe for reading.

Parameters
array ID3 tags array.
Returns tags