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

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

[linterna-magica-commit] [204] Closes tasks #11341.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [204] Closes tasks #11341.
Date: Wed, 28 Sep 2011 20:23:03 +0000

Revision: 204
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=204
Author:   valkov
Date:     2011-09-28 20:23:03 +0000 (Wed, 28 Sep 2011)
Log Message:
-----------
Closes tasks #11341. Adds basic/initial support for flowplayer and few sites as 
a result of that.

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

Modified Paths:
--------------
    trunk/WEBSITES
    trunk/src/lm_extract_js_scripts.js
    trunk/src/lm_extract_video_link.js

Added Paths:
-----------
    trunk/src/lm_extract_js_flowplayer.js

Modified: trunk/WEBSITES
===================================================================
--- trunk/WEBSITES      2011-09-28 20:15:04 UTC (rev 203)
+++ trunk/WEBSITES      2011-09-28 20:23:03 UTC (rev 204)
@@ -51,6 +51,8 @@
 http://yourlisten.com
 http://livestream.com
 http://www.khanacademy.org
+http://www.vdocity.com
+htp://publicdomainreview.org
 
 Bulgarian:
 http://vbox7.com

Added: trunk/src/lm_extract_js_flowplayer.js
===================================================================
--- trunk/src/lm_extract_js_flowplayer.js                               (rev 0)
+++ trunk/src/lm_extract_js_flowplayer.js       2011-09-28 20:23:03 UTC (rev 
204)
@@ -0,0 +1,110 @@
+//  @licstart The following is the entire license notice for the
+//  JavaScript code in this page (or file).
+//
+//  This file is part of Linterna Mágica
+//
+//  Copyright (C) 2011  Ivaylo Valkov <address@hidden>
+//
+//  The JavaScript code in this page (or file) is free software: you
+//  can redistribute it and/or modify it under the terms of the GNU
+//  General Public License (GNU GPL) as published by the Free Software
+//  Foundation, either version 3 of the License, or (at your option)
+//  any later version.  The code is distributed WITHOUT ANY WARRANTY
+//  without even the implied warranty of MERCHANTABILITY or FITNESS
+//  FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
+//
+//  As additional permission under GNU GPL version 3 section 7, you
+//  may distribute non-source (e.g., minimized or compacted) forms of
+//  that code without the copy of the GNU GPL normally required by
+//  section 4, provided you include this license notice and a URL
+//  through which recipients can access the Corresponding Source.
+//
+//  @licend The above is the entire license notice for the JavaScript
+//  code in this page (or file).
+//
+// @source http://linterna-magica.nongnu.org
+
+// END OF LICENSE HEADER
+
+// Extracts object data for flash objects created with flowplayer
+// flash player/library.
+LinternaMagica.prototype.extract_object_from_script_flowplayer = function()
+{
+    var constructor_re = new RegExp(
+       ".*(flowplayer|$f)\\\s*\\\(([^,]+)\\\s*,\\\s*.*",
+       "im");
+
+    var data = this.script_data;
+
+    var constructor = data.match(constructor_re);
+    var el;
+    var object_data = new Object();
+    
+    if (!constructor)
+    {
+       return null;
+    }
+
+    el = constructor[2].replace(/\'|\"/g, "");
+    el = document.getElementById(el);
+
+    if (!el)
+    {
+       this.log("LinternaMagica.extract_object_from_script_flowplayer:\n"+
+                "No player holder element found with id "+el,4);
+
+       return null;
+    }
+
+    object_data.parent = el;
+    object_data.width = el.clientWidth ? el.clientWidth: el.offsetWidth;
+    object_data.height = el.clientHeight ? el.clientHeight: el.offsetHeight;
+
+    this.extract_link_data = data;
+    object_data.link = this.extract_link();
+
+    if (object_data.link)
+    {
+       object_data.linterna_magica_id = 
+           this.mark_flash_object("extracted-from-script");
+
+       return object_data;
+    }
+
+    return null;
+}
+
+// Fixes relative links used in some sites with flowplayer.
+LinternaMagica.prototype.fix_flowplayer_links = function(link)
+{
+    if (!link)
+    {
+       return null;
+    }
+
+    if (!/^http/i.test(link))
+    {
+       var data = this.extract_link_data;
+       var base_url_re = new RegExp(
+           "(\\\"|\\\')*baseUrl(\\\'|\\\")*\\\s*:\\\s*(\\\'|\\\")"+
+               "([^\\\'\\\"\\\,]+)(\\\'|\\\")",
+           "im");
+
+       var base_url = data.match(base_url_re);
+
+       if (base_url)
+       {
+           link = base_url[base_url.length-2]+"/"+link;
+       }
+
+       // Relative link in the form ../../link/address/with_clip.flv
+       if (/^\.\.\//i.test(link))
+       {
+           var href = window.location.href.split("/");
+           var base_url = href.slice(0,(href.lenght-1)).join("/");
+           link = base_url +"/" +link;
+       }
+    }
+
+    return link;
+}

Modified: trunk/src/lm_extract_js_scripts.js
===================================================================
--- trunk/src/lm_extract_js_scripts.js  2011-09-28 20:15:04 UTC (rev 203)
+++ trunk/src/lm_extract_js_scripts.js  2011-09-28 20:23:03 UTC (rev 204)
@@ -110,6 +110,12 @@
        if (!object_data)
        {
            object_data =
+               this.extract_object_from_script_flowplayer();
+       }
+
+       if (!object_data)
+       {
+           object_data =
                this.extract_object_from_script_pokkariplayer();
        }
 

Modified: trunk/src/lm_extract_video_link.js
===================================================================
--- trunk/src/lm_extract_video_link.js  2011-09-28 20:15:04 UTC (rev 203)
+++ trunk/src/lm_extract_video_link.js  2011-09-28 20:23:03 UTC (rev 204)
@@ -122,6 +122,12 @@
        //     //       "mediashare\\\.bg|ted\\\.com",
        //     "i");
 
+       // Some links used with flowplayer are relative
+       if (data.match(/.*flowplayer.*/))
+       {
+           link = this.fix_flowplayer_links(link);
+       }
+
        this.log("LinternaMagica.extract_link:\n"+
                 " Extracted link: "+link,1);
 




reply via email to

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