Fix Ustream [#216]

This commit is contained in:
calzoneman 2013-07-12 16:07:11 -04:00
parent 8ea0a34326
commit efc3cf35f4
3 changed files with 25 additions and 4 deletions

View File

@ -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 = {

View File

@ -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"
},

View File

@ -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");