5 This directory contains the website scripts quvi uses to parse the media
6 stream URLs. Should the parsing ever break, these are the scripts that
7 should be looked at first.
9 If you are looking to write a new script, see the existing scripts and
10 read the HowtoWriteWebsiteScript (found typically in either
11 $prefix/doc/quvi/ or $top_srcdir/doc).
13 These scripts are written in Lua. If you are new to Lua,
14 <http://www.lua.org/pil/> is a good place to start.
20 Each website script is expected to have the following functions:
21 * ident (identifies the script to the library)
22 * parse (parses the media details and returns them to the library)
24 To access the "utility functions" from your script, e.g.:
25 local U = require 'quvi/util'
26 local s = U.unescape(url)
28 See the 'util.lua' script in the lua/website/quvi/ directory for the
32 table ident(self) [REQUIRED]
33 ----------------------------
35 Identifies the script to the library. The library calls this function to
36 check if the script can handle the user specified URL.
40 - page_url (string) -- User specified page URL
41 - script_dir (string) -- Path to the directory containing this script
43 Returns: table containing the following details:
46 - Identifies the script, this is essentially a pattern, e.g.
47 "video.google." (note the lack of TLD) or "youtube.com"
48 - Should cover any additional TLDs and website domain names
49 - If the script can handle >1 (_different_) websites, put the
50 domain names into an array, each domain name separated by '|',
51 see collegehumor.lua for an example of this
54 - Array of available format IDs (e.g. "default|best|hq|hd")
55 - Contains at least "default"
56 - Add "best" to the list *only if* there are more than one format
57 ("default") IDs and the script contains an algorithm for parsing
58 these additional formats
61 - Bit pattern defining which categories this script belongs to
62 - See quvi/const.lua for the available category bits (e.g. proto_*)
63 - You can also use bit_or of quvi/bit.lua for multi-categorization
64 - Most scripts usually set this to proto_http
67 - Whether this script can handle the user specified page URL
68 - For better results, use:
70 local U = require 'quvi/util'
71 r.handles = U.handles(self.page_url,
72 domain_patterns, path_patterns, query_patterns)
74 See quvi/util.lua for "handles" function.
77 self query_formats(self) [REQUIRED]
78 -----------------------------------
80 Queries the URL for available formats.
84 - page_url (string) -- User specified page URL
87 * self.formats (string) -- Each format string separated by '|'
89 * redirect_url (string, see collegehumor.lua)
92 * Updated `self' table
95 self parse(self) [REQUIRED]
96 ---------------------------
98 Parses the media details.
102 - page_url (string) -- User specified page URL
103 - requested_format (string) -- User requested format ID
109 * url (array of strings)
111 * redirect_url (string, see academicearth.lua)
112 * start_time (string, see youtube.lua)
113 * thumbnail_url (string)
114 * duration (numeric, msec)
117 * Updated `self' table
123 string quvi.fetch(url, options)
124 -------------------------------
126 Fetches data from the specified URL.
129 * url (string) -- URL to fetch
130 * options (table) -- Additional options [OPTIONAL]
131 - fetch_type (string) ("page"|"config"|"playlist") =page
132 - arbitrary_cookie (string) e.g. "foo=1;bar=2"
133 - <http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCOOKIE>
134 - user_agent (string) e.g. "foo/0.1"
140 local data = quvi.fetch(url) -- fetch_type default is "page"
141 local data = quvi.fetch(url, {fetch_type = 'config'})
142 local data = quvi.fetch(url, {arbitrary_cookie = 'foo=1'})
143 local data = quvi.fetch(url, {user_agent = 'foo/1.0'})
146 string quvi.resolve(url)
147 ------------------------
149 Check whether the specified `url' redirects to a new location.
152 * url (string) - URL to be checked
155 * New location or an empty string
158 local n = quvi.resolve('http://is.gd/foobar')
160 print('redirects to', n)