[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [412] Fixed Dailymotion support.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [412] Fixed Dailymotion support. |
Date: |
Sun, 28 Jul 2013 11:45:09 +0000 |
Revision: 412
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=412
Author: valkov
Date: 2013-07-28 11:45:08 +0000 (Sun, 28 Jul 2013)
Log Message:
-----------
Fixed Dailymotion support. Works with and without flash plugin. Dropped HD
links support since there is only one link found. Code clean up. See bugs
#39564.
Ticket Links:
------------
http://savannah.gnu.org/bugs/?39564
Modified Paths:
--------------
trunk/src/lm_site_dailymotion.js
Modified: trunk/src/lm_site_dailymotion.js
===================================================================
--- trunk/src/lm_site_dailymotion.js 2013-07-28 11:41:11 UTC (rev 411)
+++ trunk/src/lm_site_dailymotion.js 2013-07-28 11:45:08 UTC (rev 412)
@@ -39,42 +39,46 @@
// requests are useless.
var links_re = new RegExp (
- "sdurl"+
+ "video_url"+
"(\\\"|\\\')*\\\s*(\\\=|\\\:|\\\,)\\\s*(\\\"|\\\')*"+
"(.*(\\\?auth\\\=[A-Za-z0-9\\\-\\\.]+)"+
"(\\\&|\\\"|\\\'){1})\\\,{1}",
"i");
- var links = unescape(data).match(links_re);
+ var link = unescape(data).match(links_re);
- if (links && links[0])
+ if (!link || !link[0])
{
- // There is not data after the last comma, it is end-of-match.
- links = links[0].replace(/,$/, "").split(/,/);
+ return null;
+ }
- var hd_links = new Array();
+ link = link[0].split(":");
- for (var lnk=0; lnk<links.length; lnk++)
- {
- var link = new Object();
- var link_data = links[lnk];
+ if (!link || !link[1])
+ {
+ return null;
+ }
- link.label = link_data.match(/\w+-\d+x\d+/i);
- link.url = link_data.replace(/\\\//g, "/").replace(
- /(\"\s*:\s*\")|(\"\s*|,\s*\")|hdurl|hqurl|sdurl|\}/ig,
- "").replace(/hd720url|hd1080url/ig,"");
+ link = link[1].split(",");
- this.log("LinternaMagica.extract_dailymotion_links:\n"+
- "Extracted link : "+link.url,4);
+ if (!link || !link[0])
+ {
+ return null;
+ }
- // We want highest res on top
- // but we parse the links from lowest to highest
- hd_links.unshift(link)
- }
- return hd_links;
+ link = link[0].split("\"");
+
+ if (!link || !link[1])
+ {
+ return null;
}
- return null;
+ link = unescape(link[1]);
+
+ this.log("LinternaMagica.create_youtube_links:\n"+
+ "Extracted link : "+link,4);
+
+ return link;
}
LinternaMagica.prototype.sites["dailymotion.com"] = new Object();
@@ -109,16 +113,6 @@
return true;
}
-LinternaMagica.prototype.sites["dailymotion.com"].process_cookies =
-function()
-{
- // Dailymotion is processed twice. Once with .dailymotion.com. The
- // second time with www.dailymotion.com. They set cookies very
- // strange. Also they use host= which is not documented anywhere
- // (DOM 0,1...).
- return "; domain=.dailymotion.com; path=/;
host="+window.location.hostname+"; ";
-}
-
LinternaMagica.prototype.sites["dailymotion.com"].do_not_force_iframe_detection
=
function()
{
@@ -160,19 +154,6 @@
// libswfobject_skip_video_id_extraction
result.address = object_data.video_id;
- this.extract_cookies();
- this.expire_cookies();
-
- // For some strange reason the cookie that activates the HTML5
- // player could not be expired. It must be forced to non-relevant
- // for the site value. If it is present, the XHR does not get a
- // flash player version of the page and no data could be
- // extracted.
- if (/html5_switch=1/i.test(document.cookie))
- {
- document.cookie = "html5_switch=0;";
- }
-
return result;
}
@@ -181,7 +162,9 @@
{
var client = args.client;
var object_data = args.object_data;
-
+ object_data.linterna_magica_id =
+ this.mark_flash_object("extracted-from-script");
+
// !this.plugin_is_installed is removed so it could work when
// plugin is installed and HTML5 is active.
if (!object_data.linterna_magica_id &&
@@ -213,53 +196,17 @@
object_data.offsetWidht : null ;
}
- var hd_links = this.extract_dailymotion_links(client.responseText);
- object_data.link = hd_links ? hd_links[hd_links.length-1].url : null;
- object_data.hd_links = (hd_links && hd_links.length) ? hd_links : null;
+ object_data.link = this.extract_dailymotion_links(client.responseText);
- // See "A note on cookies"
- if (/restore/i.test(this.process_cookies))
- {
- this.restore_cookies();
- }
- // For some strange reason the cookie that activates the HTML5
- // player could not be expired. It was forced to non-relevant for
- // the site value. If it is present, the XHR does not get a flash
- // player version of the page and no data could be extracted. It
- // must be restored.
- if (/html5_switch=0/i.test(document.cookie))
+ if (!object_data.width || !object_data.height || !object_data.link)
{
- document.cookie = "html5_switch=1;";
+ return null;
}
-
- if (!object_data.width || !object_data.height || !object_data.link)
- {
- return null;
- }
-
-
return object_data;
}
-LinternaMagica.prototype.sites["dailymotion.com"].insert_object_after_xhr =
-function(object_data)
-{
- // Skip the remove_plugin_install_waring in the default object
- // creation code after XHR. This keeps the HTML5 error screen.
- if (/html5_switch=1/i.test(document.cookie))
- {
- this.log("LinternaMagica.request_video_link_parse response:\n"+
- "Creating video object with url: "+object_data.link,1);
- this.create_video_object(object_data);
- return false;
- }
-
- // Just exit and leave object insertion to the XHR function.
- return true;
-}
-
LinternaMagica.prototype.sites["dailymotion.com"].css_fixes =
function(object_data)
{
@@ -308,3 +255,11 @@
return html5_player_element;
}
+
+
+LinternaMagica.prototype.sites["dailymotion.com"].flash_plugin_installed =
+function()
+{
+ return this.sites["dailymotion.com"].
+ no_flash_plugin_installed.apply(this,[arguments]);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [412] Fixed Dailymotion support.,
Ivaylo Valkov <=