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

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

[linterna-magica-commit] [90] Fixes Blip.tv support.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [90] Fixes Blip.tv support.
Date: Tue, 14 Jun 2011 15:23:55 +0000

Revision: 90
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=90
Author:   valkov
Date:     2011-06-14 15:23:55 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
Fixes Blip.tv support. Closes tasks #11062. Closes bugs #33556.

Ticket Links:
------------
    http://savannah.gnu.org/task/?11062
    http://savannah.gnu.org/bugs/?33556

Modified Paths:
--------------
    trunk/src/lm_constructors.js
    trunk/src/lm_extract_dom_objects.js
    trunk/src/lm_extract_js_pokkariplayer.js
    trunk/src/lm_extract_video_link.js
    trunk/src/lm_jsonp_requests.js
    trunk/src/lm_remove_plugin_install_warning.js
    trunk/src/lm_site_bliptv.js

Modified: trunk/src/lm_constructors.js
===================================================================
--- trunk/src/lm_constructors.js        2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_constructors.js        2011-06-14 15:23:55 UTC (rev 90)
@@ -133,10 +133,7 @@
        this.request_video_link({video_id: window.location.pathname});
     }
     // If there is a plugin installed do not search in scripts.
-    // Exception for blip.tv. This is the easiesy way to
-    // support it with installed plugin.
     else if (!this.plugin_is_installed ||
-            /blip\.tv/i.test(window.location.hostname) ||
             /myvideo\.de/i.test(window.location.hostname) ||
             /theonion\.com/i.test(window.location.hostname))
     {

Modified: trunk/src/lm_extract_dom_objects.js
===================================================================
--- trunk/src/lm_extract_dom_objects.js 2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_extract_dom_objects.js 2011-06-14 15:23:55 UTC (rev 90)
@@ -236,6 +236,14 @@
                        self.request_video_link.apply(self,[data]);
                    }, this.wait_dailymotion);
                }
+               else if (/blip\.tv/i.test(window.location.hostname) ||
+                        (object.hasAttribute('src') &&
+                         /blip\.tv/i.test(object.getAttribute('src'))) ||
+                        (object.hasAttribute('data') && 
+                         /blip\.tv/i.test(object.getAttribute('data'))))
+               {
+                   this.request_bliptv_jsonp_data(object_data);
+               }
                else
                {
                    this.request_video_link(object_data);

Modified: trunk/src/lm_extract_js_pokkariplayer.js
===================================================================
--- trunk/src/lm_extract_js_pokkariplayer.js    2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_extract_js_pokkariplayer.js    2011-06-14 15:23:55 UTC (rev 90)
@@ -27,8 +27,9 @@
 
 // END OF LICENSE HEADER
 
-// Extracts object data for flash objects created with PokkariPlayer (blip.tv)
-// flash library
+// Extracts object data for flash objects created with PokkariPlayer
+// flash library. Used to be for Blip.tv, but the site changed. Some
+// other sites might use this code.
 LinternaMagica.prototype.
     extract_object_from_script_pokkariplayer =  function ()
 {
@@ -92,10 +93,6 @@
     object_data.link = url;
     object_data.mime = mime;
     object_data.parent = element;
-    if (/blip\.tv/i.test(window.location.hostname))
-    {
-       object_data.hd_links = this.extract_bliptv_hd_links();
-    }
 
     return object_data;
 }

Modified: trunk/src/lm_extract_video_link.js
===================================================================
--- trunk/src/lm_extract_video_link.js  2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_extract_video_link.js  2011-06-14 15:23:55 UTC (rev 90)
@@ -234,21 +234,39 @@
 
     // Fix vbox7.com (flashvars="id=...")
     data = "&"+data;
-    // 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\\\/...
-    var video_id_re = new RegExp (
-       "(\\\"|\\\'|\\\&|\\\?|\\\;|\\\/|\\\.|\\\=)(itemid|clip_id|video_id|"+
-           "vid|player_config\\\.php\\\?v|"+
-           
"videoid|media_id|vkey|video3|_videoid|vimeo_clip_|php&ID|\\\/video_embed\\\/\\\?id)"+
-           "(\\\"|\\\')*(\\\=|\\\:|,|\\\/)\\\s*(\\\"|\\\')*"+
-           "([a-zA-Z0-9\\\-\\\_]+)",
+
+    var video_id_re = null;
+
+    if (/blip\.tv/i.test(window.location.hostname) ||
+       /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\\\/(.*)",
+           "i");
+    }
+    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\\\/...
+       video_id_re = new RegExp (
+           
"(\\\"|\\\'|\\\&|\\\?|\\\;|\\\/|\\\.|\\\=)(itemid|clip_id|video_id|"+
+               "vid|player_config\\\.php\\\?v|"+
+               "videoid|media_id|vkey|video3|_videoid|"+
+               "vimeo_clip_|php&ID|\\\/video_embed\\\/\\\?id)"+
+               "(\\\"|\\\')*(\\\=|\\\:|,|\\\/)\\\s*(\\\"|\\\')*"+
+               "([a-zA-Z0-9\\\-\\\_]+)",
        "i");
+    }
 
     var video_id =data.match(video_id_re);
 

