mirror of https://github.com/calzoneman/sync.git
Add ustream support
This commit is contained in:
parent
e45489b77c
commit
c1c3e4c47f
|
@ -27,6 +27,7 @@ The following media sources are currently supported:
|
|||
- Soundcloud
|
||||
- Livestream.com
|
||||
- Twitch.tv
|
||||
- Ustream
|
||||
- RTMP livestreams
|
||||
|
||||
Installing
|
||||
|
|
11
channel.js
11
channel.js
|
@ -686,7 +686,8 @@ function isLive(type) {
|
|||
return type == "li"
|
||||
|| type == "tw"
|
||||
|| type == "rt"
|
||||
|| type == "jw";
|
||||
|| type == "jw"
|
||||
|| type == "us";
|
||||
}
|
||||
|
||||
Channel.prototype.queueAdd = function(media, idx) {
|
||||
|
@ -749,6 +750,14 @@ Channel.prototype.enqueue = function(data, user) {
|
|||
this.autoTemp(media, user);
|
||||
this.queueAdd(media, idx);
|
||||
break;
|
||||
case "us":
|
||||
InfoGetter.getUstream(data.id, function(id) {
|
||||
var media = new Media(id, "Ustream - " + data.id, "--:--", "us");
|
||||
media.queueby = user ? user.name : "";
|
||||
this.autoTemp(media, user);
|
||||
this.queueAdd(media, idx);
|
||||
}.bind(this));
|
||||
break;
|
||||
case "rt":
|
||||
var media = new Media(data.id, "Livestream", "--:--", "rt");
|
||||
media.queueby = user ? user.name : "";
|
||||
|
|
34
get-info.js
34
get-info.js
|
@ -29,8 +29,7 @@ function getJSON(options, callback) {
|
|||
}
|
||||
catch(e) {
|
||||
Logger.errlog.log("JSON fail: " + options.path);
|
||||
return;
|
||||
}
|
||||
return; }
|
||||
callback(res.statusCode, data);
|
||||
});
|
||||
});
|
||||
|
@ -190,6 +189,37 @@ exports.getDMInfo = function(id, callback) {
|
|||
timeout: 1000}, callback);
|
||||
}
|
||||
|
||||
// Ustream requires a developer key for their API, and on top of that
|
||||
// I couldn't figure out how to use it.
|
||||
// I'm regexing the stream ID out of the HTML
|
||||
// So sue me
|
||||
exports.getUstream = function(name, callback) {
|
||||
var opts = {
|
||||
host: "www.ustream.tv",
|
||||
port: 80,
|
||||
path: "/" + name
|
||||
};
|
||||
http.get(opts, function(res) {
|
||||
var html = "";
|
||||
res.on("data", function(cnk) {
|
||||
html += cnk;
|
||||
});
|
||||
res.on("end", function() {
|
||||
var lines = html.split("\n");
|
||||
const re = /cid":([0-9]+)/;
|
||||
for(var i = 0; i < lines.length; i++) {
|
||||
var m = lines[i].match(re);
|
||||
if(m) {
|
||||
callback(m[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}).on("error", function(err) {
|
||||
Logger.errlog.log(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
exports.getMedia = function(id, type, callback) {
|
||||
switch(type) {
|
||||
case "yt":
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "1.7.3",
|
||||
"version": "1.7.4",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const VERSION = "1.7.3";
|
||||
const VERSION = "1.7.4";
|
||||
|
||||
var fs = require("fs");
|
||||
var Logger = require("./logger.js");
|
||||
|
|
|
@ -502,6 +502,8 @@ function parseVideoURL(url){
|
|||
return [parseTwitch(url), "tw"];
|
||||
else if(url.indexOf("livestream.com") != -1)
|
||||
return [parseLivestream(url), "li"];
|
||||
else if(url.indexOf("ustream.tv") != -1)
|
||||
return [parseUstream(url), "us"];
|
||||
else if(url.indexOf("soundcloud.com") != -1)
|
||||
return [url, "sc"];
|
||||
else if(url.indexOf("vimeo.com") != -1)
|
||||
|
@ -550,6 +552,14 @@ function parseLivestream(url) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function parseUstream(url) {
|
||||
var m = url.match(/ustream\.tv\/([a-zA-Z0-9-]+)/);
|
||||
if(m) {
|
||||
return m[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function parseVimeo(url) {
|
||||
var m = url.match(/vimeo\.com\/([0-9]+)/);
|
||||
if(m) {
|
||||
|
|
|
@ -34,6 +34,9 @@ var Media = function(data) {
|
|||
case "jw":
|
||||
this.initJWPlayer();
|
||||
break;
|
||||
case "us":
|
||||
this.initUstream();
|
||||
break;
|
||||
default:
|
||||
this.nullPlayer();
|
||||
break;
|
||||
|
@ -373,6 +376,31 @@ Media.prototype.initJWPlayer = function() {
|
|||
this.seek = function() { }
|
||||
}
|
||||
|
||||
Media.prototype.initUstream = function() {
|
||||
var iframe = $("<iframe/>").insertBefore($("#ytapiplayer"));
|
||||
$("#ytapiplayer").remove();
|
||||
iframe.attr("id", "ytapiplayer");
|
||||
iframe.attr("width", VWIDTH);
|
||||
iframe.attr("height", VHEIGHT);
|
||||
iframe.attr("src", "http://www.ustream.tv/embed/"+this.id+"?v=3&wmode=direct");
|
||||
iframe.attr("frameborder", "0");
|
||||
iframe.attr("scrolling", "no");
|
||||
iframe.css("border", "none");
|
||||
|
||||
this.load = function(data) {
|
||||
this.id = data.id;
|
||||
this.initUstream();
|
||||
}
|
||||
|
||||
this.pause = function() { }
|
||||
|
||||
this.play = function() { }
|
||||
|
||||
this.getTime = function() { }
|
||||
|
||||
this.seek = function() { }
|
||||
}
|
||||
|
||||
Media.prototype.update = function(data) {
|
||||
if(data.id && data.id != this.id) {
|
||||
if(data.currentTime < 0) {
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
<li>http://www.dailymotion.com/video/(videoid)</li>
|
||||
<li>http://www.twitch.tv/(channel)</li>
|
||||
<li>http://www.livestream.com/(channel)</li>
|
||||
<li>http://www.ustream.tv/(channel)</li>
|
||||
<li>rtmp://(stream url)</li>
|
||||
<li>jw:(stream url) - uses a JWPlayer embed (use this for audio streams)
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue