quvi API

See also Overview.

Summary
quvi APISee also Overview.
Functions
quvi_initCreates a new session.
quvi_closeCloses a previously started session.
quvi_setoptSets a session option.
quvi_getinfoReturns session info.
quvi_parseParses an URL.
quvi_parse_closeReleases a previously allocated media handle.
quvi_getpropReturns a media property.
Support
Functions
quvi_query_formatsQueries available formats to the URL.
quvi_next_media_urlIterates the media stream URLs.
quvi_supportedChecks whether library supports the URL.
quvi_supported_identOtherwise identical to quvi_supported but returns the `ident’ data.
quvi_supported_ident_closeReleases a previously allocated ident handle.
quvi_ident_getpropReturns an ident property.
quvi_next_supported_websiteReturns the next supported website.
quvi_strerrorReturns a corresponding error message to the return code.
quvi_versionReturns a quvi version string.
quvi_freeFrees allocated memory.

Functions

quvi_init

QUVIcode quvi_init(quvi_t *session)

Creates a new session.

Parameters

sessionNew session handle (receives)

Returns

Non-zero value if an error occurred.

See Also

Example

QUVIcode rc;
quvi_t q;
rc = quvi_init(&q);
if (rc != QUVI_OK)
  {
    fprintf(stderr, "%s\n", quvi_strerror(q,rc));
    return (rc);
  }
quvi_close(&q);

quvi_close

void quvi_close(quvi_t *session)

Closes a previously started session.

Parameters

sessionSession handle

See Also

quvi_init

quvi_setopt

QUVIcode quvi_setopt(quvi_t session,
QUVIoption option,
 ...)

Sets a session option.

Parameters

sessionSession handle
optionOption ID
...Parameter

Returns

Non-zero value if an error occurred.

Example

quvi_setopt(q, QUVIOPT_FORMAT, "best");
quvi_setopt(q, QUVIOPT_CATEGORY, QUVIPROTO_HTTP|QUVIPROTO_RTMP);

quvi_getinfo

QUVIcode quvi_getinfo(quvi_t session,
QUVIinfo info,
 ...)

Returns session info.

Parameters

sessionSession handle
infoInfo ID
...Parameter

Returns

Non-zero value if an error occurred.

Example

long resp_code;
quvi_getinfo(q, QUVIINFO_RESPONSECODE, &resp_code);

quvi_parse

QUVIcode quvi_parse(quvi_t session,
char *url,
quvi_media_t *media)

Parses an URL.

Parameters

sessionSession handle
urlURL (null-terminated string)
mediaMedia handle (receives)

Returns

Non-zero value if an error occurred.

See Also

Example

quvi_media_t m;
rc = quvi_parse(q, URL, &m);
if (rc != QUVI_OK)
  {
    ...
  }
quvi_parse_close(&m);

quvi_parse_close

void quvi_parse_close(quvi_media_t *media)

Releases a previously allocated media handle.

Parameters

mediaMedia handle

quvi_getprop

QUVIcode quvi_getprop(quvi_media_t media,
QUVIproperty property,
 ...)

Returns a media property.

Parameters

mediaMedia handle
propertyProperty ID
...Parameter

Returns

Non-zero value if an error occurred.

Example

Error handling omitted for brewity.

double media_content_length;
char *media_url;
quvi_media_t m;
quvi_t q;

quvi_init(&q);
quvi_parse(q, URL, &m);
quvi_getprop(m, QUVIPROP_MEDIAURL, &media_url);
quvi_getprop(m, QUVIPROP_MEDIACONTENTLENGTH, &media_content_length);
quvi_parse_close(&m);
quvi_close(&q);

Support

Summary
Functions
quvi_query_formatsQueries available formats to the URL.
quvi_next_media_urlIterates the media stream URLs.
quvi_supportedChecks whether library supports the URL.
quvi_supported_identOtherwise identical to quvi_supported but returns the `ident’ data.
quvi_supported_ident_closeReleases a previously allocated ident handle.
quvi_ident_getpropReturns an ident property.
quvi_next_supported_websiteReturns the next supported website.
quvi_strerrorReturns a corresponding error message to the return code.
quvi_versionReturns a quvi version string.
quvi_freeFrees allocated memory.

Functions

quvi_query_formats

QUVIcode quvi_query_formats(quvi_t session,
char *url,
char **formats)

Queries available formats to the URL.  The query is done over an Internet connection.  It resolves any shortened URLs unless QUVIOPT_NORESOLVE is set explicitly with quvi_setopt.  This function checks also if an URL is supported, similarly to that quvi_supported.

