Fixed sort movies in collection

This commit is contained in:
zeldaroot 2020-02-24 01:39:45 +02:00
parent c84d7648f2
commit 197e3deb64

View file

@ -1224,32 +1224,40 @@ function saveData(collection, movies, callback) {
err,
result
);
async.eachOfLimit(
movies,
1,
function(movie, key, callback) {
if (!movie.translate && !movie.quality) return callback(null);
var rt = {};
rt.id = movie.kp_id;
rt.kp_id = movie.kp_id;
rt.translate = movie.translate;
rt.quality = movie.quality.toUpperCase();
rt.duplicate = true;
try {
var c = movie.custom ? JSON.parse(movie.custom) : {};
c.unique = c.unique ? c.unique : false;
rt.custom = JSON.stringify(c);
} catch (e) {
rt.custom = JSON.stringify({ unique: false });
CP_cache.flush(function(err) {
if (err) {
if ((err + '').indexOf('not available') === -1) {
console.error(err);
}
CP_save.save(rt, 'rt', function() {
return callback(null);
});
},
function() {
return callback(null);
}
);
async.eachOfLimit(
movies,
1,
function(movie, key, callback) {
if (!movie.translate && !movie.quality)
return callback(null);
var rt = {};
rt.id = movie.kp_id;
rt.kp_id = movie.kp_id;
rt.translate = movie.translate;
rt.quality = movie.quality.toUpperCase();
rt.duplicate = true;
try {
var c = movie.custom ? JSON.parse(movie.custom) : {};
c.unique = c.unique ? c.unique : false;
rt.custom = JSON.stringify(c);
} catch (e) {
rt.custom = JSON.stringify({ unique: false });
}
CP_save.save(rt, 'rt', function() {
return callback(null);
});
},
function() {
return callback(null);
}
);
});
});
} else {
console.log('[movies]', collection, err, movies);