Blame src/api/doxy/parse_subtitle.dp

Packit 3ff1e7
/** @page parse_subtitle Parsing subtitle properties
Packit 3ff1e7
Packit 3ff1e7
libquvi provides basic support for parsing subtitle properties and
Packit 3ff1e7
exporting the available subtitles into a specified format, e.g. SubRip.
Packit 3ff1e7
Packit 3ff1e7
@note Not all media have subtitles -- with libquvi the application must
Packit 3ff1e7
query for the available subtitles per media as shown below
Packit 3ff1e7
Packit 3ff1e7
The available @ref sub_script collection determines which websites are
Packit 3ff1e7
supported by the library. Each script will return all available @ref
Packit 3ff1e7
sub_type and @ref sub_lang.
Packit 3ff1e7
Packit 3ff1e7
@code
Packit 3ff1e7
quvi_subtitle_t qsub = quvi_subtitle_new(q, URL);
Packit 3ff1e7
abort_if_error();
Packit 3ff1e7
{
Packit 3ff1e7
  quvi_subtitle_type_t qst;
Packit 3ff1e7
Packit 3ff1e7
  /* for each subtitle type */
Packit 3ff1e7
  while (  (qst = quvi_subtitle_type_next(qsub)) != NULL)
Packit 3ff1e7
    {
Packit 3ff1e7
      quvi_subtitle_lang_t qsl;
Packit 3ff1e7
      double d;
Packit 3ff1e7
Packit 3ff1e7
      quvi_subtitle_type_get(qst, QUVI_SUBTITLE_TYPE_PROPERTY_TYPE, &d);
Packit 3ff1e7
Packit 3ff1e7
      switch (d)
Packit 3ff1e7
      {
Packit 3ff1e7
      case QUVI_SUBTITLE_TYPE_TTS:
Packit 3ff1e7
        puts("type: tts");
Packit 3ff1e7
        break;
Packit 3ff1e7
      case QUVI_SUBTITLE_TYPE_CC:
Packit 3ff1e7
        puts("type: cc");
Packit 3ff1e7
      default:
Packit 3ff1e7
        break;
Packit 3ff1e7
      }
Packit 3ff1e7
Packit 3ff1e7
      /* for each subtitle language (of the type). */
Packit 3ff1e7
      while ( (qsl = quvi_subtitle_lang_next(qst)) != NULL)
Packit 3ff1e7
        {
Packit 3ff1e7
          char *s;
Packit 3ff1e7
          quvi_subtitle_lang_get(qsl, QUVI_SUBTITLE_LANG_PROPERTY_ID, &s);
Packit 3ff1e7
          puts(s);
Packit 3ff1e7
        }
Packit 3ff1e7
    }
Packit 3ff1e7
}
Packit 3ff1e7
quvi_subtitle_free(qsub);
Packit 3ff1e7
@endcode
Packit 3ff1e7
Packit 3ff1e7
@sa QuviSubtitleTypeProperty
Packit 3ff1e7
@sa QuviSubtitleLangProperty
Packit 3ff1e7
Packit 3ff1e7
@section sub_select Selecting a language
Packit 3ff1e7
Packit 3ff1e7
When the library returns >1 languages, you can access them using the
Packit 3ff1e7
@ref quvi_subtitle_type_next, @ref quvi_subtitle_lang_next and
Packit 3ff1e7
@ref quvi_subtitle_lang_get.  Alternatively, the convenience function
Packit 3ff1e7
@ref quvi_subtitle_select could be used.
Packit 3ff1e7
Packit 3ff1e7
The example below asks the library to return the language ID matching
Packit 3ff1e7
the "cc_en" pattern.
Packit 3ff1e7
Packit 3ff1e7
@code
Packit 3ff1e7
quvi_subtitle_t qsub = quvi_subtitle_new(q, URL);
Packit 3ff1e7
abort_if_error();
Packit 3ff1e7
{
Packit 3ff1e7
  quvi_subtitle_lang_t qsl = quvi_subtitle_select(qsub, "cc_en");
Packit 3ff1e7
  abort_if_error(); /* Always check quvi_ok return value. */
Packit 3ff1e7
}
Packit 3ff1e7
@endcode
Packit 3ff1e7
Packit 3ff1e7
Similarly to @ref quvi_media_stream_select, @ref quvi_subtitle_select
Packit 3ff1e7
takes a comma-separated list of regular expression patterns, so
Packit 3ff1e7
the following is perfectly OK:
Packit 3ff1e7
Packit 3ff1e7
@code
Packit 3ff1e7
qsl = quvi_subtitle_select(qsub, "tts_e?,cc_a?,croak");
Packit 3ff1e7
@endcode
Packit 3ff1e7
Packit 3ff1e7
If neither "tts_e?" or "cc_a?" matched any of the available subtitles,
Packit 3ff1e7
the library would exit with an error (croak). By default, the library
Packit 3ff1e7
will return the default (first available type and the first available
Packit 3ff1e7
language).
Packit 3ff1e7
Packit 3ff1e7
@section sub_export Exporting subtitle languages
Packit 3ff1e7
Packit 3ff1e7
libquvi provides basic facility for converting the subtitles from their
Packit 3ff1e7
internal subtitle format that the website uses to a more standard-like
Packit 3ff1e7
format, e.g. SubRip, the media players support.
Packit 3ff1e7
Packit 3ff1e7
@code
Packit 3ff1e7
quvi_subtitle_export_t qse = quvi_subtitle_export_new(qsl, "srt");
Packit 3ff1e7
abort_if_error();
Packit 3ff1e7
puts(quvi_subtitle_export_data(qse));
Packit 3ff1e7
quvi_subtitle_export_free(qse);
Packit 3ff1e7
@endcode
Packit 3ff1e7
Packit 3ff1e7
The available @ref subex_script collection determines which export
Packit 3ff1e7
formats are supported by the library. If your application needs to
Packit 3ff1e7
know the available export formats, use the @ref script interface for
Packit 3ff1e7
querying the @ref QUVI_SCRIPT_PROPERTY_EXPORT_FORMAT.
Packit 3ff1e7
Packit 3ff1e7
@sa http://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format
Packit 3ff1e7
@sa @ref acc_script_prop
Packit 3ff1e7
*/