Wrap quvi_supported
[www-quvi.git] / lib / WWW / Quvi.pod
blobede011029b7763658ff12715432bc25644f1c415
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     ";
75 =head1 WWW::Quvi::Link
77 A container hash that holds the parsed video link details. A member of
78 the L</WWW::Quvi::Video> hash.
80     print "
81         $video->{link}->{content_type}
82         $video->{link}->{file_suffix}
83         $video->{link}->{length_bytes}
84         $video->{link}->{url}
85     ";
87 =head1 WWW::Quvi::Query
89 Glues the above together.
91     # An Options instance is required.
92     # See WWW::Quvi::Options above for the available keys.
94     my $opts  = new WWW::Quvi::Options;
96     # Initializes libquvi (quvi_init), croaks if that fails.
98     my $query = new WWW::Quvi::Query;
100     # Perform a query.
102     my $url   = "http://www.youtube.com/watch?v=DUM1284TqFc";
103     my $video = $query->parse ($url, $opts);
105     if ($video->{ok}) {
106         # Do whatever with the parsed video details.
107     }
108     else {
109         croak "libquvi: error: $query->{last_error}";
110         # Other things to check:
111         #   * $query->{quvi_code}
112         #   * $query->{resp_code}
113     }
115     # Iterate supported websites:
117     while (1) {
118         my ($done, $domain, $formats) = $query->next_website;
120         last if $done;
122         print "$domain\t$formats\n";
123     }
125     # Check if URL is supported. Make a note of "compressed" URLs, as
126     # this function fails with most of them. Refer to the libquvi C API
127     # for the details.
129     print
130         $query->supported("http://dai.ly") != WWW::Quvi::OK
131         ? "no support"
132         : "supported";
134 =head1 NOT IMPLEMENTED
136 =over 4
138 =item B<Callbacks>
140 e.g. quvi_callback_status, quvi_callback_write.
142 =item B<Video segments>
144 libquvi supports these for historical reasons only. Each
145 video would have one or more video segments which had to be
146 downloaded separately from different URLs.
148 =back
150 =head1 AUTHOR
152 Toni Gundogdu <legatvs at sign gmail com>
154 =head1 WWW
156 E<lt>http://www-quvi.googlecode.com/E<gt>
158 E<lt>http://repo.or.cz/w/www-quvi.gitE<gt>
160 =cut