Fix rai.tv support
authorAntonio Ospite <ospite@studenti.unina.it>
Sun, 12 Feb 2012 15:47:58 +0000 (16:47 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Sun, 12 Feb 2012 15:47:58 +0000 (16:47 +0100)
The pages structure has changed a little and smooth streaming links are
not behind the re-link infrastructure as well and so they need to be
processed.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
direct_download_links.user.js

index 9344012..bd8e32a 100644 (file)
@@ -107,11 +107,11 @@ var supported_sites = [
           return true;
         };
     },
-    urlContainerXPath: '//div[@id="Player"]',
+    urlContainerXPath: '//div[@id="silverlightControlHost" or @id="SilverlightPlayer"]',
     urlRegexp: /mediaUri=(http:\/\/[^,]*)/,
     onEvent: { evt: 'DOMNodeInserted', targetElement: 'object' },
     processURL: _rai_get_actual_url,
-    linkDestXPath: '//div[@id="Player"]',
+    linkDestXPath: '//div[@id="silverlightControlHost" or @id="SilverlightPlayer"]',
   },
   {
     locationRegexp: /^http:\/\/soundcloud.com\/.*$/,
@@ -267,9 +267,21 @@ function _rai_get_actual_url(site, URL) {
         parser = new DOMParser();
         xmlDoc = parser.parseFromString(text, "text/xml");
 
-        ref = xmlDoc.getElementsByTagName('REF');
-        if (ref.length > 0) {
-          href = ref[0].getAttribute('HREF');;
+        // MMS streams
+        elems = xmlDoc.getElementsByTagName('REF');
+        if (elems.length > 0) {
+          href = elems[0].getAttribute('HREF');;
+
+          var evt = document.createEvent('Event');
+          evt.initEvent('UrlFetched', true, true);
+          evt.site = site;
+          evt.URL = href;
+          document.dispatchEvent(evt);
+        }
+        // SmoothStreaming streams
+        elems = xmlDoc.getElementsByTagName('playListItem');
+        if (elems.length > 0) {
+          href = elems[0].getAttribute('mediaSource');;
 
           var evt = document.createEvent('Event');
           evt.initEvent('UrlFetched', true, true);