[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [129] Changes for tasks #11216.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [129] Changes for tasks #11216. |
Date: |
Wed, 13 Jul 2011 09:26:08 +0000 |
Revision: 129
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=129
Author: valkov
Date: 2011-07-13 09:26:07 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule to extract object data from scripts. Sites
that need the change use it.
Ticket Links:
------------
http://savannah.gnu.org/task/?11216
Modified Paths:
--------------
branches/task-11216/src/lm_extract_js_scripts.js
branches/task-11216/src/lm_site_theonion.js
branches/task-11216/src/lm_site_vimeo.js
branches/task-11216/src/lm_site_youtube.js
branches/task-11216/src/lm_sites.js
Modified: branches/task-11216/src/lm_extract_js_scripts.js
===================================================================
--- branches/task-11216/src/lm_extract_js_scripts.js 2011-07-12 19:22:47 UTC
(rev 128)
+++ branches/task-11216/src/lm_extract_js_scripts.js 2011-07-13 09:26:07 UTC
(rev 129)
@@ -73,44 +73,27 @@
continue;
}
- if (/theonion\.com/i.test(window.location.hostname))
- {
- object_data = this.extract_object_from_script_theonion();
+ var self = this;
+ var val = this.call_site_function_at_position.apply(self,[
+ "extract_object_from_script",
+ window.location.hostname]);
- if (!object_data)
- {
- // No other method of extraction is useful. Skip to
- // next script.
- continue;
- }
- }
- if (/youtube\.com/i.test(window.location.hostname) ||
- (/youtube-nocookie\.com/i.test(window.location.hostname)))
+ if (this.sites[window.location.hostname] && !val)
{
- object_data =
- this.extract_object_from_script_youtube();
+ // Site specific code is used but no results were
+ // returned. Can't extract object information. General
+ // purpose extraction might not worк, so it is useless.
+ this.log("LinternaMagica.extract_objects_from_scripts:\n"+
+ "Site specific code did not return object data. Skipping"+
+ " general purpose extraction",6);
- // Fix bloating in FF (mainly). Optimizes script
- // processing. No need to check the other swf constructors
- // in YouTube.
- if (!object_data)
- {
- continue;
- }
+ continue;
}
- if (/vimeo\.com/i.test(window.location.hostname))
+ if (val && typeof(val) != "boolean")
{
- object_data =
- this.extract_object_from_script_vimeo();
-
- // Optimizes script processing. No need to check the other
- // swf constructors in Vimeo.
- if (!object_data)
- {
- continue;
- }
+ object_data = val;
}
if (!object_data)
Modified: branches/task-11216/src/lm_site_theonion.js
===================================================================
--- branches/task-11216/src/lm_site_theonion.js 2011-07-12 19:22:47 UTC (rev
128)
+++ branches/task-11216/src/lm_site_theonion.js 2011-07-13 09:26:07 UTC (rev
129)
@@ -28,8 +28,14 @@
// Support for The Onion dot com
+LinternaMagica.prototype.sites["theonion.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.theonion.com"] = "theonion.com";
+
// Extracts data for the flash object in The Onion dot com from a script
-LinternaMagica.prototype.extract_object_from_script_theonion = function()
+LinternaMagica.prototype.sites["theonion.com"].extract_object_from_script =
+function()
{
var player_container = document.getElementById("player_container");
@@ -141,11 +147,6 @@
}
}
-LinternaMagica.prototype.sites["theonion.com"] = new Object();
-
-// Reference
-LinternaMagica.prototype.sites["www.theonion.com"] = "theonion.com";
-
LinternaMagica.prototype.sites["theonion.com"].flash_plugin_installed =
function()
{
Modified: branches/task-11216/src/lm_site_vimeo.js
===================================================================
--- branches/task-11216/src/lm_site_vimeo.js 2011-07-12 19:22:47 UTC (rev
128)
+++ branches/task-11216/src/lm_site_vimeo.js 2011-07-13 09:26:07 UTC (rev
129)
@@ -27,6 +27,11 @@
// END OF LICENSE HEADER
+LinternaMagica.prototype.sites["vimeo.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.vimeo.com"] = "vimeo.com";
+
// Detect vimeo browser upgrade warning (no flash & h264) .This is
// called withing setInterval. It is needed because when the elements
// with the warning are inserted all our data that has been added
@@ -83,7 +88,7 @@
// Extract object data in Vimeo. This makes Firefox and forks to work
// without plugin and without HTML5 (missing H264)
-LinternaMagica.prototype.extract_object_from_script_vimeo = function()
+LinternaMagica.prototype.sites["vimeo.com"].extract_object_from_script =
function()
{
var player_element_re = new RegExp(
"player[0-9]+_[0-9]+_element\\\s*=\\\s*"+
Modified: branches/task-11216/src/lm_site_youtube.js
===================================================================
--- branches/task-11216/src/lm_site_youtube.js 2011-07-12 19:22:47 UTC (rev
128)
+++ branches/task-11216/src/lm_site_youtube.js 2011-07-13 09:26:07 UTC (rev
129)
@@ -167,9 +167,80 @@
}
}
+// Extract links data for youtube from fmt_url_map
+LinternaMagica.prototype.extract_youtube_fmt_url_map = function(data)
+{
+ var fmt_re = new RegExp (
+ "(\\\"|\\\'|\\\&)fmt_url_map"+
+ "(\\\"|\\\')*(\\\=|\\\:|,)\\\s*(\\\"|\\\')*"+
+ "([a-zA-Z0-9\\\-\\\_\\\%\\\=\\\/,\\\\\.\|:=&%\?]+)");
+ var fmt = data.match(fmt_re);
+
+ if (fmt)
+ {
+
+ // For debug level 1
+ this.log("LinternaMagica.extract_youtube_fmt_url_map:\n"+
+ "Extracted fmt_url_map.",1);
+
+ // Hash with keys fmt_ids and values video URLs
+ var map = new Object();
+
+ // There was unescape here but it broke the split by ,. How it
+ // worked it is not clear. Maybe YT changed something.
+ fmt = fmt[fmt.length-1].replace(/\\\//g, "/");
+
+ fmt = fmt.split(/,/);
+
+ for (var url=0; url<fmt.length; url++)
+ {
+ // fmt_id|link
+ var m = fmt[url].split(/\|/);
+ map[m[0]] = m[1];
+ }
+
+ return map;
+ }
+ else
+ {
+ this.log("LinternaMagica.extract_youtube_fmt_url_map:\n"+
+ "No fmt_url_map parameter found. ",1);
+ }
+
+ return null;
+}
+
+LinternaMagica.prototype.sites["youtube.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.youtube.com"] = "youtube.com";
+LinternaMagica.prototype.sites["www.youtube-nocookie.com"] = "youtube.com";
+LinternaMagica.prototype.sites["youtube-nocookie.com"] = "youtube.com";
+
+LinternaMagica.prototype.sites["youtube.com"].set_cookies_domain =
+function()
+{
+ return ".youtube.com";
+}
+
+LinternaMagica.prototype.sites["youtube.com"].skip_link_extraction = function()
+{
+ // Link extraction bloats FF in youtube:
+ // LinternaMagica.extract_link_from_param_list:
+ // Trying to extract a link from param/attribute "flashvars"
+ // at www.youtube.com time: ***14:58:59:999***
+ // LinternaMagica.extract_link: No link found. at
+ // www.youtube.com time: ***15:12:21:356***
+ this.log("LinternaMagica.sites.skip_link_extraction:\n"+
+ "Skipping link extraction in YouTube. Might bloat "+
+ "GNU IceCat and other forks and versions of Firefox.",4);
+ return false;
+}
+
// Extracts data for the flash object in youtube from a script
-LinternaMagica.prototype.extract_object_from_script_youtube = function()
+LinternaMagica.prototype.sites["youtube.com"].extract_object_from_script =
+function()
{
var data = this.script_data;
if (!data.match(/var\s*swfConfig/))
@@ -258,74 +329,3 @@
return object_data;
}
-
-// Extract links data for youtube from fmt_url_map
-LinternaMagica.prototype.extract_youtube_fmt_url_map = function(data)
-{
- var fmt_re = new RegExp (
- "(\\\"|\\\'|\\\&)fmt_url_map"+
- "(\\\"|\\\')*(\\\=|\\\:|,)\\\s*(\\\"|\\\')*"+
- "([a-zA-Z0-9\\\-\\\_\\\%\\\=\\\/,\\\\\.\|:=&%\?]+)");
-
- var fmt = data.match(fmt_re);
-
- if (fmt)
- {
-
- // For debug level 1
- this.log("LinternaMagica.extract_youtube_fmt_url_map:\n"+
- "Extracted fmt_url_map.",1);
-
- // Hash with keys fmt_ids and values video URLs
- var map = new Object();
-
- // There was unescape here but it broke the split by ,. How it
- // worked it is not clear. Maybe YT changed something.
- fmt = fmt[fmt.length-1].replace(/\\\//g, "/");
-
- fmt = fmt.split(/,/);
-
- for (var url=0; url<fmt.length; url++)
- {
- // fmt_id|link
- var m = fmt[url].split(/\|/);
- map[m[0]] = m[1];
- }
-
- return map;
- }
- else
- {
- this.log("LinternaMagica.extract_youtube_fmt_url_map:\n"+
- "No fmt_url_map parameter found. ",1);
- }
-
- return null;
-}
-
-LinternaMagica.prototype.sites["youtube.com"] = new Object();
-
-// Reference
-LinternaMagica.prototype.sites["www.youtube.com"] = "youtube.com";
-LinternaMagica.prototype.sites["www.youtube-nocookie.com"] = "youtube.com";
-LinternaMagica.prototype.sites["youtube-nocookie.com"] = "youtube.com";
-
-LinternaMagica.prototype.sites["youtube.com"].set_cookies_domain =
-function()
-{
- return ".youtube.com";
-}
-
-LinternaMagica.prototype.sites["youtube.com"].skip_link_extraction = function()
-{
- // Link extraction bloats FF in youtube:
- // LinternaMagica.extract_link_from_param_list:
- // Trying to extract a link from param/attribute "flashvars"
- // at www.youtube.com time: ***14:58:59:999***
- // LinternaMagica.extract_link: No link found. at
- // www.youtube.com time: ***15:12:21:356***
- this.log("LinternaMagica.sites.skip_link_extraction:\n"+
- "Skipping link extraction in YouTube. Might bloat "+
- "GNU IceCat and other forks and versions of Firefox.",4);
- return false;
-}
Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-12 19:22:47 UTC (rev 128)
+++ branches/task-11216/src/lm_sites.js 2011-07-13 09:26:07 UTC (rev 129)
@@ -143,6 +143,12 @@
return true;
}
+// Extract object data from script
+LinternaMagica.prototype.sites.__extract_object_from_script = function()
+{
+ return true;
+}
+
// LinternaMagica.prototype.sites.__extract_scripts_extract_when // Condition
? DM /ted?
// LinternaMagica.prototype.sites.__extract_scripts_once // YT ?
// LinternaMagica.prototype.sites.__extract_scripts_wait_insert // FB
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [129] Changes for tasks #11216.,
Ivaylo Valkov <=