~ubuntu-branches/ubuntu/saucy/libquvi/saucy-proposed

« back to all changes in this revision

Viewing changes to share/lua/website/README

  • Committer: Bazaar Package Importer
  • Author(s): Alejandro Garrido Mota
  • Date: 2011-04-25 01:07:41 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110425010741-nalzd12y180qs082
Tags: 0.2.15-1
* New upstream release (Closes: #622253). 
* Update d/watch to sf.net
* Update homepage field to quvi.sourceforge.net (Closes: #615554) 
* d/rules: Add dh_auto_test before NO_INTERNET=1 in override_dh_auto_test 
* Update Standards-Version field to 3.9.2 
* Add symbol (d/libquvi0.symbols) file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
<http://www.lua.org/pil/> is a good place to start.
11
11
 
12
12
 
 
13
1.1. Notes
 
14
----------
 
15
 
 
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.
 
18
 
 
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:
 
23
 
 
24
  local U = require 'quvi/util'
 
25
  local s = U.unescape(url)
 
26
 
 
27
 
13
28
2. Structure of an quvi website script
14
29
======================================
15
30
 
18
33
  * parse
19
34
 
20
35
 
21
 
2.1. function ident (page_url)
 
36
2.1. function ident (self)
22
37
------------------------------
23
38
 
24
39
quvi calls this function to check if the script can handle
25
40
the user specified video page URL.
26
41
 
27
42
Parameters:
28
 
  * page_url (string)
 
43
  * self (table)
 
44
    - page_url (string)   -- User specified video page URL
 
45
    - script_dir (string) -- Path to the directory containing this script
29
46
 
30
47
Returns:
31
 
  * A table containing the following keys
32
 
 
33
 
    - domain (string)
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."
38
 
 
39
 
    - formats (string)
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
43
 
 
44
 
    - handles (boolean)
45
 
      - Used to check whether the script can handle the user specified URL
46
 
 
47
 
 
48
 
2.2. function parse (video)
 
48
  * A table containing the following details
 
49
 
 
50
    * domain (string)
 
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.
 
55
 
 
56
    * formats (string)
 
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
 
61
 
 
62
    * categories (number)
 
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
 
67
 
 
68
    * handles (boolean)
 
69
      - Whether this script can handle the user specified video page URL
 
70
 
 
71
 
 
72
2.2. function parse (self)
49
73
---------------------------
50
74
 
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.
54
78
 
55
 
The "parse" function is expected set/update the following video details:
 
79
The "parse" function is expected set the following details:
56
80
  * host_id (string)
57
81
  * title (string)
58
82
  * id (string)
59
83
  * url (array of strings)
60
 
  * redirect (string) [see notes below]
61
 
 
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]
 
85
 
 
86
Optional details (set if available):
 
87
  * thumbnail_url (string)
 
88
  * duration (numeric)
 
89
 
 
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'
64
92
 
65
93
Parameters:
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
69
98
 
70
99
Returns:
71
 
  * The updated `video' table
 
100
  * The updated `self' table
72
101
 
73
102
Notes:
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
78
107
 
79
108
 
103
132
 
104
133
Returns:
105
134
  * Fetched data
106
 
 
107
 
 
108
 
3.2. Function: string quvi.unescape (string)
109
 
--------------------------------------------
110
 
 
111
 
Returns an unescaped `string'.
112
 
 
113
 
Parameters:
114
 
  * string
115
 
 
116
 
Returns:
117
 
  * Unescaped string