| 1 |
<!-- This template is based on the YouTube site script. You will need to be familiar |
| 2 |
-- with regular expressions in order to understand what is happening here. |
| 3 |
--> |
| 4 |
<VideoSite> |
| 5 |
<name>YouTube</name> |
| 6 |
<version>1.0</version> |
| 7 |
<decoders> |
| 8 |
<decoder>avconv-flv_audio-in</decoder> |
| 9 |
</decoders> |
| 10 |
|
| 11 |
<script type="text/javascript"> |
| 12 |
<![CDATA[ |
| 13 |
function canHandleURL(URL) { |
| 14 |
/* This function simply returns true or false depending on |
| 15 |
* whether it thinks it can handle the given URL or not. |
| 16 |
*/ |
| 17 |
if (URL.toLowerCase().match(/http:\/\/www.youtube.com\/watch\?v=.*/)) return true; |
| 18 |
else return false; |
| 19 |
} |
| 20 |
|
| 21 |
function getVideoURL(html) { |
| 22 |
/* This function returns the URL of the actual FLV video file. It is relatively straight |
| 23 |
* forward for YouTube, but for some other sites you will need to do much more here. |
| 24 |
* |
| 25 |
* For example, many site store the actual video URL in an intermediate file that has to be |
| 26 |
* downloaded first. Please have a look at the other site scripts for examples on this. |
| 27 |
*/ |
| 28 |
return html.match(/"url_encoded_fmt_stream_map": ".*?url=(.*?)\\u0026.*?webm.*?\\u0026sig=(.*?)\\u0026.*?,/), unescape(RegExp.$1) + "&signature=" + RegExp.$2; |
| 29 |
} |
| 30 |
|
| 31 |
function queryMetadata(html) { |
| 32 |
/* You need to create and fill a Metadata object here. |
| 33 |
* |
| 34 |
* You should use regular expressions to extract the metadata from the HTML or a linked resource file. |
| 35 |
* For example, for YouTube the description is specified as <p id="eow-description">[description]</p> and thus |
| 36 |
* extracted using the regular expression {/<p id="eow-description"\s*>((?:.|\n|\r)*?)<\/p>/} below. |
| 37 |
* |
| 38 |
* Please have a look at the other site scripts for further examples. |
| 39 |
*/ |
| 40 |
var metadata = new Metadata(); |
| 41 |
|
| 42 |
metadata.title = (html.match(/<meta name="title" content="(.*?)">/) ? RegExp.$1 : null); |
| 43 |
metadata.description = (html.match(/<p id="eow-description"\s*>((?:.|\n|\r)*?)<\/p>/) ? RegExp.$1 : null); |
| 44 |
|
| 45 |
metadata.date = (html.match(/<span id="eow-date" class="watch-video-date"\s*>\s*(.*?)\s*<\/span>/) ? RegExp.$1 : null); |
| 46 |
metadata.thumbnail = (html.match(/<meta property="og:image" content="(.*?)"\s*\/?>/) ? RegExp.$1 : null); |
| 47 |
|
| 48 |
metadata.uploader = (html.match(/<a (?:.|\n|\r)*? class=".*? yt-user-name author" rel="author"(?:.|\n|\r)*?>\s*(.*?)\s*<\/a>/) ? RegExp.$1 : null); |
| 49 |
|
| 50 |
return metadata; |
| 51 |
} |
| 52 |
]]> |
| 53 |
</script> |
| 54 |
</VideoSite> |