This commit is contained in:
Tommy Mikkelsen 2022-07-28 23:39:04 +02:00
parent fd9adf6335
commit 06b954c42b
4 changed files with 35 additions and 15 deletions

View file

@ -10,6 +10,8 @@
**Changes**: **Changes**:
* [#547 Add link to Library Map on FM Settings page](https://github.com/WebTools-NG/WebTools-NG/issues/547) (Enhancement) * [#547 Add link to Library Map on FM Settings page](https://github.com/WebTools-NG/WebTools-NG/issues/547) (Enhancement)
* [#552 Export posters and art in original size](https://github.com/WebTools-NG/WebTools-NG/issues/552) (Enhancement)
* [#550 Export posters for Seasons and Shows](https://github.com/WebTools-NG/WebTools-NG/issues/550) (Enhancement)
## V1.0.0 First Official Release (20220724) ## V1.0.0 First Official Release (20220724)

View file

@ -208,6 +208,7 @@
"Name": "ExportTools", "Name": "ExportTools",
"ErrorServer": "No server", "ErrorServer": "No server",
"Settings": { "Settings": {
"ArtPostersOrigen": "Export Art and Posters in original size",
"Settings": "Settings", "Settings": "Settings",
"Description": "Here you can define the settings for @:Modules.ET.Name", "Description": "Here you can define the settings for @:Modules.ET.Name",
"ArraySep": "Delimiter for multiple info in same field", "ArraySep": "Delimiter for multiple info in same field",

View file

@ -68,6 +68,7 @@
ArtDim: wtconfig.get('ET.Art_Dimensions', '75*75'), ArtDim: wtconfig.get('ET.Art_Dimensions', '75*75'),
cbSelected: [], cbSelected: [],
cbOptions: [ cbOptions: [
{ text: i18n.t('Modules.ET.Settings.ArtPostersOrigen'), value: 'ArtPostersOrigen' },
{ text: i18n.t('Modules.ET.Settings.ExportToCSV'), value: 'ExpCSV' }, { text: i18n.t('Modules.ET.Settings.ExportToCSV'), value: 'ExpCSV' },
{ text: i18n.t('Modules.ET.Settings.ExportToExcel'), value: 'ExpXLSX', disabled: true }, { text: i18n.t('Modules.ET.Settings.ExportToExcel'), value: 'ExpXLSX', disabled: true },
{ text: i18n.t('Modules.ET.Settings.OrgTitleNull'), value: 'OrgTitleNull' }, { text: i18n.t('Modules.ET.Settings.OrgTitleNull'), value: 'OrgTitleNull' },
@ -92,7 +93,7 @@
dialog.ShowMsg( i18n.t("Modules.ET.Name"), i18n.t("Common.Ok"), i18n.t("Common.AppName"), 'For this version, export to XLSX is currently disabled', 'info'); dialog.ShowMsg( i18n.t("Modules.ET.Name"), i18n.t("Common.Ok"), i18n.t("Common.AppName"), 'For this version, export to XLSX is currently disabled', 'info');
}, },
getDefaults(){ getDefaults(){
const cbItems = ["ExpCSV","ExpXLSX", "OrgTitleNull", "SortTitleNull", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange"]; const cbItems = ["ExpCSV","ExpXLSX", "OrgTitleNull", "SortTitleNull", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen"];
for(let i = 0; i < cbItems.length; i++){ for(let i = 0; i < cbItems.length; i++){
if (wtconfig.get("ET." + cbItems[i], false)){ if (wtconfig.get("ET." + cbItems[i], false)){
this.cbSelected.push(cbItems[i]); this.cbSelected.push(cbItems[i]);
@ -105,7 +106,7 @@
}, },
filterTable(){ filterTable(){
this.$nextTick(()=>{console.log(this.cbSelected);}) this.$nextTick(()=>{console.log(this.cbSelected);})
for( var cbItem of ["ExpCSV","ExpXLSX","OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange"]){ for( var cbItem of ["ExpCSV","ExpXLSX","OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen"]){
wtconfig.set("ET." + cbItem, (this.cbSelected.includes(cbItem))) wtconfig.set("ET." + cbItem, (this.cbSelected.includes(cbItem)))
} }
}, },

View file

@ -1378,36 +1378,52 @@ const etHelper = new class ETHELPER {
{ {
log.error(`[etHelper] (exportPics) Exception in exportPics is: ${error}`); log.error(`[etHelper] (exportPics) Exception in exportPics is: ${error}`);
} }
log.verbose(`[etHelper] (exportPics) picUrl is: ${picUrl}`);
log.verbose(`[etHelper] (exportPics) resolutions is: ${JSON.stringify(resolutions)}`);
log.verbose(`[etHelper] (exportPics) ExpDir is: ${ExpDir}`);
// Create export dir // Create export dir
var fs = require('fs'); var fs = require('fs');
if (!fs.existsSync(ExpDir)){ if (!fs.existsSync(ExpDir)){
fs.mkdirSync(ExpDir, { recursive: true }); fs.mkdirSync(ExpDir, { recursive: true });
} }
log.verbose(`[etHelper] (exportPics) picUrl is: ${picUrl}`);
log.verbose(`[etHelper] (exportPics) resolutions is: ${JSON.stringify(resolutions)}`);
const ArtPostersOrigen = wtconfig.get('ET.ArtPostersOrigen', false);
log.verbose(`[etHelper] (exportPics) resolutions as orginal: ${ArtPostersOrigen}`);
log.verbose(`[etHelper] (exportPics) ExpDir is: ${ExpDir}`);
let key = String(JSONPath({path: '$.ratingKey', json: data})[0]); let key = String(JSONPath({path: '$.ratingKey', json: data})[0]);
let title = String(JSONPath({path: '$.title', json: data})[0]); let title = String(JSONPath({path: '$.title', json: data})[0]);
// Get resolutions to export as if ( ArtPostersOrigen ){ // Export at original size
for(let res of resolutions) { const fileName = key + '_' + title.replace(/[/\\?%*:|"<>]/g, ' ').trim() + '.jpg';
const fileName = key + '_' + title.replace(/[/\\?%*:|"<>]/g, ' ').trim() + '_' + res.trim().replace("*", "x") + '.jpg';
let outFile = path.join( let outFile = path.join(
ExpDir, ExpDir,
fileName fileName
); );
// Build up pic url let URL = this.Settings.baseURL;
//const width = res.split('*')[1].trim();
const hight = res.split('*')[1].trim();
const width = res.split('*')[0].trim();
let URL = this.Settings.baseURL + '/photo/:/transcode?width=';
URL += width + '&height=' + hight;
URL += '&minSize=1&url=';
URL += picUrl; URL += picUrl;
log.verbose(`[etHelper] (exportPics) Url for ${extype} is ${URL}`); log.verbose(`[etHelper] (exportPics) Url for ${extype} is ${URL}`);
log.verbose(`[etHelper] (exportPics) Outfile is ${outFile}`); log.verbose(`[etHelper] (exportPics) Outfile is ${outFile}`);
URL += '&X-Plex-Token=' + this.Settings.accessToken; URL += '&X-Plex-Token=' + this.Settings.accessToken;
await this.forceDownload( { url:URL, target:outFile, title:title} ); await this.forceDownload( { url:URL, target:outFile, title:title} );
} }
else { // Get resolutions to export as
for(let res of resolutions) {
const fileName = key + '_' + title.replace(/[/\\?%*:|"<>]/g, ' ').trim() + '_' + res.trim().replace("*", "x") + '.jpg';
let outFile = path.join(
ExpDir,
fileName
);
// Build up pic url
//const width = res.split('*')[1].trim();
const hight = res.split('*')[1].trim();
const width = res.split('*')[0].trim();
let URL = this.Settings.baseURL + '/photo/:/transcode?width=';
URL += width + '&height=' + hight;
URL += '&minSize=1&url=';
URL += picUrl;
log.verbose(`[etHelper] (exportPics) Url for ${extype} is ${URL}`);
log.verbose(`[etHelper] (exportPics) Outfile is ${outFile}`);
URL += '&X-Plex-Token=' + this.Settings.accessToken;
await this.forceDownload( { url:URL, target:outFile, title:title} );
}
}
} }
async createOutFile() async createOutFile()