Unlike quvi_supported, quvi_supported_ident and quvi_next_supported_website which all return a static format ID list as specified in the webscript’s `ident’ function, quvi_query_formats constructs the list of format IDs dynamically for each URL.

Please note that this function returns only ‘default’ to those URLs that have their corresponding webscripts handle only one (1) format. e.g.  No internet connection is required in such case and a static string (‘default’) is returned to the caller instead.

Parameters

sessionSession handle
urlURL (null-terminated string)
formatsNull-terminated string (receives)

Returns

A null-terminated string or NULL.  quvi_free it when done.

See Also

Example

Error handling omitted for brewity.

char *formats;
quvi_t q;

quvi_init(&q);
quvi_query_formats(q, URL, &formats);
puts(formats);
quvi_free(formats);
quvi_close(&q);

quvi_next_media_url

QUVIcode quvi_next_media_url(quvi_media_t media)

Iterates the media stream URLs.

Parameters

mediaMedia handle

Returns

Non-zero value if an error occurred or QUVI_LAST, otherwise QUVI_OK.

See Also

quvi_getprop

Example

Error handling omitted for brewity.

quvi_media_t m;
char *url;
quvi_t q;

quvi_init(&q);
quvi_parse(q, URL, &m);
do
  {
    quvi_getprop(m, QUVIPROP_MEDIAURL, &url);
    puts(url);
  }
while (quvi_next_media_url(media) == QUVI_OK);
quvi_parse_close(&m);
quvi_close(&q);

quvi_supported

QUVIcode quvi_supported(quvi_t session,
char *url)

Checks whether library supports the URL.  Does not require an Internet connection.  Shortened URLs will fail with this function.

Parameters

sessionSession handle
urlURL (null-terminated string)

Returns

Non-zero value if an error occurred or QUVI_NOSUPPORT, otherwise QUVI_OK.

See Also

quvi_supported_ident

quvi_supported_ident

QUVIcode quvi_supported_ident(quvi_t session,
char *url,
quvi_ident_t *ident)

Otherwise identical to quvi_supported but returns the `ident’ data.

Parameters

sessionSession handle
urlURL (null-terminated string)
identIdent handle (receives)

Returns

Non-zero value if an error occurred.

See Also

Example

Error handling omitted for brewity.

quvi_ident_t ident;
quvi_t q;

quvi_init(&q);
if (quvi_supported_ident(q, URL, &ident) == QUVI_OK)
  {
    char *formats;
    quvi_ident_getprop(ident, QUVI_IDENT_PROPERTY_FORMATS, &formats);
    puts(formats);
    quvi_supported_ident_close(&ident);
  }
quvi_close(&q);

quvi_supported_ident_close

void quvi_supported_ident_close(quvi_ident_t *handle)

Releases a previously allocated ident handle.

Parameters

identIdent handle

See Also

quvi_supported_ident

quvi_ident_getprop

QUVIcode quvi_ident_getprop(quvi_ident_t ident,
QUVIidentProperty property,
 ...)

Returns an ident property.

Parameters

identIdent handle
propertyProperty ID
...Parameters

Returns

Non-zero value if an error occurred.

See Also

quvi_supported_ident

quvi_next_supported_website

QUVIcode quvi_next_supported_website(quvi_t session,
char **domain,
char **formats)

Returns the next supported website.

Parameters

sessionSession handle
domainNull-terminated string containing the domain (receives)
formatsNull-terminated (static) string containing formats (receives)

Returns

Non-zero value if an error occurred or QUVI_LAST, otherwise QUVI_OK.

quvi_strerror

char *quvi_strerror(quvi_t session,
QUVIcode code)

Returns a corresponding error message to the return code.

Parameters

sessionSession handle
codeReturn code

Returns

A null-terminated string.  Do not attempt to quvi_free it.

quvi_version

char *quvi_version(QUVIversion id)

Returns a quvi version string.

Parameters

idVersion ID

Returns

A null-terminated string.  Do not attempt to quvi_free it.

quvi_free

void quvi_free(void *pointer)

Frees allocated memory.

Parameters

pointerPointer to data
QUVIcode quvi_init(quvi_t *session)
Creates a new session.
void quvi_close(quvi_t *session)
Closes a previously started session.
QUVIcode quvi_setopt(quvi_t session,
QUVIoption option,
 ...)
Sets a session option.
QUVIcode quvi_getinfo(quvi_t session,
QUVIinfo info,
 ...)
Returns session info.
QUVIcode quvi_parse(quvi_t session,
char *url,
quvi_media_t *media)
Parses an URL.
void quvi_parse_close(quvi_media_t *media)
Releases a previously allocated media handle.
QUVIcode quvi_getprop(quvi_media_t media,
QUVIproperty property,
 ...)
Returns a media property.
QUVIcode quvi_query_formats(quvi_t session,
char *url,
char **formats)
Queries available formats to the URL.
QUVIcode quvi_next_media_url(quvi_media_t media)
Iterates the media stream URLs.
QUVIcode quvi_supported(quvi_t session,
char *url)
Checks whether library supports the URL.
QUVIcode quvi_supported_ident(quvi_t session,
char *url,
quvi_ident_t *ident)
Otherwise identical to quvi_supported but returns the `ident’ data.
void quvi_supported_ident_close(quvi_ident_t *handle)
Releases a previously allocated ident handle.
QUVIcode quvi_ident_getprop(quvi_ident_t ident,
QUVIidentProperty property,
 ...)
Returns an ident property.
QUVIcode quvi_next_supported_website(quvi_t session,
char **domain,
char **formats)
Returns the next supported website.
char *quvi_strerror(quvi_t session,
QUVIcode code)
Returns a corresponding error message to the return code.
char *quvi_version(QUVIversion id)
Returns a quvi version string.
void quvi_free(void *pointer)
Frees allocated memory.
Do not attempt to resolve URLs to new location
Close