Modified: trunk/src/lm_jsonp_requests.js
===================================================================
--- trunk/src/lm_jsonp_requests.js      2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_jsonp_requests.js      2011-06-14 15:23:55 UTC (rev 90)
@@ -44,6 +44,8 @@
 //     parser_function: object,
 //     // The id for the frame
 //     frame_id: string
+//    // Custom data to be passed to the parser_function
+//    user_data: object
 // }
 LinternaMagica.prototype.create_checker_frame = function(data)
 {
@@ -158,7 +160,7 @@
        // Unpack
        jsonp_data = this.string_to_json(atob(jsonp_data));
 
-       data.parser_function.apply(this, [jsonp_data]);
+       data.parser_function.apply(this, [jsonp_data, data.user_data]);
     }
 }
 

Modified: trunk/src/lm_remove_plugin_install_warning.js
===================================================================
--- trunk/src/lm_remove_plugin_install_warning.js       2011-06-14 13:30:24 UTC 
(rev 89)
+++ trunk/src/lm_remove_plugin_install_warning.js       2011-06-14 15:23:55 UTC 
(rev 90)
@@ -122,7 +122,10 @@
        }
 
        // FIXME Temporary fix for Blip.tv. Will replace the HTML5
-       // player, otherwise two are visible.
+       // player, otherwise two are visible.  14.06.2011 With the
+       // changes in Blip.tv design and logic, I am unable to find
+       // how to turn HTML5 and test this. I always get the flash
+       // player.
        if (/blip\.tv/i.test(window.location.hostname))
        {
            if (node.parentNode)

Modified: trunk/src/lm_site_bliptv.js
===================================================================
--- trunk/src/lm_site_bliptv.js 2011-06-14 13:30:24 UTC (rev 89)
+++ trunk/src/lm_site_bliptv.js 2011-06-14 15:23:55 UTC (rev 90)
@@ -27,33 +27,57 @@
 
 // END OF LICENSE HEADER
 
-// Extracts hd links form Blip.tv
-LinternaMagica.prototype.extract_bliptv_hd_links = function()
+//  Makes a JSONP request that fetches the clip data in Blip.tv
+LinternaMagica.prototype.request_bliptv_jsonp_data =
+function (object_data)
 {
-    var holder = document.getElementById("SelectFormat");
+    var jsonp_request_data = new Object();
 
-    if (!holder)
-       return null;
+    jsonp_request_data.frame_id = "bliptv_jsonp_data_fetcher";
+    jsonp_request_data.parser_timeout = this.bliptv_jsonp_timeout;
+    jsonp_request_data.parser_timeout_counter = 
+       this.bliptv_jsonp_timeout_counter;
+    jsonp_request_data.jsonp_script_link = 
+       "http://blip.tv/players/episode/"+object_data.video_id+
+       "?skin=json&callback=bliptv_video_data&version=2";
+    jsonp_request_data.jsonp_function = "bliptv_video_data";
+    jsonp_request_data.parser_function = this.parse_bliptv_jsonp_data;
+    jsonp_request_data.user_data = object_data;
 
+    this.create_checker_frame(jsonp_request_data);
+}
 
-    // We have only one link
-    if (holder.options.length == 2)
-       return null;
+// Parses the JSONP data and creates the video object in Blip.tv
+LinternaMagica.prototype.parse_bliptv_jsonp_data = function(data, object_data)
+{
+    // The useful object is inside two arrays
+    data = data[0][0];
+    object_data.link = data.mediaUrl;
 
     var hd_links = new Array();
 
-    // option zero is just a message, no link there
-    for (var op=1; op<holder.options.length; op++)
+    // Sort the HD links by width so they are ordered in the HD link
+    // list bottom to top , low to high.
+    var sort_fun = function(a, b)
     {
-       var link_data = holder.options[op];
+       return ((a.width > b.width) ? -1 : 
+               (a.width < b.width) ? 1 :0);
+    };
+
+    data.additionalMedia.sort(sort_fun);
+
+    for (var i=0, l=data.additionalMedia.length; i<l; i++)
+    {
+       var link_data = data.additionalMedia[i];
        var link = new Object();
-       link.label = link_data.text;
-       var raw_url = link_data.value.split(/=/);
-       link.url = "http://blip.tv/file/get/"+raw_url[raw_url.length-1]+
-           "?referrer=blip.tv&source=1&use_direct=1&use_documents=1";
+       link.url = link_data.url;
+       link.label = link_data.role+
+           " ("+link_data.width+"x"+link_data.height+")";
 
-       hd_links.unshift(link);
+       hd_links.push(link);
     }
 
-    return hd_links;
+    object_data.hd_links = hd_links;
+    this.create_video_object(object_data);
 }
+




reply via email to

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