libquvi
 All Files Functions Typedefs Enumerations Enumerator Macros Groups Pages
Parsing subtitle properties

libquvi provides basic support for parsing subtitle properties and exporting the available subtitles into a specified format, e.g. SubRip.

Note
Not all media have subtitles – with libquvi the application must query for the available subtitles per media as shown below

The available Subtitle script collection determines which websites are supported by the library. Each script will return all available Subtitle type and Subtitle language.

abort_if_error();
{
/* for each subtitle type */
while ( (qst = quvi_subtitle_type_next(qsub)) != NULL)
{
double d;
quvi_subtitle_type_get(qst, QUVI_SUBTITLE_TYPE_PROPERTY_TYPE, &d);
switch (d)
{
case QUVI_SUBTITLE_TYPE_TTS:
puts("type: tts");
break;
case QUVI_SUBTITLE_TYPE_CC:
puts("type: cc");
default:
break;
}
/* for each subtitle language (of the type). */
while ( (qsl = quvi_subtitle_lang_next(qst)) != NULL)
{
char *s;
quvi_subtitle_lang_get(qsl, QUVI_SUBTITLE_LANG_PROPERTY_ID, &s);
puts(s);
}
}
}
See Also
QuviSubtitleTypeProperty
QuviSubtitleLangProperty

Selecting a language

When the library returns >1 languages, you can access them using the quvi_subtitle_type_next, quvi_subtitle_lang_next and quvi_subtitle_lang_get. Alternatively, the convenience function quvi_subtitle_select could be used.

The example below asks the library to return the language ID matching the "cc_en" pattern.

abort_if_error();
{
abort_if_error(); /* Always check quvi_ok return value. */
}

Similarly to quvi_media_stream_select, quvi_subtitle_select takes a comma-separated list of regular expression patterns, so the following is perfectly OK:

qsl = quvi_subtitle_select(qsub, "tts_e?,cc_a?,croak");

If neither "tts_e?" or "cc_a?" matched any of the available subtitles, the library would exit with an error (croak). By default, the library will return the default (first available type and the first available language).

Exporting subtitle languages

libquvi provides basic facility for converting the subtitles from their internal subtitle format that the website uses to a more standard-like format, e.g. SubRip, the media players support.

The available Subtitle export script collection determines which export formats are supported by the library. If your application needs to know the available export formats, use the Scripts interface for querying the QUVI_SCRIPT_PROPERTY_EXPORT_FORMAT.

See Also
http://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format
Accessing script properties