mirror of https://github.com/calzoneman/sync.git
database: update for new custom embed format
This commit is contained in:
parent
7fee1414e2
commit
92d5375950
|
@ -427,7 +427,8 @@ module.exports = {
|
|||
var meta = JSON.stringify({
|
||||
bitrate: media.meta.bitrate,
|
||||
codec: media.meta.codec,
|
||||
scuri: media.meta.scuri
|
||||
scuri: media.meta.scuri,
|
||||
embed: media.meta.embed
|
||||
});
|
||||
|
||||
db.query("INSERT INTO `channel_libraries` " +
|
||||
|
|
|
@ -2,7 +2,7 @@ var db = require("../database");
|
|||
var Logger = require("../logger");
|
||||
var Q = require("q");
|
||||
|
||||
const DB_VERSION = 5;
|
||||
const DB_VERSION = 6;
|
||||
var hasUpdates = [];
|
||||
|
||||
module.exports.checkVersion = function () {
|
||||
|
@ -54,6 +54,8 @@ function update(version, cb) {
|
|||
})
|
||||
} else if (version < 5) {
|
||||
fixUtf8mb4(cb);
|
||||
} else if (version < 6) {
|
||||
fixCustomEmbeds(cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,3 +242,31 @@ function fixUtf8mb4(cb) {
|
|||
Logger.errlog.log("Failed to fix utf8mb4: " + e);
|
||||
});
|
||||
};
|
||||
|
||||
function fixCustomEmbeds(cb) {
|
||||
var CustomEmbedFilter = require("../customembed").filter;
|
||||
|
||||
Q.nfcall(db.query, "SELECT * FROM `channel_libraries` WHERE type='cu'")
|
||||
.then(function (rows) {
|
||||
var all = [];
|
||||
rows.forEach(function (row) {
|
||||
if (row.id.indexOf("cu:") === 0) return;
|
||||
|
||||
all.push(Q.nfcall(db.query, "DELETE FROM `channel_libraries` WHERE `id`=? AND `channel`=?",
|
||||
[row.id, row.channel]));
|
||||
|
||||
try {
|
||||
var media = CustomEmbedFilter(row.id);
|
||||
|
||||
all.push(Q.nfcall(db.channels.addToLibrary, row.channel, media));
|
||||
} catch(e) {
|
||||
console.error("WARNING: Unable to convert " + row.id);
|
||||
}
|
||||
});
|
||||
|
||||
Q.allSettled(all).then(function () {
|
||||
Logger.syslog.log("Converted custom embeds.");
|
||||
cb();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ Media.prototype = {
|
|||
type: this.type,
|
||||
meta: {
|
||||
direct: this.meta.direct,
|
||||
gpdirect: this.meta.gpdirect,
|
||||
restricted: this.meta.restricted,
|
||||
codec: this.meta.codec,
|
||||
bitrate: this.meta.bitrate,
|
||||
|
|
Loading…
Reference in New Issue