Online VOD Issues

Online VOD Issues

Adam Kariv a.dapper.dan.man at gmail.com
Sun Jun 6 14:09:40 IDT 2010


I have written a chrome extension to extract the video link from any
mako vod page. Simply open any video page in the Mako VOD site, and
copy-paste the displayed link to vlc to play the video (works
perfectly on my Ubuntu box).

To use the extension, put these two files in one directory and use
chrome's extension manager to load it (disclaimer - it's not well
written, but it works):

manifest.json:
==========
{
  "name": "Mako VOD",
  "version": "1.0",
  "description": "Extract direct link instead of built-in player.",
  "content_scripts": [
    {
      "matches": ["http://switch5.castup.net/Customers/KeshetMako/*"],
      "js": ["myscript.js"],
 "all_frames": true
    }
  ],
  "permissions": [
    "tabs",
    "http://*.castup.net/"
  ]
}
========

myscript.js:
========
var findAddress = function() {
  var found;
  var re = new RegExp("var cuUrl = \"(.+)\";");
  var node = document.head;
  var done = false;
  while (!done) {
    done = true;
    for (var i = 0; i < node.childNodes.length; ++i) {
      var child = node.childNodes[i];
      if (child.textContent.match(re)) {
console.log(".");
        node = child;
        found = node;
        done = false;
        break;
      }
    }
  }
  if (found) {
    var text = "";
    if (found.childNodes.length) {
      for (var i = 0; i < found.childNodes.length; ++i) {
        text += found.childNodes[i].textContent + " ";
      }
    } else {
      text = found.textContent;
    }
    var match = re.exec(text);
    if (match && match.length) {
      console.log("found: " + match[0]);
      return match[0].replace("var cuUrl = \"", "").replace("\";","");
    } else {
      console.log("bad initial match: " + found.textContent);
      console.log("no match in: " + text);
    }
  }
  return null;
}
var dostuff = function() {
var address = findAddress();
document.body.innerHTML = "<div style='margin:20px;'><label>Copy this
link:<br/><font size='-5'>"+address+"</font></label></div>";
};

setTimeout("dostuff();", 1000 );
=======
HTH,
Adam



More information about the Linux-il mailing list