Skip to content

Class: Videos

Saqib Razzaq edited this page Mar 17, 2019 · 9 revisions

Videos class is responsible for all major video related operations. This includes uploading, inserting, updating, deleting among many others. This page lists all available methods of Videos class along with examples.

initialize

Thus method creates required variables and makes things ready for all other parameters. This is a required method when creating new Videos() object.

Parameters
[object] $database [optional]

You can pass already initialized Database object or functional will automatically try to use global object.

Examples
$videos = new Videos();
$videos->intialize();

column

This method determines if given value is video id (int) or vkey (string)

Parameters
[mixed] $identifier

Any videoid or vkey

Returns

Returns 'id' or 'vkey' depending on value provided.

Examples
$videos->column(1412); // outputs id
$videos->column('7v0cw_tPRm'); // outputs vkey

owns

Check if a video is owned by certain user.

Parameters
[string] $username

Username to check ownership against.

[mixed] $video

Videoid or vkey for video to be checked for ownership.

Returns

This returns boolean value. Please note that all Admin (user with level 1) own all videos and this will return true if user is Admin even if uploader is different.

Examples
$videos->owns('stark', 1412);
$videos->owns('jon', '7v0cw_tPRm');

exists

Check if a value exists against given columns

Parameters
[string] $fields

Single field or set of field => value to match

[mixed] $value [optional]

Value to match against when $fields is string

[string] $fetch [optional]

Fields to return if match is found

Returns

Returns boolean or array of fields requested in $fetch parameter

Examples

idExists

Check if given id exists

Parameters
[integer] $id

ID to check for

Returns

Boolean depending case of value found

Examples

keyExists

Check if given vkey exists

Parameters
[string] $vkey

vkey to check for

Returns

Boolean depending case of value found

Examples

filenameExists

Check if given filename exists

Parameters
[string] $filename

Filename to check for

Returns

Boolean depending case of value found

Examples

get

Get all fields for a single video

Parameters
[mixed] $identifier

Value of field to search against

[string] $type [optional]

Name of field to search against, by default it tries to determine between ID and vkey

Returns

An array of data consisting of all available columns against matching video.

Examples

getField

Get a single field for a single video

Parameters
[mixed] $identifier

ID or vkey to search for

[string] $field

Name of field to fetch

Returns

An array of data for matching video

Examples

getFields

Get a multiple fields for a single video

Parameters
[mixed] $identifier

ID or vkey to search for

[array] $fields

A list of fields to fetch

Returns

An array of data consisting of fields requested only.

Examples

setField

Update a single field of single video

Parameters
[string] $field

Field to be updated

[mixed] $value

New value to set

[mixed] $identiferValue

Value to search video by

[string] $identifier [optional]

Column to search against. If false then function will consider it vkey.

Returns

Boolean depending on how update query went.

Examples

setFieldBulk

Update a single field of multiple videos

Parameters
[string] $field

Field to be updated

[mixed] $value

New value to set

[array] $identifierValueArray

Value list to search video by

[string] $identifier [optional]

Column to search against. If false then function will consider it vkey.

Returns

Boolean depending on how update query went.

Examples

setFields

update multiple fields of single video

Parameters
[array] $fieldValueArray

An assoc. array of field => value to update

[mixed] $identiferValue

Value to search video by

[string] $identifier [optional]

Column to search values against. If false then function will consider it vkey.

Returns

Boolean depending on status of update.

Examples

setFieldsBulk

update multiple columns of multiple videos

Parameters
[array] $fieldValueArray

An assoc. array of field => value to update

[mixed] $identiferValueArray

List of values to search videos by

[string] $identifier [optional]

Column to search values against. If false then function will consider it vkey.

Returns

Boolean depending on status of update.

Examples

getById

Get all fields of video by id

Parameters
[integer] $id

ID to search video by

Returns

An array consisting of all columns for matching video.

Examples

getByKey

Get all fields of video by key

Parameters
[integer] $vkey

vkey to search video by

Returns

An array consisting of all columns for matching video.

Examples

getByFilename

Get all fields of video by filename

Parameters
[integer] $filename

Filename to search video by

Returns

An array consisting of all columns for matching video.

Examples

getId

Get ID of video

Parameters
[string] $identifier

vkey of video to fetch

Returns

ID for matching video

Examples

getKey

Get key of video

Parameters
[string] $identifier

ID of video to fetch

Returns

vkey for matching video

Examples

getFilename

Get Filename of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Filename for matching video

Examples

getUploaderId

Get video uploader's ID

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Video uploader's ID for matching video

Examples

getUploaderName

Get video uploader's name

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Video uploader's name for matching video

Examples

getDate

Get publish date of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

The publish date for matching video

Examples

getTitle

Get title of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

The title for matching video

Examples

getDescription

Get description of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Description for matching video

Examples

getScope

Get scope of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Scope for matching video

Examples

getFeatured

Get featured status of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Featured status for matching video

Examples

getStatus

Get processing status of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Processing status for matching video

Examples

getQualities

Get qualities of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

List of available qualities for matching video

