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) {
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 = "";
let isRemember = false
if(wtconfig.get('general.rememberlastusername')){
userName = wtconfig.get('general.username')
if(wtconfig.get('General.rememberlastusername')){
userName = wtconfig.get('General.username')
isRemember = true
}
@ -85,11 +85,11 @@ export default {
if(this.checkbox){
log.verbose(`Save username is: ${this.checkbox}`)
wtconfig.set('general.rememberlastusername', true )
wtconfig.set('general.username', this.input.username)
wtconfig.set('General.rememberlastusername', true )
wtconfig.set('General.username', this.input.username)
} else {
log.verbose(`Save username is: ${this.checkbox}`)
wtconfig.set('general.rememberlastusername', false )
wtconfig.set('General.rememberlastusername', false )
}
},
danger(){

View file

@ -59,10 +59,10 @@
icon-pack="fas"
:disabled="btnDisable == true"
>{{ $t("Modules.ET.HExportMedia") }}</b-button>
</div>
<label id="status" class="form-label" v-show='status'>
{{ status }}
</label>
</div>
<div name="status">
{{ count }}
</div>
</section>
@ -71,6 +71,7 @@
<script>
import { et } from "./et";
import i18n from '../../../i18n';
import store from '../../../store';
const log = require("electron-log");
export default {
data() {
@ -86,13 +87,13 @@
{ text: 'Artist', value: 'artist', disabled: true },
{ text: 'Photos', value: 'photo', disabled: true },
{ text: 'Other Videos', value: 'other', disabled: true }
],
status: "Idle"
]
};
},
created() {
log.info("ET Created");
this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
this.$store.commit("UPDATE_EXPORTSTATUS", i18n.t("Modules.ET.Status.Idle"));
this.fetchSelection();
},
computed: {
@ -155,6 +156,9 @@
});
item['options']=options;
return options;
},
count () {
return this.$i18n.t("Modules.ET.Status.Status") + store.getters.getExportStatus
}
},
methods: {
@ -173,19 +177,16 @@
this.$store.commit("UPDATE_SELECTEDLIBTYPE", this.selMediaType);
},
selectExportLevel: function() {
selectExportLevel: function() {
this.enableBtnExport();
},
callbackStatus: function(statusTxt) {
this.status = statusTxt;
console.log('Status: ' + statusTxt)
},
getMedia() {
log.info("getMedia Called");
this.$store.commit("UPDATE_EXPORTLEVEL", this.selLevel);
this.$store.commit("UPDATE_SELECTEDSECTION", this.selLibrary);
this.callbackStatus('Starting Export');
this.$store.dispatch("getMediaMovies");
this.$store.commit("UPDATE_EXPORTSTATUS", "Stating to Export");
this.$store.dispatch("exportMedias");
},
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'
import {wtconfig, wtutils} from '../../../wtutils'
import {wtconfig, wtutils} from '../../../wtutils';
import i18n from '../../../i18n';
import filesize from 'filesize';
var path = require("path");
@ -14,6 +15,7 @@ const fetch = require('node-fetch');
const {JSONPath} = require('jsonpath-plus');
import axios from 'axios'
import store from '../../../store';
const et = new class ET {
@ -463,12 +465,12 @@ const excel2 = new class Excel {
}
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
const fields = et.getFields( libType, level)
let lookup, val, array, i, valArray, valArrayVal, subType, subKey
let str = ''
let result = ''
let result = ''
for (var x=0; x<fields.length; x++) {
var name = Object.keys(fields[x]);
lookup = JSONPath({path: '$..key', json: fields[x]})[0];
@ -582,7 +584,7 @@ const excel2 = new class Excel {
}
// Remove first character
result = str.substr(1);
stream.write( result + "\n");
await stream.write( result + "\n");
}
async addRowToSheet(sheet, libType, level, data) {
@ -715,58 +717,61 @@ const excel2 = new class Excel {
log.debug(`header: ${header}`);
// Now we need to find out how many calls to make
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
log.verbose('*** Returned from section was ***')
log.verbose(JSON.stringify(sectionData))
log.verbose(`Amount of chunks in sectionData are: ${sectionData.length}`)
outType, call
// Open a file stream
const tmpFile = await excel2.getFileName({ Library: libName, Level: level, Type: 'tmp' })
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}`)
for (var x=0; x<sectionData.length; 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 )
{
//await excel2.addRowToSheet(sheet, libType, level, item)
let item
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]});
if ( call == 1 )
{
for (item of sectionChunk){
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.close();
stream.destroy();
// Rename to real file name
var newFile = tmpFile.replace('.tmp', 'csv')
var newFile = tmpFile.replace('.tmp', '.csv')
fs.rename(tmpFile, newFile, function (err) {
if (err) throw err;
console.log('renamed complete');
});
store.commit("UPDATE_EXPORTSTATUS", `Export finished. File:"${newFile}" created`)
// Save Excel file
// const result = await excel2.SaveWorkbook(workBook, libName, level, outType)

View file

@ -23,6 +23,8 @@ Vue.use(BootstrapVue);
// Logging start
// Remember to define log in all components where its used, as in below
const log = require('electron-log');
@ -43,8 +45,13 @@ log.info('*********************************')
log.info('Starting ' + wtutils.AppName + ' Version:' + wtutils.AppVersion);
// 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
i18n.locale = wtconfig.get('general.language', 'en')
i18n.locale = wtconfig.get('General.language', 'en')
Vue.config.productionTip = false
// App Menu Bar

View file

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

View file

@ -8,8 +8,8 @@ const state = {
mediaData: [],
selectedSection : "",
selectedExportLevel: "",
selectedLibType: ""
selectedLibType: "",
exportStatus: ""
};
const mutations = {
@ -23,7 +23,10 @@ const mutations = {
},
UPDATE_EXPORTLEVEL(state, payload) {
state.selectedExportLevel = payload
},
},
UPDATE_EXPORTSTATUS(state, payload) {
state.exportStatus = payload
},
UPDATE_EXPORTLEVELS(state, payload) {
state.exportLevels = payload
},
@ -43,9 +46,9 @@ const actions = {
commit('UPDATE_SECTIONS', await et.getSections(baseURL, accessToken))
},
//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
var baseURL = getters.getSlectedServerAddress
@ -64,7 +67,7 @@ const actions = {
var libName = et.getLibDisplayName(getters.getSelectedSection, getters.getPmsSections)
libName, levelName, libType, 'xlsx', testimp3, baseURL, accessToken
libName, levelName, libType, 'xlsx', baseURL, accessToken
excel2
//excel2.createOutFile( libName, levelName, libType, 'xlsx', testimp3, baseURL, accessToken );
@ -148,7 +151,8 @@ const getters = {
getSelectedSection: state => state.selectedSection,
getSelectedExportLevel: state => state.selectedExportLevel,
getLibType: state => state.selectedLibType,
getExportLevels: state => state.exportLevels
getExportLevels: state => state.exportLevels,
getExportStatus: state => state.exportStatus
};
const etModule = {

View file

@ -104,7 +104,7 @@ const wtutils = new class WTUtils {
{
localHome = __dirname.replace('app.asar', 'locales');
}
var last = wtconfig.get('general.transfilescopied', "0")
var last = wtconfig.get('General.transfilescopied', "0")
if (!(last == wtutils.AppVersion))
{
log.debug('We need to copy translation strings over')
@ -124,10 +124,72 @@ const wtutils = new class WTUtils {
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) {
if (value.length < 4) {
alert("Name is too short.");