Convert custom embeds when loading playlist

This commit is contained in:
calzoneman 2015-06-30 09:38:19 -07:00
parent b34ea01c3d
commit a457ea6c8a
1 changed files with 12 additions and 3 deletions

View File

@ -7,6 +7,7 @@ var Config = require("../config");
var Flags = require("../flags"); var Flags = require("../flags");
var db = require("../database"); var db = require("../database");
var Logger = require("../logger"); var Logger = require("../logger");
var CustomEmbedFilter = require("../customembed").filter;
const MAX_ITEMS = Config.get("playlist.max-items"); const MAX_ITEMS = Config.get("playlist.max-items");
@ -109,6 +110,16 @@ PlaylistModule.prototype.load = function (data) {
var i = 0; var i = 0;
playlist.pos = parseInt(playlist.pos); playlist.pos = parseInt(playlist.pos);
playlist.pl.forEach(function (item) { playlist.pl.forEach(function (item) {
if (item.media.type === "cu" && item.media.id.indexOf("cu:") !== 0) {
try {
item.media = CustomEmbedFilter(item.media.id);
} catch (e) {
return;
}
} else if (item.media.type === "gd" || item.media.type === "gp") {
delete item.media.meta.gpdirect;
}
var m = new Media(item.media.id, item.media.title, item.media.seconds, var m = new Media(item.media.id, item.media.title, item.media.seconds,
item.media.type, item.media.meta || {}); item.media.type, item.media.meta || {});
var newitem = new PlaylistItem(m, { var newitem = new PlaylistItem(m, {
@ -132,10 +143,8 @@ PlaylistModule.prototype.load = function (data) {
PlaylistModule.prototype.save = function (data) { PlaylistModule.prototype.save = function (data) {
var arr = this.items.toArray().map(function (item) { var arr = this.items.toArray().map(function (item) {
/* Clear Google Docs and Vimeo meta */ /* Clear Google Docs/Google+ and Vimeo meta */
if (item.media && item.media.meta) { if (item.media && item.media.meta) {
delete item.media.meta.object;
delete item.media.meta.params;
delete item.media.meta.direct; delete item.media.meta.direct;
} }
return item; return item;