This commit is contained in:
UKDTOM 2021-05-01 21:32:17 +02:00
parent 41f2e220ef
commit 4d36434ad6
6 changed files with 58 additions and 172 deletions

View file

@ -195,6 +195,7 @@
"SecLibraries": "Libraries",
"SecMovies": "Movies",
"SecPhotos": "Photos",
"SecPlaylists": "Playlists",
"SecPlaylistAudio": "Audio",
"SecPlaylistVideo": "Video",
"SecPlaylistPhoto": "Photo",

View file

@ -163,15 +163,14 @@
log.debug(`Customlevel ${this.selCustLevel} selected`);
if (this.selCustLevel != 'NewLevel'){
// Get fields from config.json file
const revType = et.getLibTypeName(this.selMediaType);
let custLevel = wtconfig.get(`ET.CustomLevels.${revType}.level.${this.selCustLevel}`)
let custLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`)
// Do we need to export posters?
if ( wtconfig.get(`ET.CustomLevels.${revType}.Posters.${this.selCustLevel}`, false) )
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, false) )
{
custLevel.push("Export Posters");
}
// Do we need to export art?
if ( wtconfig.get(`ET.CustomLevels.${revType}.Art.${this.selCustLevel}`, false) )
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, false) )
{
custLevel.push("Export Art");
}
@ -239,24 +238,24 @@
// Hide Modal box
this.$refs['showNewLevel'].hide();
// Get current level names
const revSelMediaType = et.getLibTypeName(this.selMediaType);
let curLevels = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.levels`);
//const revSelMediaType = et.getLibTypeName(this.selMediaType);
let curLevels = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.levels`);
// Add new level to JSON
curLevels[this.NewLevelName] = this.NewLevelName;
// Save
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.levels`, curLevels);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.levels`, curLevels);
// Get current level counts
let curLevelCount = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.LevelCount`);
let curLevelCount = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.LevelCount`);
// Add new level to JSON
curLevelCount[this.NewLevelName] = 0;
// Save
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount`, curLevelCount);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount`, curLevelCount);
// Get current level names
let curLevel = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level`);
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level`);
// Add new level to JSON
curLevel[this.NewLevelName] = [];
// Save
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.level`, curLevel);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.level`, curLevel);
// Update combobox
this.genExportLevels();
//this.exportLevels;
@ -268,8 +267,9 @@
var fields = def['fields'];
// Release def memory again
def = null;
const revSelMediaType = et.getLibTypeName(this.selMediaType);
const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`);
//const revSelMediaType = et.getLibTypeName(this.selMediaType);
//const levelFields = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level.${this.selCustLevel}`);
const levelFields = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`);
let curLevel = 0;
levelFields.forEach(function (item) {
// Get field level
@ -279,8 +279,8 @@
curLevel = count;
}
});
log.info(`LevelCount for "${this.selCustLevel}" of the type "${revSelMediaType}" was calculated as:${curLevel}`);
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.LevelCount.${this.selCustLevel}`, curLevel);
log.info(`LevelCount for "${this.selCustLevel}" of the type "${this.selMediaType}" was calculated as:${curLevel}`);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`, curLevel);
},
changeType: function() {
// Triggers when lib type is changed
@ -292,14 +292,14 @@
this.fieldList = [];
},
deleteCustomLevel() {
const revSelCustLevel = et.getLibTypeName(this.selMediaType);
//const revSelCustLevel = et.getLibTypeName(this.selMediaType);
log.info(`User confirmed to delete custom level: ${this.selCustLevel}`);
this.$refs['confirmDeleteLevel'].hide();
wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.levels.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.LevelCount.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.level.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.Posters.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${revSelCustLevel}.Art.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.levels.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.LevelCount.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`);
wtconfig.delete(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`);
this.genExportLevels();
this.resultList = [];
},
@ -322,15 +322,14 @@
result.push(this.resultList[k].name);
}
}
const revSelMediaType = et.getLibTypeName(this.selMediaType);
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Posters.${this.selCustLevel}`, bExportPosters);
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.Art.${this.selCustLevel}`, bExportArt);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, bExportPosters);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, bExportArt);
// Get current level names
let curLevel = wtconfig.get(`ET.CustomLevels.${revSelMediaType}.level`);
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level`);
// Add new level to JSON
curLevel[this.selCustLevel] = result;
log.info(`Saving custom level ${this.selCustLevel} as ${JSON.stringify(result)}`)
wtconfig.set(`ET.CustomLevels.${revSelMediaType}.level`, curLevel);
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.level`, curLevel);
// Now we need to update levelcount for the level
this.updateLevelCount();
alert( i18n.t("Modules.ET.Custom.AlertSaved"));

View file

@ -189,65 +189,16 @@
selLevel: async function(){
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
},
/*
selLibrary: async function(){
if (['libraryInfo', 'playlistInfo'].indexOf(this.selMediaType) > -1)
{
this.btnDisable = false;
this.selMediaType = '';
this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
this.selLevel = 'all';
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
this.selPType = '';
this.$store.commit("UPDATE_SELECTEDPLISTTYPE", this.selPType);
}
else
{
this.btnDisable=!(this.selLibrary!=='Loading...' && this.selLevel!=='');
}
},
*/
/*
selMediaType: async function(){
if (['libraryInfo', 'playlistInfo'].indexOf(this.selMediaType) > -1)
{
this.btnDisable = false
}
else
{
this.btnDisable=!(this.selLibrary!=='Loading...' && this.selLevel!=='');
}
this.pListGrpDisabled = (this.selMediaType == 'playlist');
},
*/
selectedServerAddressUpdateInProgress: async function(){
this.selLibraryWait = false;
},
/*
selLevel: async function(){
if (['libraryInfo', 'playlistInfo'].indexOf(this.selMediaType) > -1)
{
this.btnDisable = false
}
else
{
this.btnDisable=!(this.selLibrary!=='Loading...' && this.selLevel!=='');
}
},
*/
selPType: async function(){
this.$store.commit("UPDATE_SELECTEDPLISTTYPE", this.selPType);
}
},
created() {
log.info("ET Created");
//this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
this.$store.commit("UPDATE_EXPORTSTATUS", i18n.t("Modules.ET.Status.Idle"));
// this.$store.commit("UPDATE_SELECTEDPLISTTYPE", this.selPType);
this.checkSrvSelected();
},
computed: {
@ -261,6 +212,11 @@
this.$store.commit("UPDATE_EXPORTLEVEL", 'all');
return false;
}
else if (this.selExpTypeSec == et.ETmediaType.Playlists)
{
this.$store.commit("UPDATE_EXPORTLEVEL", 'all');
return false;
}
else
{
return true;

View file

@ -119,6 +119,10 @@ const et = new class ET {
{
"text": i18n.t('Modules.ET.optExpType.SecPlaylistPhoto'),
"value": this.ETmediaType.Playlist_Photo
},
{
"text": i18n.t('Modules.ET.optExpType.SecPlaylists'),
"value": this.ETmediaType.Playlists
}
],
1001: [
@ -136,34 +140,17 @@ const et = new class ET {
// Find LibType steps
const step = wtconfig.get("PMS.ContainerSize." + libType, 20)
log.debug(`Got Step size as: ${step}`)
let libSize, libKey, element
let libKey, element
// Get Section Key
libKey = await et.getSectionKey({libName: sectionName, baseURL: baseURL, accessToken: accessToken})
log.debug(`Got SectionKey as: ${libKey}`)
//if (libType != 'libraryInfo')
//if (['libraryInfo', 'playlistInfo'].indexOf(libType) < 0)
if ('playlistInfo' == libType)
{
log.info(`Starting getSectionData with Name: "${sectionName}" and with a type of: "${libType}" and a sec type of: "${libTypeSec}"`)
// Get the size of the library
libSize = await et.getSectionSizeByKey({sectionKey: libKey, baseURL: baseURL, accessToken: accessToken, libType: libType})
log.debug(`Got Section size as: ${libSize}`);
}
else
{
console.log('Ged 6 not PList')
element = '/library/sections/all';
}
// Now read the fields and level defs
// Current item
let idx = 0
// Now let's walk the section
let chuncks, postURI
let size
console.log('Ged 22', libType)
do {
if (libType == et.ETmediaType.Photo)
{
@ -247,20 +234,15 @@ const et = new class ET {
getRealLevelName(level, libType) {
// First get the real name of the level, and not just the display name
let levelName
console.log('Ged 11', level, '*', libType, '*')
if (['libraryInfo', 'playlistInfo'].indexOf(libType) > -1)
//if (et.isPlaylist( libType ))
if ([ et.ETmediaType.Libraries, et.ETmediaType.Playlists].indexOf(libType) > -1)
{
levelName = 'all';
}
else
{
console.log('Ged 11-2')
if (libType == et.ETmediaType.Playlist)
{
console.log('Ged 11-3')
libType = store.getters.getSelectedLibTypeSec.toString();
//libType = libType + '-' + (et.RevETmediaType[store.getters.getSelectedLibTypeSec]).toString().toLowerCase();
}
levelName = defLevels[libType]['levels'][level]
if (levelName == undefined)
@ -314,21 +296,16 @@ const et = new class ET {
}
getLevelDisplayName(level, libType){
console.log('Ged 3', level, '*', libType, '*')
// return displayname for the buildin levels
if (libType == et.ETmediaType.Playlist)
{
libType = store.getters.getSelectedLibTypeSec;
}
if (libType == et.ETmediaType.Libraries)
{
level = 'all'
// libType = 'libraryInfo';
}
const levels = et.getLevels(libType)
console.log('Ged 3-2', levels, '*')
let result = '';
loop1:
for(var key in levels){
@ -338,15 +315,11 @@ const et = new class ET {
break loop1;
}
}
console.log('Ged 3-2-1', result, '*')
if ( result == '')
{
console.log('Ged 3-3-0', libType, '*')
// We need to check custom levels
console.log('Ged 3-3-0-1', et.RevETmediaType[libType])
//const customLevels = et.getCustomLevels(et.RevETmediaType[libType])
const customLevels = et.getCustomLevels(libType)
console.log('Ged 3-3-1', customLevels, '*')
loop2:
for(key in customLevels){
if ( customLevels[key] == level)
@ -372,21 +345,13 @@ const et = new class ET {
return result;
}
getLevelFields(level, libType, pListType) {
getLevelFields(level, libType) {
// return fields in a level
console.log('Ged 7', level, '*', libType, '*', pListType, '*')
const out = []
if (libType == et.ETmediaType.Playlist)
{
//pListType = (et.RevETmediaType[store.getters.getSelectedLibTypeSec]).toString().toLowerCase();
//libType = libType + '-' + (et.RevETmediaType[store.getters.getSelectedLibTypeSec]).toString().toLowerCase();
libType = store.getters.getSelectedLibTypeSec;
}
if (libType == 'libraries')
{
pListType = (et.RevETmediaType[store.getters.getSelectedLibTypeSec]).toString().toLowerCase();
libType = 'libraryInfo';
}
let realName = et.getRealLevelName(level, libType);
log.debug(`RealName is ${realName}`);
// We need to load fields and defs into def var
@ -441,11 +406,7 @@ const et = new class ET {
// code block
log.error(`Unknown libtype: "${libType}" or level: "${level}" in "getLevelFields"`);
}
console.log('Ged 7-0', libType)
console.log('Ged 7-1', JSON.stringify(def))
console.log('Ged 7-1-1', JSON.stringify(def[libType.toString()]))
let levels = def[libType.toString()]['level'][realName];
console.log('Ged 7-2', JSON.stringify(levels))
if (levels == undefined)
{
// We are dealing with a custom level
@ -461,8 +422,6 @@ const et = new class ET {
// this will return number of calls needed
if (libType == et.ETmediaType.Playlist)
{
console.log('Ged 99 playlist', libType)
//libType = libType + '-' + this.RevETmediaType[store.getters.getSelectedLibTypeSec].toLowerCase();
libType = store.getters.getSelectedLibTypeSec.toString();
}
else if (libType == et.ETmediaType.Libraries)
@ -476,14 +435,6 @@ const et = new class ET {
getLevels(libType) {
// Returns an json of levels for a selected type og medias, like 'movie'
console.log('Ged 8', libType, '*')
const lookupType = libType.toString()
console.log('Ged 8-0', lookupType, '*')
//console.log('Ged 8-1', (et.RevETmediaType[libType]));
// console.log('Ged 8-2', (et.RevETmediaType[libType]).toLowerCase());
console.log('Ged 8-3', JSON.stringify(defLevels))
console.log('Ged 8-4', JSON.stringify(defLevels[lookupType]))
console.log('Ged 8-5', JSON.stringify(defLevels[libType]['levels']))
const levels = defLevels[libType]['levels']
log.debug(`ET LevelNames: ${JSON.stringify(levels)}`);
return levels
@ -550,10 +501,10 @@ const et = new class ET {
}
getFieldsKeyVal( libType, level, pListType) {
getFieldsKeyVal( libType, level) {
// Get fields for level
let fields
fields = et.getLevelFields(level, libType, pListType)
fields = et.getLevelFields(level, libType)
const out = []
fields.forEach(element => {
const item = {}
@ -563,9 +514,9 @@ const et = new class ET {
return out
}
getFieldsKeyValType( libType, level, pListType) {
getFieldsKeyValType( libType, level) {
// Get field and type for level
const fields = et.getLevelFields(level, libType, pListType)
const fields = et.getLevelFields(level, libType)
const out = []
fields.forEach(element => {
const item = {}
@ -617,13 +568,13 @@ const et = new class ET {
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Artist.json')));
break;
case et.ETmediaType.Album:
// code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Album.json')));
break;
// code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Album.json')));
break;
case et.ETmediaType.Track:
// code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Track.json')));
break;
// code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Track.json')));
break;
case et.ETmediaType.Photo:
// code block
typeFields = JSON.parse(JSON.stringify(require('./../defs/def-Photo.json')));
@ -644,25 +595,16 @@ const et = new class ET {
// code block
}
// Get all the fields keys
let filteredFields;
if (this.isPlaylist(libType))
{
filteredFields = JSONPath({path: '$.playlist-' + et.RevETmediaType[libType].toLowerCase() + '.level.all.*', json: typeFields});
}
else
{
filteredFields = JSONPath({path: '$.' + et.RevETmediaType[libType].toLowerCase() + '.level.all.*', json: typeFields});
}
const filteredFields = JSONPath({path: '$.' + libType.toString() + '.level.all.*', json: typeFields});
// Sort them, and add an index as well, so drageble is happy
return filteredFields.sort().map((name, index) => {
return { name, order: index + 1 };
});
}
getFields( libType, level, pListType) {
getFields( libType, level) {
// Get field and type for level
const fields = et.getLevelFields(level, libType, pListType)
const fields = et.getLevelFields(level, libType)
const out = []
fields.forEach(element => {
const item = {}
@ -752,11 +694,11 @@ const excel2 = new class Excel {
return sheet
}
GetHeader(Level, libType, pListType) {
GetHeader(Level, libType) {
const columns = []
log.verbose(`GetHeader level: ${Level} - libType: ${libType}`)
// Get level fields
const fields = et.getLevelFields(Level, libType, pListType)
const fields = et.getLevelFields(Level, libType)
for (var i=0; i<fields.length; i++) {
log.verbose(`Column: ${fields[i]}`)
columns.push(fields[i])
@ -764,11 +706,11 @@ const excel2 = new class Excel {
return columns
}
async AddHeader(Sheet, Level, libType, pListType) {
async AddHeader(Sheet, Level, libType) {
const columns = []
log.verbose(`AddHeader level: ${Level} - libType: ${libType}`)
// Get level fields
const fields = et.getLevelFields(Level, libType, pListType)
const fields = et.getLevelFields(Level, libType)
for (var i=0; i<fields.length; i++) {
log.verbose('Column: ' + fields[i] + ' - ' + fields[i])
let column = { header: fields[i], key: fields[i], width: 5 }
@ -792,9 +734,6 @@ const excel2 = new class Excel {
}
async getFileName({ Library, Level, Type, Module, exType }){
console.log('Ged 13', exType, '*')
console.log('Ged 13-2', et.RevETmediaType[exType.toString()], '*')
//console.log('Ged 13-3', this.ETmediaType[exType], '*')
const dateFormat = require('dateformat');
const OutDir = wtconfig.get('General.ExportPath');
const timeStamp=dateFormat(new Date(), "yyyy.mm.dd_h.MM.ss");
@ -1398,11 +1337,11 @@ const excel2 = new class Excel {
let counter = 1;
const totalSize = JSONPath({path: '$..totalSize', json: sectionData[0]});
let jPath, sectionChunk;
if (libType == 'libraries')
if (libType == et.ETmediaType.Libraries)
{
jPath = "$.MediaContainer.Directory[*]";
}
else if (libType == 'playlistInfo')
else if (libType == et.ETmediaType.Playlists)
{
jPath = "$.MediaContainer.Metadata[*]";
}

View file

@ -392,17 +392,10 @@ const wtutils = new class WTUtils {
wtconfig.set('ET.CustomLevels.2002.level', {})
}
// rename cust levels
console.log('Ged 9999', wtconfig.get('ET.CustomLevels.movie', 'N/A'))
console.log('Ged 9999-1', wtconfig.get('ET.CustomLevels.gummiged', 'N/A'))
if ( wtconfig.get('ET.CustomLevels.movie', 'N/A') != 'N/A' ){
console.log('Ged 9999-2 found movie')
wtconfig.set('ET.CustomLevels.1', wtconfig.get('ET.CustomLevels.movie', 'N/A'));
wtconfig.delete('ET.CustomLevels.movie');
}
else
{
console.log('Ged 9999-3 movie NOT FOUND')
}
if ( wtconfig.get('ET.CustomLevels.show', 'N/A') != 'N/A' ){
wtconfig.set('ET.CustomLevels.2', wtconfig.get('ET.CustomLevels.show', 'N/A'));
wtconfig.delete('ET.CustomLevels.show');

View file

@ -58,16 +58,14 @@ const actions = {
//var pListType = getters.getSelectedPListType;
let levelName;
var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections);
if (['libraryInfo', 'playlistInfo'].indexOf(libType) > -1)
if ([ et.ETmediaType.Libraries, et.ETmediaType.Playlists].indexOf(libType) > -1)
{
levelName = 'All'
}
else
{
console.log('Ged 9-0', getters.getSelectedExportLevel, '*', libType, '*')
levelName = et.getLevelDisplayName(getters.getSelectedExportLevel, libType);
}
console.log('Ged 9 start create', levelName, '*')
excel2.createOutFile( {
libName: libName,
level: levelName,