quvi/const: Add quvi error codes
[libquvi-scripts.git] / share / common / quvi / const.lua
blob6153b198c939e732b4bc07f23e356b0d21cbd5b1
1 -- libquvi-scripts
2 -- Copyright (C) 2010-2013 Toni Gundogdu <legatvs@gmail.com>
3 --
4 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
5 --
6 -- This program is free software: you can redistribute it and/or
7 -- modify it under the terms of the GNU Affero General Public
8 -- License as published by the Free Software Foundation, either
9 -- version 3 of the License, or (at your option) any later version.
11 -- This program is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 -- GNU Affero General Public License for more details.
16 -- You should have received a copy of the GNU Affero General
17 -- Public License along with this program. If not, see
18 -- <http://www.gnu.org/licenses/>.
21 local M = {}
24 -- (q)uvi (err)or codes
26 -- static
27 M.qerr_ok = 0x00
28 M.qerr_callback_aborted = 0x01
29 M.qerr_no_subtitle_export_scripts = 0x02
30 M.qerr_no_subtitle_scripts = 0x03
31 M.qerr_no_playlist_scripts = 0x04
32 M.qerr_no_media_scripts = 0x05
33 M.qerr_no_scan_scripts = 0x06
34 M.qerr_no_util_scripts = 0x07
35 M.qerr_keyword_croak = 0x08
36 M.qerr_invalid_arg = 0x09
37 M.qerr_proxy_init = 0x0a
38 M.qerr_curl_init = 0x0b
39 M.qerr_lua_init = 0x0c
40 -- dynamically created
41 M.qerr_no_support = 0x40
42 M.qerr_callback = 0x41
43 -- an error occurred in a callback, e.g. a network error.
44 M.qerr_script = 0x42
47 -- (q)uvi (o)bject (o)ption
49 M.qoo_croak_if_error = 0x01
50 -- fetch
51 M.qoo_fetch_from_charset = 0x20
52 -- http
53 M.qoo_http_user_agent = 0x40
54 M.qoo_http_cookie = 0x41
57 -- subtitle
60 -- (s)ubtitle (t)ype
61 M.st_tts = 0x1 -- text-to-speech
62 M.st_cc = 0x2 -- closed caption
64 -- (s)ubtitle (i)nternal (f)ormat
65 M.sif_tt = 0x1 -- timed text
68 -- quvi.fetch
71 -- (q)uvi.(f)etch (o)ption
72 M.qfo_from_charset = 0x0 -- Convert (to UTF-8) from this charset
73 M.qfo_user_agent = 0x1 -- Set user-agent string value
74 M.qfo_cookie = 0x2 -- Set an arbitrary cookie
75 M.qfo_type = 0x3 -- Fetch type (see qft_*)
77 -- (q)uvi.(f)etch (t)ype
78 M.qft_playlist = 0x0
79 M.qft_config = 0x1
80 M.qft_url = 0x2 -- default
82 --[[
84 qfo_from_charset
85 ----------------
86 Instructs the library to convert from this charset to UTF-8. Using this
87 option may be required with the websites that use a specific (non-UTF8)
88 encoding.
90 The purpose of this option is to make sure that the data is encoded to
91 unicode (UTF-8) before any of it is parsed and returned to the
92 application using libquvi.
94 By default, libquvi converts the data which is in the encoding used for
95 the strings by the C runtime in the current locale into UTF-8. IF this
96 fails, and the 'from charset' option is set, the library will then try
97 to convert to UTF-8 using the 'from charset' value.
99 qfo_cookie
100 ----------
101 When set, the arbitrary cookie will be used with the quvi.fetch .
102 The cookies are handled by libcurl, look up the CURLOPT_COOKIE
103 description for details. If you must define >1 cookies, use the
104 following format: "foo=1; bar=2;" .
106 EXAMPLES
107 --------
108 local C = require 'quvi/const'
110 local p = quvi.fetch(URL, {[C.qfo_cookie] = 'foo=1'})
111 local p = quvi.fetch(URL, {[C.qfo_type] = C.qft_config})
113 local t = {
114 [C.qfo_cookie] = 'foo=1; bar=2;',
115 [C.qfo_type] = C.qft_config
117 local p = quvi.fetch(URL, t)
119 ]]--
121 return M
123 -- vim: set ts=2 sw=2 tw=72 expandtab: