mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2025-02-16 19:38:26 +00:00
#365-2 Now with sub range export
This commit is contained in:
parent
56460219cd
commit
19dc896f9b
3 changed files with 99 additions and 19 deletions
|
@ -251,7 +251,16 @@
|
|||
"ttExpLibrary": "Here you select the library to export",
|
||||
"ttExpTypeSec": "Here you select the sub type",
|
||||
"ttExpType": "Here you select the type of library you want to export",
|
||||
"SecPlaylists": "Playlists"
|
||||
"SecPlaylists": "Playlists",
|
||||
"itemStart": "The starting item (Normally 0)",
|
||||
"itemEnd": "The ending item (Normally the last item in the library)",
|
||||
"startStopDesc": "Here you have the option to define what item to start exporting with,",
|
||||
"startStopDesc2": "as well as specifying the item to end the export.",
|
||||
"startStopDesc3": "Use this to split export files into smaller chuncks (files) if needed.",
|
||||
"startStopDesc4": "We default to export everything.",
|
||||
"startStopStartingItem": "Item to start with",
|
||||
"startStopEndingItem": "Item to end with",
|
||||
"startStopTitle": "Limit Export"
|
||||
}
|
||||
},
|
||||
"About": {
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</b-form-row>
|
||||
<b-form-row> <!-- Select Export Level -->
|
||||
<b-col>
|
||||
<div>
|
||||
<div>
|
||||
<b-form-group id="etLevelGroup" v-bind:label="$t('Modules.ET.optExpType.lblExportLevel')" label-size="lg" label-class="font-weight-bold pt-0" :disabled=this.etLevelGroupDisabled>
|
||||
<b-tooltip target="etLevelGroup" triggers="hover">
|
||||
{{ $t('Modules.ET.optExpType.ttExpLevel') }}
|
||||
|
@ -82,12 +82,13 @@
|
|||
<div class="buttons"> <!-- Buttons -->
|
||||
<b-button
|
||||
type="is-primary"
|
||||
@click="getMedia"
|
||||
@click="showStartEnd"
|
||||
icon-left="fas fa-file-download"
|
||||
icon-pack="fas"
|
||||
:disabled="btnDisable == true"
|
||||
variant="success"
|
||||
>{{ $t("Modules.ET.optExpType.lblBtnExportMedia") }}</b-button>
|
||||
>
|
||||
{{ $t("Modules.ET.optExpType.lblBtnExportMedia") }}</b-button>
|
||||
</div>
|
||||
<br>
|
||||
<b-container fluid> <!-- Status -->
|
||||
|
@ -107,6 +108,26 @@
|
|||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
<b-modal ref="startEnd" hide-footer v-bind:title=this.startEnd>
|
||||
<div class="d-block">
|
||||
{{ this.startEndBody }}
|
||||
{{ this.startEndBody2 }}
|
||||
<br>
|
||||
{{ this.startEndBody3 }}
|
||||
<br>
|
||||
<br>
|
||||
{{ this.startEndBody4 }}
|
||||
<br>
|
||||
<br>
|
||||
<b-input-group id="itemStart" :prepend="$t('Modules.ET.optExpType.startStopStartingItem')" class="mt-3">
|
||||
<b-form-input id="itemStartNo" name="itemStartNo" type="number" class="form-control" v-model="itemStartNo" :min=0 :max=this.sectionMaxItems.toString() :disabled=false @change.native="setItemStartNo()"></b-form-input>
|
||||
</b-input-group>
|
||||
<b-input-group id="itemEnd" :prepend="$t('Modules.ET.optExpType.startStopEndingItem')" class="mt-3">
|
||||
<b-form-input id="itemEndNo" name="itemEndNo" type="number" class="form-control" v-model="itemEndNo" :disabled=false :min=this.itemStartNo.toString() :max=this.sectionMaxItems.toString() @change.native="setItemEndNo()"></b-form-input>
|
||||
</b-input-group>
|
||||
</div>
|
||||
<b-button class="mt-3" variant="success" block @click="getMedia">{{ this.startEndBtn }}</b-button>
|
||||
</b-modal>
|
||||
</div>
|
||||
</b-container>
|
||||
</template>
|
||||
|
@ -161,7 +182,16 @@
|
|||
pListGrpDisabled: true,
|
||||
etLibraryGroupDisabled: false,
|
||||
etLevelGroupDisabled: false,
|
||||
statusMsg: 'Idle'
|
||||
statusMsg: 'Idle',
|
||||
startEnd: i18n.t("Modules.ET.optExpType.startStopTitle"),
|
||||
startEndBody: i18n.t("Modules.ET.optExpType.startStopDesc"),
|
||||
startEndBody2: i18n.t("Modules.ET.optExpType.startStopDesc2"),
|
||||
startEndBody3: i18n.t("Modules.ET.optExpType.startStopDesc3"),
|
||||
startEndBody4: i18n.t("Modules.ET.optExpType.startStopDesc4"),
|
||||
startEndBtn: i18n.t("Modules.ET.optExpType.lblBtnExportMedia"),
|
||||
itemStartNo: etHelper.Settings.currentItem,
|
||||
itemEndNo: 0,
|
||||
sectionMaxItems: 0
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
|
@ -227,6 +257,36 @@
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
setItemStartNo: async function(){
|
||||
// Update settings with new start value
|
||||
etHelper.Settings.startItem = this.itemStartNo;
|
||||
},
|
||||
setItemEndNo: async function(){
|
||||
// Update settings with new start value
|
||||
if (Number(this.sectionMaxItems) < Number(this.itemEndNo)){
|
||||
this.itemEndNo = this.sectionMaxItems
|
||||
}
|
||||
etHelper.Settings.endItem = this.itemEndNo;
|
||||
},
|
||||
showStartEnd: async function(){
|
||||
// Will ask for a starting item as well as an ending item, then export
|
||||
// Start by getting the maximum and min items
|
||||
etHelper.Settings.currentItem = 0;
|
||||
etHelper.Settings.baseURL = this.$store.getters.getSelectedServerAddress;
|
||||
etHelper.Settings.accessToken = this.$store.getters.getSelectedServerToken;
|
||||
etHelper.Settings.totalItems = await etHelper.getSectionSize();
|
||||
this.itemEndNo = etHelper.Settings.totalItems;
|
||||
this.sectionMaxItems = this.itemEndNo;
|
||||
this.$refs['startEnd'].show();
|
||||
|
||||
|
||||
// getMedia()
|
||||
|
||||
},
|
||||
hideStartEnd: async function(){
|
||||
// Hide StartEnd modal
|
||||
this.$refs['startEnd'].hide();
|
||||
},
|
||||
async serverSelected() {
|
||||
etHelper.resetETHelper();
|
||||
let serverCheck = this.$store.getters.getSelectedServer;
|
||||
|
@ -369,6 +429,7 @@
|
|||
selExpTypeSecChanged: async function(){
|
||||
// Triggers when exp type is changed
|
||||
log.verbose(`Secondary export type selected as: ${arguments[0]}`);
|
||||
etHelper.Settings.selType = arguments[0];
|
||||
// Set selMediaType to the type we want, and has to handle exceptions
|
||||
switch(arguments[0]) {
|
||||
// Set type for episodes to shows
|
||||
|
@ -468,6 +529,7 @@
|
|||
},
|
||||
async getMedia() {
|
||||
log.info("getMedia Called");
|
||||
this.hideStartEnd();
|
||||
if (wtconfig.get('General.ExportPath', "") == "")
|
||||
{
|
||||
log.info('ET: No output dir defined')
|
||||
|
@ -507,14 +569,10 @@
|
|||
et.expSettings.accessToken = this.$store.getters.getSelectedServerToken;
|
||||
|
||||
console.log('Ged USE below') */
|
||||
etHelper.Settings.currentItem = 0;
|
||||
|
||||
etHelper.Settings.libType = this.selMediaType;
|
||||
etHelper.Settings.Level = this.selLevel;
|
||||
|
||||
etHelper.Settings.libTypeSec = this.selExpTypeSec;
|
||||
etHelper.Settings.baseURL = this.$store.getters.getSelectedServerAddress;
|
||||
etHelper.Settings.accessToken = this.$store.getters.getSelectedServerToken;
|
||||
|
||||
await etHelper.exportMedias();
|
||||
},
|
||||
async checkSrvSelected() {
|
||||
|
|
|
@ -81,7 +81,11 @@ const etHelper = new class ETHELPER {
|
|||
call: null,
|
||||
fields: null,
|
||||
currentItem: 0,
|
||||
totalItems: null
|
||||
totalItems: null,
|
||||
startItem: 0,
|
||||
endItem: null,
|
||||
count: 0,
|
||||
selType: null
|
||||
};
|
||||
|
||||
this.PMSHeader = wtutils.PMSHeader;
|
||||
|
@ -465,7 +469,7 @@ const etHelper = new class ETHELPER {
|
|||
|
||||
async addRowToTmp( { data }) {
|
||||
this.Settings.currentItem +=1;
|
||||
this.updateStatusMsg(this.RawMsgType.Items, i18n.t('Modules.ET.Status.ProcessItem', {count: this.Settings.currentItem, total: this.Settings.totalItems}));
|
||||
this.updateStatusMsg(this.RawMsgType.Items, i18n.t('Modules.ET.Status.ProcessItem', {count: this.Settings.count, total: this.Settings.endItem}));
|
||||
log.debug(`Start addRowToTmp item ${this.Settings.currentItem} (Switch to Silly log to see contents)`)
|
||||
log.silly(`Data is: ${JSON.stringify(data)}`)
|
||||
let name, key, type, subType, subKey, doPostProc;
|
||||
|
@ -480,7 +484,7 @@ const etHelper = new class ETHELPER {
|
|||
try
|
||||
{
|
||||
for (var x=0; x<this.Settings.fields.length; x++) {
|
||||
this.updateStatusMsg(this.RawMsgType.Items, i18n.t('Modules.ET.Status.ProcessItem', {count: this.Settings.currentItem, total: this.Settings.totalItems}));
|
||||
this.updateStatusMsg(this.RawMsgType.Items, i18n.t('Modules.ET.Status.ProcessItem', {count: this.Settings.count, total: this.Settings.endItem}));
|
||||
var fieldDef = JSONPath({path: '$.fields.' + this.Settings.fields[x], json: defFields})[0];
|
||||
name = this.Settings.fields[x];
|
||||
key = fieldDef["key"];
|
||||
|
@ -638,7 +642,9 @@ const etHelper = new class ETHELPER {
|
|||
async populateExpFiles(){
|
||||
log.info('Populating export files');
|
||||
// Current item counter in the chunck
|
||||
let idx = 0;
|
||||
//let idx = 0;
|
||||
let idx = this.Settings.startItem;
|
||||
this.Settings.count = idx;
|
||||
// Chunck step
|
||||
const step = wtconfig.get("PMS.ContainerSize." + this.Settings.libType, 20);
|
||||
let size = 0; // amount of items fetched each time
|
||||
|
@ -682,22 +688,28 @@ const etHelper = new class ETHELPER {
|
|||
if (this.Settings.xlsxFile){
|
||||
console.log('Ged 12-4 We need to exp to XLSX')
|
||||
}
|
||||
|
||||
}
|
||||
++this.Settings.count;
|
||||
console.log('Ged 8 counter: ' + this.Settings.count)
|
||||
console.log('Ged 8-1 Max: ' + this.Settings.endItem)
|
||||
if ( this.Settings.count >= this.Settings.endItem) {
|
||||
console.log('Ged 8-3 counter break')
|
||||
break;
|
||||
}
|
||||
}
|
||||
idx += step;
|
||||
} while (size == step);
|
||||
idx = Number(idx) + Number(step);
|
||||
} while (this.Settings.count < this.Settings.endItem);
|
||||
log.info('Populating export files ended');
|
||||
}
|
||||
|
||||
async getSectionSize()
|
||||
{
|
||||
const url = this.Settings.baseURL + '/library/sections/' + this.Settings.selLibKey + '/all?X-Plex-Container-Start=0&X-Plex-Container-Size=0';
|
||||
const url = this.Settings.baseURL + '/library/sections/' + this.Settings.selLibKey + '/all?X-Plex-Container-Start=0&X-Plex-Container-Size=0&type=' + this.Settings.selType;
|
||||
this.PMSHeader["X-Plex-Token"] = this.Settings.accessToken;
|
||||
log.verbose(`Calling url in getSectionSize: ${url}`)
|
||||
let response = await fetch(url, { method: 'GET', headers: this.PMSHeader});
|
||||
let resp = await response.json();
|
||||
var totalSize = JSONPath({path: '$..totalSize', json: resp});
|
||||
var totalSize = JSONPath({path: '$..totalSize', json: resp})[0];
|
||||
log.silly(`Response in getSectionSize: ${totalSize}`);
|
||||
return totalSize;
|
||||
}
|
||||
|
@ -917,6 +929,7 @@ const etHelper = new class ETHELPER {
|
|||
outFile += this.Settings.LibName + '_';
|
||||
outFile += this.RevETmediaType[this.Settings.libType.toString()] + '_';
|
||||
outFile += this.Settings.levelName + '_';
|
||||
outFile += 'Item ' + this.Settings.startItem + '-' + this.Settings.endItem + '_';
|
||||
outFile += timeStamp + '.' + Type + '.tmp';
|
||||
this.Settings.outFile = outFile;
|
||||
const targetDir = path.join(
|
||||
|
|
Loading…
Add table
Reference in a new issue