View as Markdown

Catalog

OpenVideo:OpenVideoCatalog is a headless discovery component. Each function starts an asynchronous request, returns a requestId string, and publishes the completion on the result field.

Input fields

Field Type Description
config assocarray Uses channelSlug, and optionally apiBase, pageUrlBase and feedUrl. See Configuration.

Functions

Function Arguments Description
listVideos { category?, page? } Your channel's videos. category is featured (default), latest, most-views or most-likes. Pages of 12.
recentUploads { page? } Same as listVideos with latest; the result op is recentUploads.
listPlaylists { page?, pageSize? } Your channel's playlists. Defaults: page 1, 12 per page.
playlistVideos { playlistId?, playlistSlug?, page?, limit? } Videos in one playlist; playlistSlug wins when both are passed. Defaults: page 1, 25 per page.
search { query } Video items plus matching channels.
getVideo { videoId } One video as item, plus related.
cancel requestId Stops a request that is still running. Cancelled requests emit no result.

Result

{ requestId, op, page, items: [], hasMore, error: "" }

search results also carry channels; getVideo results carry item and related. Errors arrive as results with error <> "", an empty items and hasMore = false; the functions never throw. hasMore is true when a full page came back.

sub init()
    m.catalog = CreateObject("roSGNode", "OpenVideo:OpenVideoCatalog")
    m.catalog.config = m.cfg
    m.catalog.ObserveField("result", "onCatalogResult")
    m.catalog.callFunc("listVideos", { category: "featured", page: 1 })
end sub

sub onCatalogResult()
    result = m.catalog.result
    if result.error <> "" then print "Catalog error: "; result.error
    if result.op = "listVideos" then m.featuredItems = result.items
end sub