10
10
<http://www.lua.org/pil/> is a good place to start.
16
See quvi/ subdir for additional scripts that can be used in your
17
scripts. You can find plenty of examples in the website scripts.
19
You may need to unescape URLs from time to time. The "quvi" object
20
(described below) previously contained a function `quvi.unescape' which
21
could be used to do this. This function was removed in 0.2.14 and as
22
of 0.2.14 you can do the following in your scripts instead:
24
local U = require 'quvi/util'
25
local s = U.unescape(url)
13
28
2. Structure of an quvi website script
14
29
======================================
21
2.1. function ident (page_url)
36
2.1. function ident (self)
22
37
------------------------------
24
39
quvi calls this function to check if the script can handle
25
40
the user specified video page URL.
44
- page_url (string) -- User specified video page URL
45
- script_dir (string) -- Path to the directory containing this script
31
* A table containing the following keys
34
- This string is used to match page URL to domain
35
- Returned to an application with quvi_next_supported_website
36
- The string must cover any TLDs and additional domain names
37
- e.g. "youtube.com", "video.google."
40
- An "array" of the supported video format IDs, e.g. "default|best|hq|hd"
41
- All scripts should at least define "default" in this string
42
- Should include "best" if there are more than just "default" ID
45
- Used to check whether the script can handle the user specified URL
48
2.2. function parse (video)
48
* A table containing the following details
51
- Identifies the script, essentially a pattern
52
- Used to match the user specified video page URL
53
- Should cover any additional TLDs and website domain names
54
- Examples: youtube.com, video.google.
57
- Array of available video format IDs (e.g. "default|best|hq|hd")
58
- Specify at least 'default' in this
59
- Append 'best' to the list only if there are more than one format
60
IDs and the script contains an algorithm for this purpose
63
- Bit pattern defining which categories this script belongs to
64
- See quvi/const.lua for the available category bits (e.g. proto_*)
65
- You can also use bit_or of quvi/bit.lua for multi-categorization
66
- Most scripts usually set this to proto_http
69
- Whether this script can handle the user specified video page URL
72
2.2. function parse (self)
49
73
---------------------------
51
75
quvi calls this function to fetch and parse the user specified URL.
52
76
This function looks typically very different for each website. Compare
53
77
buzzhumor.lua and youtube.lua for an example of this.
55
The "parse" function is expected set/update the following video details:
79
The "parse" function is expected set the following details:
59
83
* url (array of strings)
60
* redirect (string) [see notes below]
62
Each of these belong to the `video' table passed to the function
63
as a parameter. e.g. video.host_id = 'youtube' or video.id = '1234'
84
* redirect_url (string) [see notes below]
86
Optional details (set if available):
87
* thumbnail_url (string)
90
Each of these belong to the `self' table passed to the function
91
as a parameter. e.g. self.host_id = 'youtube' or self.id = '1234'
66
94
* quvi sets the following table keys before it runs the script
67
- page_url (string) -- user specified URL
68
- requested_format (string) -- user requested video format ID
95
- page_url (string) -- User specified video page URL
96
- requested_format (string) -- User requested video format ID
97
- script_dir (string) -- Path to the directory containing this script
71
* The updated `video' table
100
* The updated `self' table
74
* "redirect", special field, if set (default:empty):
75
- Drop user specified URL and follow to the redirect URL instead
76
- This replaces the original user defined URL (set by quvi_parse)
103
* "redirect_url", special field, if set (default:empty):
104
- Follow to a new location (of redirect_url)
105
- Replaces the original user defined "page_url" (set by quvi_parse)
77
106
- See academicearth.lua script for an example