Update gitignore
[www-quvi.git] / Quvi.i
blobc973bb3aadb2355530fd8d806aa1696b47c2884b
1 /* WWW::Quvi
2 * Copyright (C) 2010,2011 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 %module "WWW::Quvi"
22 %include "std_string.i"
23 %include "exception.i"
24 %include "typemaps.i"
27 #include "Quvi.h"
30 %inline %{
32 char *_VERSION = VERSION;
34 typedef enum {
35 libquviVersion = QUVI_VERSION,
36 libquviVersionLong = QUVI_VERSION_LONG,
37 ModuleVersion
38 } quviVersion;
40 static char* version (quviVersion n=ModuleVersion) {
41 if (n == ModuleVersion) return _VERSION;
42 return quvi_version ((QUVIversion)n);
46 * A manual copy of QUVIcode. If there's a better way to do this,
47 * I'd like to know it too. This will need to be maintained manually
48 * if there are any changes to the QUVIcode enum list in quvi.h file.
50 * The reason we don't simply "%include <quvi/quvi.h>" and
51 * get the constants is because that would clutter the wrapper.
53 * We have renamed the constants to avoid any conflicts with those
54 * defined in <quvi/quvi.h> which is included by the wrapper.
56 typedef enum {
57 OK = 0x00,
58 Mem,
59 BadHandle,
60 InvArg,
61 CurlInit,
62 Last,
63 AbortedByCallback,
64 LuaInit,
65 NoLuaWebsite,
66 NoLuaUtil,
67 PcreError= 0x40, /* QUVI_PCRE */
68 NoSupport,
69 CurlError, /* QUVI_CURL */
70 IconvError, /* QUVI_ICONV */
71 LuaError, /* QUVI_LUA */
72 } quviCode;
74 typedef enum {
75 ProtoHttp = 0x1,
76 ProtoMms = 0x2,
77 ProtoRtsp = 0x4,
78 ProtoRtmp = 0x8,
79 ProtoAll = (ProtoHttp|ProtoMms|ProtoRtsp|ProtoRtmp)
80 } quviCategory;
84 class Options {
85 public:
86 Options ();
87 public:
88 std::string user_agent;
89 std::string http_proxy;
90 bool verbose_libcurl;
91 std::string format;
92 bool verify;
93 bool shortened;
94 long category;
97 class Link {
98 public:
99 Link ();
100 public:
101 %immutable;
102 std::string content_type;
103 std::string file_suffix;
104 double length_bytes;
105 std::string url;
108 class Video {
109 public:
110 Video ();
111 public:
112 %immutable;
113 std::string title;
114 std::string host;
115 std::string url;
116 std::string id;
117 Link link;
118 bool ok;
121 /* Query::_init throws std::runtime_error if quvi_init fails. */
122 %exception {
124 { $action }
125 catch (const std::runtime_error& e)
126 { SWIG_exception (SWIG_RuntimeError, e.what ()); }
129 %apply std::string &OUTPUT { std::string &domain, std::string &formats };
131 class Query {
132 public:
133 Query ();
134 virtual ~Query ();
135 public:
136 Video parse (const std::string&, const Options&);
137 int next_website (std::string &domain, std::string &formats);
138 public:
139 %immutable;
140 std::string last_error;
141 long quvi_code;
142 long resp_code;
145 %exception;