linterna-magica-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linterna-magica-commit] [148] Changes for tasks #11216.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [148] Changes for tasks #11216.
Date: Wed, 20 Jul 2011 18:49:42 +0000

Revision: 148
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=148
Author:   valkov
Date:     2011-07-20 18:49:40 +0000 (Wed, 20 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule to set/force video extraction regex to 
site specific one.

Ticket Links:
------------
    http://savannah.gnu.org/task/?11216

Modified Paths:
--------------
    branches/task-11216/src/lm_extract_video_link.js
    branches/task-11216/src/lm_site_bliptv.js
    branches/task-11216/src/lm_sites.js

Modified: branches/task-11216/src/lm_extract_video_link.js
===================================================================
--- branches/task-11216/src/lm_extract_video_link.js    2011-07-20 16:08:35 UTC 
(rev 147)
+++ branches/task-11216/src/lm_extract_video_link.js    2011-07-20 18:49:40 UTC 
(rev 148)
@@ -152,31 +152,38 @@
     data = "&"+data;
 
     var video_id_re = null;
+    var match_site = null;
+    var video_id_position = null;
 
-    if (/blip\.tv/i.test(window.location.hostname) ||
-       /blip\.tv/i.test(data))
+    if (/blip\.tv/i.test(data))
     {
        // Blip.tv has a JSONP API that could be used in remote
        // sites. That is why we cant search for blip.tv directly in
        // the data.
        // http://wiki.blip.tv/index.php/Extract_metadata_from_our_embed_code
-       video_id_re = new RegExp(
-           "blip\\\.tv\\\/(play|rss\\\/flash)\\\/([0-9A-Za-z_%-]+)&*",
-           "i");
+
+       match_site = "blip.tv";
     }
     else
     {
-       // 06.07.2010 Update  for vidoemo.com video3 and \\\/
-       // slashes before and after might create bugs
-       // 18.12.2010 Update is for vimeo.com : vimeo_clip_
-       // 12.02.2011 Update for myvideo.de. php&ID and \\\. This migth break
-       // 25.02.2011 Update for videoclipsdump.com
-       // player_config\\\.php\\\ must be after vid|
-       // 11.06.2011 Update for theonion.com 
-       // \\\/video_embed\\\/...
+       match_site = window.location.hostname;
+    }
+
+    var self = this;
+    var val = this.call_site_function_at_position.apply(self,[
+       "set_video_id_regex",
+       match_site]);
+
+    if (val && typeof(val) !== "boolean")
+    {
+       video_id_re = val.video_id_re;
+       video_id_position = val.video_id_position;
+    }
+    else
+    {
        video_id_re = new RegExp (
-           
"(\\\"|\\\'|\\\&|\\\?|\\\;|\\\/|\\\.|\\\=)(itemid|clip_id|video_id|"+
-               "vid|player_config\\\.php\\\?v|"+
+           "(\\\"|\\\'|\\\&|\\\?|\\\;|\\\/|\\\.|\\\=)(itemid|"+
+               "clip_id|video_id|vid|player_config\\\.php\\\?v|"+
                "videoid|media_id|vkey|video3|_videoid|"+
                "vimeo_clip_|php&ID|\\\/video_embed\\\/\\\?id)"+
                "(\\\"|\\\')*(\\\=|\\\:|,|\\\/)\\\s*(\\\"|\\\')*"+
@@ -184,11 +191,17 @@
        "i");
     }
 
+    if (video_id_position == null ||
+       typeof(video_id_position) == "undefined")
+    {
+       video_id_position = 1;
+    }
+
     var video_id =data.match(video_id_re);
 
     if (video_id)
     {
-       video_id = video_id[video_id.length-1];
+       video_id = video_id[video_id.length-video_id_position];
 
        this.log("LinternaMagica.extract_video_id:\n"+
                 "Extracted video id : "+video_id,1);

Modified: branches/task-11216/src/lm_site_bliptv.js
===================================================================
--- branches/task-11216/src/lm_site_bliptv.js   2011-07-20 16:08:35 UTC (rev 
147)
+++ branches/task-11216/src/lm_site_bliptv.js   2011-07-20 18:49:40 UTC (rev 
148)
@@ -89,3 +89,22 @@
     this.create_video_object(object_data);
 }
 
+LinternaMagica.prototype.sites["blip.tv"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.blip.tv"] = "blip.tv";
+
+LinternaMagica.prototype.sites["blip.tv"].set_video_id_regex = function()
+{
+    var result = new Object();
+
+    result.video_id_re = new RegExp(
+       "blip\\\.tv\\\/(play|rss\\\/flash)\\\/([0-9A-Za-z_%-]+)&*",
+       "i");
+
+    // Captured video_id position from left to right. Will be
+    // subtracted from the matched arrays's lenght;
+    result.videoid_position = 1;
+
+    return result;
+}

Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-20 16:08:35 UTC (rev 147)
+++ branches/task-11216/src/lm_sites.js 2011-07-20 18:49:40 UTC (rev 148)
@@ -195,6 +195,13 @@
     return true;
 }
 
+// Force/set the regular expression used to extract video id to
+// site specific value. Overrides the default one.
+LinternaMagica.prototype.sites.__set_video_id_regex = function()
+{
+    return true;
+}
+
 // LinternaMagica.prototype.sites.__extract_scripts_extract_when // Condition 
? DM /ted? 
 // LinternaMagica.prototype.sites.__wait_before_inserting_object_from-script 
// FB
 // LinternaMagica.prototype.sites.__extract_swfobject_regex




reply via email to

[Prev in Thread] Current Thread [Next in Thread]