Save playlists with cached data

This commit is contained in:
calzoneman 2013-07-30 09:07:30 -04:00
parent 17c733be44
commit fe2985e8dd
4 changed files with 17 additions and 2 deletions

View File

@ -900,6 +900,8 @@ function saveUserPlaylist(pl, user, name) {
for(var i = 0; i < pl.length; i++) { for(var i = 0; i < pl.length; i++) {
var e = { var e = {
id: pl[i].media.id, id: pl[i].media.id,
title: pl[i].media.title,
seconds: pl[i].media.seconds,
type: pl[i].media.type type: pl[i].media.type
}; };
time += pl[i].media.seconds; time += pl[i].media.seconds;

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "2.1.3", "version": "2.1.4",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -239,6 +239,19 @@ Playlist.prototype.addMedia = function(data, callback) {
}; };
this.queueAction(action); this.queueAction(action);
// Pre-cached data
if(typeof data.title === "string" &&
typeof data.seconds === "number") {
if(data.maxlength && data.seconds > data.maxlength) {
action.expire = 0;
callback("Media is too long!", null);
return;
}
it.media = new Media(data.id, data.title, data.seconds, data.type);
action.waiting = false;
return;
}
InfoGetter.getMedia(data.id, data.type, function(err, media) { InfoGetter.getMedia(data.id, data.type, function(err, media) {
if(err) { if(err) {
action.expire = 0; action.expire = 0;

View File

@ -6,7 +6,7 @@ var Logger = require("./logger");
var Channel = require("./channel"); var Channel = require("./channel");
var User = require("./user"); var User = require("./user");
const VERSION = "2.1.3"; const VERSION = "2.1.4";
function getIP(req) { function getIP(req) {
var raw = req.connection.remoteAddress; var raw = req.connection.remoteAddress;