forked from hoyois/plugin-to-html5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlip.js
73 lines (65 loc) · 2.39 KB
/
Blip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
addKiller("Blip", {
"canKill": function(data) {
return data.src.indexOf("blip.tv/") !== -1;
},
"process": function(data, callback) {
if(/^https?:\/\/blip\.tv\/players\/xplayer/.test(data.location)) {
var videoID = parseFlashVariables(data.location.split(/\?/)[1]).id;
var url = "http://blip.tv/rss/flash/" + videoID;
this.processXML(url, false, callback);
} else if(/stratos\.swf/.test(data.src)) {
var match = /[?&#]file=([^&]*)/.exec(data.src);
if(!match) return;
url = match[1];
this.processXML(decodeURIComponent(url), !/^http:\/\/blip\.tv/.test(data.location), callback);
} else {
var match = /blip\.tv\/play\/([^%]*)/.exec(data.src);
if(match) this.processOldVideoID(match[1], callback);
}
},
"processXML": function(url, isEmbed, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.addEventListener("load", function() {
var xml = xhr.responseXML;
var media = xml.getElementsByTagNameNS("http://search.yahoo.com/mrss/", "content");
var sources = [];
var url, info, height, audioOnly = true;
for(var i = 0; i < media.length; i++) {
url = media[i].getAttribute("url");
info = extInfo(getExt(url));
if(!info) continue;
if(!info.isAudio) audioOnly = false;
height = media[i].getAttribute("height");
info.url = url;
info.format = media[i].getAttributeNS("http://blip.tv/dtd/blip/1.0", "role") + " " + info.format;
info.height = parseInt(height);
sources.push(info);
}
var siteInfo;
if(isEmbed) {
var itemId = xml.getElementsByTagNameNS("http://blip.tv/dtd/blip/1.0", "item_id")[0];
if(itemId) siteInfo = {"name": "Blip.tv", "url": "http://www.blip.tv/file/" + itemId.textContent};
}
callback({
"playlist": [{
"title": xml.getElementsByTagName("item")[0].getElementsByTagName("title")[0].textContent,
"poster": xml.getElementsByTagNameNS("http://search.yahoo.com/mrss/", "thumbnail")[0].getAttribute("url"),
"sources": sources,
"siteInfo": siteInfo
}],
"audioOnly": audioOnly
});
}, false);
xhr.send(null);
},
"processOldVideoID": function(videoID, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://blip.tv/players/episode/" + videoID + "?skin=api", true);
var _this = this;
xhr.addEventListener("load", function() {
_this.processXML("http://blip.tv/rss/flash/" + xhr.responseXML.getElementsByTagName("id")[0].textContent, true, callback);
}, false);
xhr.send(null);
}
});