Wrap QUVIPROP_STARTTIME
[www-quvi.git] / lib / WWW / Quvi.pod
blobe7d6e0edf7769455fe818868273e97ca84c4c5b7
1 =head1 NAME
3 WWW::Quvi - Perl extension interface for libquvi
5 =head1 SYNOPSIS
7     use WWW::Quvi;
8     my $opts  = new WWW::Quvi::Options;
9     my $query = new WWW::Quvi::Query;
10     my $video = $query->parse ($url, $opts);
11     if ($video->{ok}) {
12         # ...
13     }
14     else {
15         die "libquvi: error: $query->{last_error}";
16     }
18 =head1 DESCRIPTION
20 WWW::Quvi provides a Perl interface to libquvi, a library for parsing video
21 download links.
23 =head1 DOCUMENTATION
25 This module provides a Perl interface to libquvi. This documentation
26 contains the Perl specific details and some sample code. The libquvi
27 documentation should be consulted for the API details at
28 L<http://quvi.googlecode.com/>.
30 =head1 WWW::Quvi::version
32 A wrapper function that returns WWW::Quvi version and libquvi version
33 information.
35     use warnings;
36     use strict;
38     print WWW::Quvi::version; # Module version
39     print WWW::Quvi::version (WWW::Quvi::ModuleVersion); # Same as above.
40     print WWW::Quvi::version (WWW::Quvi::libquviVersion);
41     print WWW::Quvi::version (WWW::Quvi::libquviVersionLong);
43 =head1 WWW::Quvi::Options
45 A container hash for the options used with libquvi that would normally
46 (using the C API) be set with C<quvi_setopt(3)>.
48  use warnings;
49  use strict;
51  use WWW::Quvi;
53  my $opts = new WWW::Quvi::Options;
55  $opts->{user_agent}      = 'Foo/1.0';              # Default: ""
56  $opts->{http_proxy}      = 'http://foo:1234';      # Default: ""
57  $opts->{format}          = 'hd';                   # Default: "default"
58  $opts->{verify}          = 0;                      # Default: 1
59  $opts->{verbose_libcurl} = 1;                      # Default: 0
60  $opts->{shortened}       = 0;                      # Default: 1
61  $opts->{category}        = WWW::Quvi::ProtoAll;    # Default: ProtoHttp
63 =head1 WWW::Quvi::Video
65 A container hash that holds the parsed video details.
67     print "
68         $video->{title}
69         $video->{host}
70         $video->{url}
71         $video->{id}
72         $video->{ok}
73         $video->{start_time}
74     ";
76 =head1 WWW::Quvi::Link
78 A container hash that holds the parsed video link details. A member of
79 the L</WWW::Quvi::Video> hash.
81     print "
82         $video->{link}->{content_type}
83         $video->{link}->{file_suffix}
84         $video->{link}->{length_bytes}
85         $video->{link}->{url}
86     ";
88 =head1 WWW::Quvi::Query
90 Glues the above together.
92     # An Options instance is required.
93     # See WWW::Quvi::Options above for the available keys.
95     my $opts  = new WWW::Quvi::Options;
97     # Initializes libquvi (quvi_init), croaks if that fails.
99     my $query = new WWW::Quvi::Query;
101     # Perform a query.
103     my $url   = "http://www.youtube.com/watch?v=DUM1284TqFc";
104     my $video = $query->parse ($url, $opts);
106     if ($video->{ok}) {
107         # Do whatever with the parsed video details.
108     }
109     else {
110         croak "libquvi: error: $query->{last_error}";
111         # Other things to check:
112         #   * $query->{quvi_code}
113         #   * $query->{resp_code}
114     }
116     # Iterate supported websites:
118     while (1) {
119         my ($done, $domain, $formats) = $query->next_website;
121         last if $done;
123         print "$domain\t$formats\n";
124     }
126     # Check if URL is supported. Make a note of "compressed" URLs, as
127     # this function fails with most of them. Refer to the libquvi C API
128     # for the details.
130     print
131         $query->supported("http://dai.ly") != WWW::Quvi::OK
132         ? $query->{last_error}
133         : "supported";
135 =head1 NOT IMPLEMENTED
137 =over 4
139 =item B<Callbacks>
141 e.g. quvi_callback_status, quvi_callback_write.
143 =item B<Video segments>
145 libquvi supports these for historical reasons only. Each
146 video would have one or more video segments which had to be
147 downloaded separately from different URLs.
149 =back
151 =head1 AUTHOR
153 Toni Gundogdu <legatvs at sign gmail com>
155 =head1 WWW
157 E<lt>http://www-quvi.googlecode.com/E<gt>
159 E<lt>http://repo.or.cz/w/www-quvi.gitE<gt>
161 =cut