This commit is contained in:
UKDTOM 2020-08-06 15:58:52 +02:00
parent 50d6e5af7e
commit 21d4589ce9
9 changed files with 156 additions and 96 deletions

View file

@ -37,7 +37,7 @@ export default {
}, },
onChange(event) { onChange(event) {
log.info('language set to:' + event.target.value); log.info('language set to:' + event.target.value);
wtconfig.set('general.language', event.target.value); wtconfig.set('General.language', event.target.value);
} }
} }
} }

View file

@ -60,8 +60,8 @@ import {wtconfig} from '../wtutils';
var userName = ""; var userName = "";
let isRemember = false let isRemember = false
if(wtconfig.get('general.rememberlastusername')){ if(wtconfig.get('General.rememberlastusername')){
userName = wtconfig.get('general.username') userName = wtconfig.get('General.username')
isRemember = true isRemember = true
} }
@ -85,11 +85,11 @@ export default {
if(this.checkbox){ if(this.checkbox){
log.verbose(`Save username is: ${this.checkbox}`) log.verbose(`Save username is: ${this.checkbox}`)
wtconfig.set('general.rememberlastusername', true ) wtconfig.set('General.rememberlastusername', true )
wtconfig.set('general.username', this.input.username) wtconfig.set('General.username', this.input.username)
} else { } else {
log.verbose(`Save username is: ${this.checkbox}`) log.verbose(`Save username is: ${this.checkbox}`)
wtconfig.set('general.rememberlastusername', false ) wtconfig.set('General.rememberlastusername', false )
} }
}, },
danger(){ danger(){

View file

@ -60,9 +60,9 @@
:disabled="btnDisable == true" :disabled="btnDisable == true"
>{{ $t("Modules.ET.HExportMedia") }}</b-button> >{{ $t("Modules.ET.HExportMedia") }}</b-button>
</div> </div>
<label id="status" class="form-label" v-show='status'> <div name="status">
{{ status }} {{ count }}
</label> </div>
</section> </section>
@ -71,6 +71,7 @@
<script> <script>
import { et } from "./et"; import { et } from "./et";
import i18n from '../../../i18n'; import i18n from '../../../i18n';
import store from '../../../store';
const log = require("electron-log"); const log = require("electron-log");
export default { export default {
data() { data() {
@ -86,13 +87,13 @@
{ text: 'Artist', value: 'artist', disabled: true }, { text: 'Artist', value: 'artist', disabled: true },
{ text: 'Photos', value: 'photo', disabled: true }, { text: 'Photos', value: 'photo', disabled: true },
{ text: 'Other Videos', value: 'other', disabled: true } { text: 'Other Videos', value: 'other', disabled: true }
], ]
status: "Idle"
}; };
}, },
created() { created() {
log.info("ET Created"); log.info("ET Created");
this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType); this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
this.$store.commit("UPDATE_EXPORTSTATUS", i18n.t("Modules.ET.Status.Idle"));
this.fetchSelection(); this.fetchSelection();
}, },
computed: { computed: {
@ -155,6 +156,9 @@
}); });
item['options']=options; item['options']=options;
return options; return options;
},
count () {
return this.$i18n.t("Modules.ET.Status.Status") + store.getters.getExportStatus
} }
}, },
methods: { methods: {
@ -176,16 +180,13 @@
selectExportLevel: function() { selectExportLevel: function() {
this.enableBtnExport(); this.enableBtnExport();
}, },
callbackStatus: function(statusTxt) {
this.status = statusTxt;
console.log('Status: ' + statusTxt)
},
getMedia() { getMedia() {
log.info("getMedia Called"); log.info("getMedia Called");
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel); this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary); this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary);
this.callbackStatus('Starting Export'); this.$store.commit("UPDATE_EXPORTSTATUS", "Stating to Export");
this.$store.dispatch("getMediaMovies"); this.$store.dispatch("exportMedias");
}, },
fetchSelection() { fetchSelection() {
log.debug("fetchSelection"); log.debug("fetchSelection");

File diff suppressed because one or more lines are too long

View file

@ -4,7 +4,8 @@ const log = require('electron-log');
const defpostURI = '?checkFiles=1&includeRelated=0&includeExtras=1&includeBandwidths=1&includeChapters=1' const defpostURI = '?checkFiles=1&includeRelated=0&includeExtras=1&includeBandwidths=1&includeChapters=1'
import {wtconfig, wtutils} from '../../../wtutils' import {wtconfig, wtutils} from '../../../wtutils';
import i18n from '../../../i18n';
import filesize from 'filesize'; import filesize from 'filesize';
var path = require("path"); var path = require("path");
@ -14,6 +15,7 @@ const fetch = require('node-fetch');
const {JSONPath} = require('jsonpath-plus'); const {JSONPath} = require('jsonpath-plus');
import axios from 'axios' import axios from 'axios'
import store from '../../../store';
const et = new class ET { const et = new class ET {
@ -463,7 +465,7 @@ const excel2 = new class Excel {
} }
async addRowToTmp( { libType, level, data, stream }) { async addRowToTmp( { libType, level, data, stream }) {
log.debug(`Start addRowToTmp. libType: ${libType} - level: ${level}`) // log.debug(`Start addRowToTmp. libType: ${libType} - level: ${level}`)
let date, year, month, day, hours, minutes, seconds let date, year, month, day, hours, minutes, seconds
const fields = et.getFields( libType, level) const fields = et.getFields( libType, level)
let lookup, val, array, i, valArray, valArrayVal, subType, subKey let lookup, val, array, i, valArray, valArrayVal, subType, subKey
@ -582,7 +584,7 @@ const excel2 = new class Excel {
} }
// Remove first character // Remove first character
result = str.substr(1); result = str.substr(1);
stream.write( result + "\n"); await stream.write( result + "\n");
} }
async addRowToSheet(sheet, libType, level, data) { async addRowToSheet(sheet, libType, level, data) {
@ -715,58 +717,61 @@ const excel2 = new class Excel {
log.debug(`header: ${header}`); log.debug(`header: ${header}`);
// Now we need to find out how many calls to make // Now we need to find out how many calls to make
const call = await et.getLevelCall(libType, level) const call = await et.getLevelCall(libType, level)
// Get all the items in small chuncks
var sectionData = await et.getSectionData({sectionName: libName, baseURL: baseURL, accessToken: accessToken, libType: libType})
outType, call outType, call
log.verbose('*** Returned from section was ***')
log.verbose(JSON.stringify(sectionData))
log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`)
// Open a file stream // Open a file stream
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp' }) const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp' })
var fs = require('fs'); var fs = require('fs');
var stream = fs.createWriteStream(tmpFile, {flags:'a'}); var stream = fs.createWriteStream(tmpFile, {flags:'a'});
// Get all the items in small chuncks
var sectionData = await et.getSectionData({sectionName: libName, baseURL: baseURL, accessToken: accessToken, libType: libType})
log.verbose('*** Returned from section was ***')
//log.verbose(JSON.stringify(sectionData))
log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`)
let item
for (var x=0; x<sectionData.length; x++) for (var x=0; x<sectionData.length; x++)
{ {
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.Processing-Chunk', {current: x, total: sectionData.length}))
var sectionChunk = await JSONPath({path: "$.MediaContainer.Metadata[*]", json: sectionData[x]}); var sectionChunk = await JSONPath({path: "$.MediaContainer.Metadata[*]", json: sectionData[x]});
//for (var n=0; n<sectionChunk.length; n++)
for (var item of sectionChunk)
{
if ( call == 1 ) if ( call == 1 )
{ {
//await excel2.addRowToSheet(sheet, libType, level, item) for (item of sectionChunk){
await excel2.addRowToTmp( { libType: libType, level: level, data: item, stream: stream } ); await excel2.addRowToTmp( { libType: libType, level: level, data: item, stream: stream } );
} }
else
{
// Get rating key for each item
const url = await JSONPath({path: '$..ratingKey', json: item});
log.verbose('Item to lookup are: ' + url)
const urlWIthPath = '/library/metadata/' + url
const contents = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: urlWIthPath});
const detailedItem = await JSONPath({path: '$.MediaContainer.Metadata[0]', json: contents});
//log.verbose('detailedItem: ' + JSON.stringify(detailedItem[0]))
//await excel2.addRowToSheet(sheet, libType, level, detailedItem[0])
await excel2.addRowToTmp( { libType: libType, level: level, data: detailedItem[0], stream: stream } );
}
} }
else
{
// Get ratingKeys in the chunk
const urls = await JSONPath({path: '$..ratingKey', json: sectionChunk});
let urlStr = urls.join(',')
log.verbose(`Items to lookup are: ${urlStr}`)
store.commit("UPDATE_EXPORTSTATUS", i18n.t('Modules.ET.Status.Processing-Chunk-Detailed', {current: x, total: sectionData.length, urlStr: urlStr}))
//store.commit("UPDATE_EXPORTSTATUS", `Processing chunk ${x} of ${sectionData.length}.\nItems to export: \n${urlStr}`)
const urlWIthPath = '/library/metadata/' + urlStr
log.verbose(`Items retrieved`)
const contents = await et.getItemData({baseURL: baseURL, accessToken: accessToken, element: urlWIthPath});
const contentsItems = await JSONPath({path: '$.MediaContainer.Metadata[*]', json: contents});
//await excel2.addRowsToTmp( { libType: libType, level: level, data: contentsItems, stream: stream } );
for (item of contentsItems){
await excel2.addRowToTmp( { libType: libType, level: level, data: item, stream: stream } );
}
}
} }
stream.end(); stream.end();
stream.close();
stream.destroy();
// Rename to real file name // Rename to real file name
var newFile = tmpFile.replace('.tmp', 'csv') var newFile = tmpFile.replace('.tmp', '.csv')
fs.rename(tmpFile, newFile, function (err) { fs.rename(tmpFile, newFile, function (err) {
if (err) throw err; if (err) throw err;
console.log('renamed complete'); console.log('renamed complete');
}); });
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`)
// Save Excel file // Save Excel file
// const result = await excel2.SaveWorkbook(workBook, libName, level, outType) // const result = await excel2.SaveWorkbook(workBook, libName, level, outType)

View file

@ -23,6 +23,8 @@ Vue.use(BootstrapVue);
// Logging start // Logging start
// Remember to define log in all components where its used, as in below // Remember to define log in all components where its used, as in below
const log = require('electron-log'); const log = require('electron-log');
@ -43,8 +45,13 @@ log.info('*********************************')
log.info('Starting ' + wtutils.AppName + ' Version:' + wtutils.AppVersion); log.info('Starting ' + wtutils.AppName + ' Version:' + wtutils.AppVersion);
// Logging ended // Logging ended
if (wtconfig.get("general.version", "") != wtutils.AppVersion){
// Config file out of date, so prepopulate with default values if missing
wtutils.UpdateConfigFile()
}
// Get saved language to use, and default to en // Get saved language to use, and default to en
i18n.locale = wtconfig.get('general.language', 'en') i18n.locale = wtconfig.get('General.language', 'en')
Vue.config.productionTip = false Vue.config.productionTip = false
// App Menu Bar // App Menu Bar

View file

@ -14,17 +14,9 @@ const vuexLocal = new VuexPersistence({
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
CONTAINERSIZEMOVIES: "30",
CONTAINERSIZETV: "20",
CONTAINERSIZEEPISODES: "30",
CONTAINERSIZEAUDIO: "10",
CONTAINERSIZEPHOTO: "20",
PMSTIMEOUT: "20"
}, },
mutations: {}, mutations: {},
getters: { getters: {
getContainerSizeMovies: state => state.CONTAINERSIZEMOVIES
}, },
actions: {}, actions: {},
modules: { modules: {

View file

@ -8,8 +8,8 @@ const state = {
mediaData: [], mediaData: [],
selectedSection : "", selectedSection : "",
selectedExportLevel: "", selectedExportLevel: "",
selectedLibType: "" selectedLibType: "",
exportStatus: ""
}; };
const mutations = { const mutations = {
@ -24,6 +24,9 @@ const mutations = {
UPDATE_EXPORTLEVEL(state, payload) { UPDATE_EXPORTLEVEL(state, payload) {
state.selectedExportLevel = payload state.selectedExportLevel = payload
}, },
UPDATE_EXPORTSTATUS(state, payload) {
state.exportStatus = payload
},
UPDATE_EXPORTLEVELS(state, payload) { UPDATE_EXPORTLEVELS(state, payload) {
state.exportLevels = payload state.exportLevels = payload
}, },
@ -43,9 +46,9 @@ const actions = {
commit('UPDATE_SECTIONS', await et.getSections(baseURL, accessToken)) commit('UPDATE_SECTIONS', await et.getSections(baseURL, accessToken))
}, },
//getMediaMovies({ getters, commit }) { //getMediaMovies({ getters, commit }) {
getMediaMovies({ commit, getters }) { exportMedias({ commit, getters }) {
const testimp3 = require('../../components/modules/ExportTools/Samples/testimp3.json') //const testimp3 = require('../../components/modules/ExportTools/Samples/testimp3.json')
// Vars OK // Vars OK
var baseURL = getters.getSlectedServerAddress var baseURL = getters.getSlectedServerAddress
@ -64,7 +67,7 @@ const actions = {
var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections) var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections)
libName, levelName, libType, 'xlsx', testimp3, baseURL, accessToken libName, levelName, libType, 'xlsx', baseURL, accessToken
excel2 excel2
//excel2.createOutFile( libName, levelName, libType, 'xlsx', testimp3, baseURL, accessToken ); //excel2.createOutFile( libName, levelName, libType, 'xlsx', testimp3, baseURL, accessToken );
@ -148,7 +151,8 @@ const getters = {
getSelectedSection: state => state.selectedSection, getSelectedSection: state => state.selectedSection,
getSelectedExportLevel: state => state.selectedExportLevel, getSelectedExportLevel: state => state.selectedExportLevel,
getLibType: state => state.selectedLibType, getLibType: state => state.selectedLibType,
getExportLevels: state => state.exportLevels getExportLevels: state => state.exportLevels,
getExportStatus: state => state.exportStatus
}; };
const etModule = { const etModule = {

View file

@ -104,7 +104,7 @@ const wtutils = new class WTUtils {
{ {
localHome = __dirname.replace('app.asar', 'locales'); localHome = __dirname.replace('app.asar', 'locales');
} }
var last = wtconfig.get('general.transfilescopied', "0") var last = wtconfig.get('General.transfilescopied', "0")
if (!(last == wtutils.AppVersion)) if (!(last == wtutils.AppVersion))
{ {
log.debug('We need to copy translation strings over') log.debug('We need to copy translation strings over')
@ -124,10 +124,72 @@ const wtutils = new class WTUtils {
if (err) return console.error(err) if (err) return console.error(err)
}); });
} }
wtconfig.set('general.transfilescopied', wtutils.AppVersion) wtconfig.set('General.transfilescopied', wtutils.AppVersion)
} }
} }
UpdateConfigFile() {
// Update config file with defaults if missing
console.log('Updating config file')
// General section
if ( wtconfig.get('General.username', 'N/A') == 'N/A' ){
wtconfig.set('General.username', '')
}
if ( wtconfig.get('General.language', 'N/A') == 'N/A' ){
wtconfig.set('General.language', 'en')
}
if ( wtconfig.get('General.rememberlastusername', 'N/A') == 'N/A' ){
wtconfig.set('General.rememberlastusername', false)
}
if ( wtconfig.get('General.transfilescopied', 'N/A') == 'N/A' ){
wtconfig.set('General.transfilescopied', '')
}
// Log settings
if ( wtconfig.get('Log.maxSize', 'N/A') == 'N/A' ){
wtconfig.set('Log.maxSize', '10485760')
}
if ( wtconfig.get('Log.fileLevel', 'N/A') == 'N/A' ){
wtconfig.set('Log.fileLevel', 'info')
}
if ( wtconfig.get('Log.consoleLevel', 'N/A') == 'N/A' ){
wtconfig.set('Log.consoleLevel', 'info')
}
// PMS Settings
if ( wtconfig.get('PMS.TimeOut', 'N/A') == 'N/A' ){
wtconfig.set('PMS.TimeOut', 20)
}
if ( wtconfig.get('PMS.ContainerSize.artist', 'N/A') == 'N/A' ){
wtconfig.set('PMS.ContainerSize.artist', 10)
}
if ( wtconfig.get('PMS.ContainerSize.episode', 'N/A') == 'N/A' ){
wtconfig.set('PMS.ContainerSize.episode', 20)
}
if ( wtconfig.get('PMS.ContainerSize.movie', 'N/A') == 'N/A' ){
wtconfig.set('PMS.ContainerSize.movie', 20)
}
if ( wtconfig.get('PMS.ContainerSize.photo', 'N/A') == 'N/A' ){
wtconfig.set('PMS.ContainerSize.photo', 20)
}
if ( wtconfig.get('PMS.ContainerSize.show', 'N/A') == 'N/A' ){
wtconfig.set('PMS.ContainerSize.show', 20)
}
// ET Settings
if ( wtconfig.get('ET.ArraySep', 'N/A') == 'N/A' ){
wtconfig.set('ET.ArraySep', ' - ')
}
if ( wtconfig.get('ET.ColumnSep', 'N/A') == 'N/A' ){
wtconfig.set('ET.ColumnSep', ',')
}
if ( wtconfig.get('ET.OutPath', 'N/A') == 'N/A' ){
wtconfig.set('ET.OutPath', '')
}
// All done, so stamp version number
wtconfig.set('General.version', wtutils.AppVersion)
}
/* set name(value) { /* set name(value) {
if (value.length < 4) { if (value.length < 4) {
alert("Name is too short."); alert("Name is too short.");