build_url_regex renamed to build_url_regexp
[conkeror.git] / modules / page-modes / dailymotion.js
blob65e7c7a2fb13db900499a5f11c41c6af6e1c7bb0
1 /**
2  * (C) Copyright 2008 Jeremy Maitin-Shepard
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 in_module(null);
10 require("content-buffer.js");
11 require("media.js");
13 function media_scrape_dailymotion(buffer, results) {
14     var text = unescape(buffer.document.documentElement.innerHTML);
15     const reg = /video=([^&]+)&/;
17     const reg2 = /([^\|]*)@@\w+$/;
18     var match = reg.exec(text);
19     var param;
20     if (!match || !(param = match[1]))
21         return;
23     param = unescape(param);
25     match = reg2.exec(param);
26     var path;
27     if (!match || !(path = match[1]))
28         return;
29     let title = get_meta_title(buffer.document);
30     if (title)
31         title = title.replace("Dailymotion : ", "");
32     results.push(load_spec({uri: "http://dailymotion.com" + path,
33                             title: title,
34                             filename_extension: "flv",
35                             source_frame: buffer.top_frame,
36                             mime_type: "video/x-flv"}));
39 define_page_mode("dailymotion-mode",
40     build_url_regexp($domain = /(?:[^\/]*\.)?dailymotion/),
41     function enable (buffer) {
42         media_setup_local_object_classes(buffer);
43     },
44     function disable (buffer) {},
45     $display_name = "Dailymotion");
47 page_mode_activate(dailymotion_mode);
49 media_scrapers.unshift([dailymotion_mode.test, media_scrape_dailymotion]);
51 provide("dailymotion");