Examples

getDuration

Get duration of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Duration for matching video

Examples

getThumbnailsCount

Get thumbnails count of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Total thumbnails count for matching video

Examples

getViews

Get total views of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Total views count for matching video

Examples

getComments

Get total comments of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

Total comments count for matching video

Examples

getState

Get state of video

Parameters
[string] $identifier

ID or vkey of video to fetch

Returns

State for matching video

Examples

list

List videos matching several dynamic parameters

Parameters
[array] $parameters

An array of parameters to match videos against. This array can contain any of columns from 'videos' table. You can select values using =, >, >=, < or <= to have more control.

Returns

An array consisting of videos that matched pattern after $limit was applied.

Examples

listTrending

List most viewed videos since start

Parameters
[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listFresh

List most recent videos

Parameters
[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listByState

List most videos by specific state

Parameters
[string] $state

State of video to fetch. Options for this are active, inactive or disabled

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listActive

List videos by active state

Parameters
[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listInactive

List videos by inactive state

Parameters
[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listByStatus

List videos by processing status

Parameters
[string] $status

Conversion status of video to fetch. Options for this are pending, successful or failed.

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listSuccessful

List successfully processed videos

Parameters
[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listPending

List videos that are pending processing

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listFailed

List most videos that failed during processing

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listByScope

List by a specific scope

Parameters
[string] $status

Conversion status of video to fetch. Options for this are pending, successful or failed.

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listPublic

List public videos

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listPrivate

List private videos

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listUnlist

List unlisted videos

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

listByUploader

List videos by specific uploader

[string] $uploader

Uploader's name or user ID

[mixed] $limit

Number or MySQL style limit

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of videos matching parameters.

Examples

count

Count total videos matching parameters

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

countActive

Count total active videos

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

countInactive

Count total inactive videos

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

countSuccessful

Count total successful videos

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

countPending

Count total pending videos

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

countFailed

Count total failed videos

Parameters
[array] $parameters [optional]

An array of parameters to match and count videos against

Returns

The number of videos found

Examples

validateUpload

Validate video upload data before moving into processing queue

Parameters
[object] $fileData

The raw $_FILES object

Returns

True if upload is valid and false if it isn't

Examples

validateUpdate

Validate fields before updating video

Parameters
[array] $fields

The fields array to be updated

Returns

True if update is valid and false if it isn't

Examples

validateInsert

Validate form before inserting video

Parameters
[array] $fields

The fields array to be updated

Returns

True if update is valid and false if it isn't

Examples

validatePermissions

Validate permissions of logged in user requesting changes to video

Parameters
[mixed] $video

ID or vkey of video to check

Returns

Boolean

Examples

activate

Set video state to active

Parameters
[mixed] $video

ID or vkey of video to activate

Returns

Boolean depending on how request went

Examples

bulkActivate

Set video state to active for multiple videos

Parameters
[array] $videosArray

A list of videos to be activated

[string] $identifier [optional]

Column to match list against. If nothing is specified then it is considered 'vkey'.

Returns

Boolean depending on how request went

Examples

deactivate

Set video state to inactive

Parameters
[mixed] $video

ID or vkey of video to deactivate

Returns

Boolean depending on how request went

Examples

bulkDeactivate

Set video state to inactive for multiple videos

Parameters
[array] $videosArray

A list of videos to be deactivated

[string] $identifier [optional]

Column to match list against. If nothing is specified then it is considered 'vkey'.

Returns

Boolean depending on how request went

Examples

feature

Set video to featured

Parameters
[mixed] $video

ID or vkey of video to be featured

Returns

Boolean depending on how request went

Examples

unfeature

Remove video from featured

Parameters
[mixed] $video

ID or vkey of video to be unfeatured

Returns

Boolean depending on how request went

Examples

delete

Delete a video and all media files belonging to it

Parameters
[mixed] $video

ID or vkey of video to delete

Returns

Boolean depending on how request went

Examples

bulkDelete

Delete multiple videos and their media files

deactivate

Set video state to inactive

Parameters
[array] $videosArray

A list of vkeys to be deleted

Returns

Boolean depending on how request went

Examples

createKey

Create unique public key to be used for new video

Returns

Unique video key that doesn't exist in database

Examples

createFilename

Create unique filename to be used for new video

Returns

Unique video filename that doesn't exist in database

Examples

upload

Upload a new video file

Parameters
[object] $fileData

The raw $_FILES object

Returns

filename, path and directory of uploaded video

Examples

insert

Insert a video into database

Parameters
[array] $form

Raw form fields

Returns

ID of inserted video

Examples

update

Update a video's fields

Parameters
[mixed] $identifier

ID or public key

[array] $details

Array with fields and values to be updated

Returns

Boolean depending on how update went

Examples

setViews

Increment video views

Parameters
[mixed] $video

ID or public key

[integer] $views

Number of views to increment

Returns

Boolean

Examples

setComments

Increment video comments

Parameters
[mixed] $video

ID or public key

[integer] $comments

Number of comments to increment

Returns

Boolean

Examples
Clone this wiki locally