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++) {
var e = {
id: pl[i].media.id,
title: pl[i].media.title,
seconds: pl[i].media.seconds,
type: pl[i].media.type
};
time += pl[i].media.seconds;

View file

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

View file

@ -239,6 +239,19 @@ Playlist.prototype.addMedia = function(data, callback) {
};
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) {
if(err) {
action.expire = 0;

View file

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