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

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

[linterna-magica-commit] [73] Fixes bugs #33324


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [73] Fixes bugs #33324
Date: Thu, 19 May 2011 10:41:45 +0000

Revision: 73
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=73
Author:   valkov
Date:     2011-05-19 10:41:44 +0000 (Thu, 19 May 2011)
Log Message:
-----------
Fixes bugs #33324

Ticket Links:
------------
    http://savannah.gnu.org/bugs/?33324

Modified Paths:
--------------
    trunk/src/lm_constructors.js
    trunk/src/lm_xhr.js

Modified: trunk/src/lm_constructors.js
===================================================================
--- trunk/src/lm_constructors.js        2011-05-16 12:43:52 UTC (rev 72)
+++ trunk/src/lm_constructors.js        2011-05-19 10:41:44 UTC (rev 73)
@@ -127,10 +127,15 @@
        this.player_timers = new Array();
     }
 
+    if (!this.plugin_is_installed &&
+       /dailymotion\.com/i.test(window.location.hostname))
+    {
+       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.
-    if (!this.plugin_is_installed ||
+    else if (!this.plugin_is_installed ||
        /blip\.tv/i.test(window.location.hostname) ||
        /myvideo\.de/i.test(window.location.hostname))
     {

Modified: trunk/src/lm_xhr.js
===================================================================
--- trunk/src/lm_xhr.js 2011-05-16 12:43:52 UTC (rev 72)
+++ trunk/src/lm_xhr.js 2011-05-19 10:41:44 UTC (rev 73)
@@ -337,6 +337,52 @@
 
        if (/dailymotion\.com/i.test(host))
        {
+           if (!this.plugin_is_installed &&
+               !object_data.linterna_magica_id && 
+               !object_data.parent)
+           {
+               // In Dailymotion the script that creates the flash
+               // object replaces itself. The work around here is to
+               // request the page and process it. 
+
+               // Dailymotion uses pseudo-random ids for some DOM
+               // elements of interest. We replace the body HTML with
+               // the one returned by the XHR. Then scripts are
+               // processed. The script extraction code matches the
+               // correct ID for the parentNode in DOM, that will
+               // hold the video object. The original body is
+               // restored, because some data is missing in the body
+               // data from XHR. After all data is collected, the
+               // parentNode (object_data.parent), where the video
+               // object will be inserted is replaced with the one in
+               // the original body.  Custom function to match the
+               // parent by CSS class is used, because getElementById
+               // does not support regular expressions.
+
+               var body_data = 
+                   client.responseText.split("<body")[1].
+                   replace(/>{1}/,"__SPLIT__").
+                   split("__SPLIT__")[1];
+
+               var body = document.getElementsByTagName("body")[0];
+               var original_body_data = body.innerHTML;
+
+               body.innerHTML = body_data;
+
+               this.script_data = client.responseText;
+               object_data = this.extract_object_from_script_swfobject();
+
+               body.innerHTML = original_body_data;
+
+               object_data.parent = 
+                   this.getElementByClass("dmpi_video_playerv[0-9]+");
+
+               if (!object_data.parent)
+               {
+                   return null;
+               }
+           }
+
            hd_links = this.extract_dailymotion_links(client.responseText);
            url = hd_links ? hd_links[hd_links.length-1].url : null;
 




reply via email to

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