diff --git a/get-info.js b/get-info.js index b8440618..88a83299 100644 --- a/get-info.js +++ b/get-info.js @@ -226,8 +226,20 @@ exports.getUstream = function(name, callback) { html += cnk; }); res.on("end", function() { + if(res.statusCode != 200) { + callback(true, null); + return; + } var lines = html.split("\n"); const re = /cid":([0-9]+)/; + var m = html.match(re); + if(m) { + callback(false, m[1]); + } + else { + callback(true, null); + } + return; for(var i = 0; i < lines.length; i++) { var m = lines[i].match(re); if(m) { @@ -371,18 +383,27 @@ exports.getMedia = function(id, type, callback) { case "li": case "tw": case "jt": - case "us": case "jw": const prefix = { "li": "Livestream.com - ", "tw": "Twitch.tv - ", "jt": "Justin.tv - ", - "us": "Ustream.tv - ", "jw": "JWPlayer Stream - " }; var media = new Media(id, prefix[type] + id, "--:--", type); callback(false, media); break; + case "us": + exports.getUstream(id, function(err, data) { + if(err) { + callback(true, null); + return; + } + + var media = new Media(data, "Ustream.tv - " + id, "--:--", "us"); + callback(false, media); + }); + break; case "rt": case "im": const names = { diff --git a/package.json b/package.json index ee891dc1..c296645f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "2.0.3", + "version": "2.0.4", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/server.js b/server.js index 2cccd70f..07bc03a4 100644 --- a/server.js +++ b/server.js @@ -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 = "2.0.3"; +const VERSION = "2.0.4"; var fs = require("fs"); var Logger = require("./logger.js");