mirror of
https://github.com/WebTools-NG/WebTools-NG
synced 2024-11-30 06:50:21 +00:00
# 550 WIP
This commit is contained in:
parent
06b954c42b
commit
433883bef9
5 changed files with 129 additions and 70 deletions
|
@ -172,16 +172,31 @@
|
|||
log.debug(`Customlevel ${this.selCustLevel} selected`);
|
||||
if (this.selCustLevel != 'NewLevel'){
|
||||
// Get fields from config.json file
|
||||
let custLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`)
|
||||
let custLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level.${this.selCustLevel}`);
|
||||
// Do we need to export art?
|
||||
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, false) )
|
||||
{
|
||||
custLevel.push("Export Art");
|
||||
}
|
||||
// Do we need to export show art?
|
||||
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.ShowArt.${this.selCustLevel}`, false) )
|
||||
{
|
||||
custLevel.push("Export Show Art");
|
||||
}
|
||||
// Do we need to export posters?
|
||||
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.${this.selMediaType}.Art.${this.selCustLevel}`, false) )
|
||||
// Do we need to export season posters?
|
||||
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.SeasonPosters.${this.selCustLevel}`, false) )
|
||||
{
|
||||
custLevel.push("Export Art");
|
||||
custLevel.push("Export Season Posters");
|
||||
}
|
||||
// Do we need to export show posters?
|
||||
if ( wtconfig.get(`ET.CustomLevels.${this.selMediaType}.ShowPosters.${this.selCustLevel}`, false) )
|
||||
{
|
||||
custLevel.push("Export Show Posters");
|
||||
}
|
||||
// Add to resultList
|
||||
this.resultList = custLevel.map((name, index) => {
|
||||
|
@ -330,7 +345,10 @@
|
|||
saveCustomLevel() {
|
||||
let result = []
|
||||
let bExportArt = false;
|
||||
let bExportShowArt = false;
|
||||
let bExportPosters = false;
|
||||
let bExportSeasonPosters = false;
|
||||
let bExportShowPosters = false;
|
||||
for(var k in this.resultList) {
|
||||
if (this.resultList[k].name == 'Export Posters')
|
||||
{
|
||||
|
@ -340,13 +358,28 @@
|
|||
{
|
||||
bExportArt = true;
|
||||
}
|
||||
else if (this.resultList[k].name == 'Export Show Art')
|
||||
{
|
||||
bExportShowArt = true;
|
||||
}
|
||||
else if (this.resultList[k].name == 'Export Season Posters')
|
||||
{
|
||||
bExportSeasonPosters = true;
|
||||
}
|
||||
else if (this.resultList[k].name == 'Export Show Posters')
|
||||
{
|
||||
bExportShowPosters = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.push(this.resultList[k].name);
|
||||
}
|
||||
}
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Posters.${this.selCustLevel}`, bExportPosters);
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.SeasonPosters.${this.selCustLevel}`, bExportSeasonPosters);
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.ShowPosters.${this.selCustLevel}`, bExportShowPosters);
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.Art.${this.selCustLevel}`, bExportArt);
|
||||
wtconfig.set(`ET.CustomLevels.${this.selMediaType}.ShowArt.${this.selCustLevel}`, bExportShowArt);
|
||||
// Get current level names
|
||||
let curLevel = wtconfig.get(`ET.CustomLevels.${this.selMediaType}.level`);
|
||||
// Add new level to JSON
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
<b-tooltip target="PosterGrp" triggers="hover">
|
||||
{{ $t('Modules.ET.Settings.Posters_Dimensions_TT') }}
|
||||
</b-tooltip>
|
||||
<b-form-input id="PosterDim" name="PosterDim" type="text" class="form-control" v-model="PosterDim" :disabled=false @change="setPosters_Dimensions()"></b-form-input>
|
||||
<b-form-input id="PosterDim" name="PosterDim" type="text" class="form-control" v-model="PosterDim" :disabled=PosterDimDisabled @change="setPosters_Dimensions()"></b-form-input>
|
||||
</b-input-group>
|
||||
<b-input-group id="ArtGrp" :prepend="$t('Modules.ET.Settings.Art_Dimensions')" class="mt-3">
|
||||
<b-tooltip target="ArtGrp" triggers="hover">
|
||||
{{ $t('Modules.ET.Settings.Art_Dimensions_TT') }}
|
||||
</b-tooltip>
|
||||
<b-form-input id="ArtDim" name="ArtDim" type="text" class="form-control" v-model="ArtDim" :disabled=false @change="setArt_Dimensions()"></b-form-input>
|
||||
<b-form-input id="ArtDim" name="ArtDim" type="text" class="form-control" v-model="ArtDim" :disabled=ArtDimDisabled @change="setArt_Dimensions()"></b-form-input>
|
||||
</b-input-group>
|
||||
<b-form-group id="b-form-group">
|
||||
<b-form-checkbox-group
|
||||
|
@ -64,6 +64,8 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
PosterDimDisabled: false,
|
||||
ArtDimDisabled: false,
|
||||
PosterDim: wtconfig.get('ET.Posters_Dimensions', '75*75'),
|
||||
ArtDim: wtconfig.get('ET.Art_Dimensions', '75*75'),
|
||||
cbSelected: [],
|
||||
|
@ -99,6 +101,8 @@
|
|||
this.cbSelected.push(cbItems[i]);
|
||||
}
|
||||
}
|
||||
this.PosterDimDisabled = this.cbSelected.includes('ArtPostersOrigen');
|
||||
this.ArtDimDisabled = this.cbSelected.includes('ArtPostersOrigen');
|
||||
this.SelectedMoviesID = wtconfig.get("ET.SelectedMoviesID", "imdb");
|
||||
},
|
||||
SelectedMoviesIDChanged(){
|
||||
|
@ -109,6 +113,8 @@
|
|||
for( var cbItem of ["ExpCSV","ExpXLSX","OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen"]){
|
||||
wtconfig.set("ET." + cbItem, (this.cbSelected.includes(cbItem)))
|
||||
}
|
||||
this.PosterDimDisabled = this.cbSelected.includes('ArtPostersOrigen');
|
||||
this.ArtDimDisabled = this.cbSelected.includes('ArtPostersOrigen');
|
||||
},
|
||||
setPosters_Dimensions: function(){
|
||||
wtconfig.set('ET.Posters_Dimensions', this.PosterDim);
|
||||
|
|
|
@ -68,7 +68,10 @@
|
|||
"Duration",
|
||||
"Episode",
|
||||
"Export Art",
|
||||
"Export Show Art",
|
||||
"Export Posters",
|
||||
"Export Season Posters",
|
||||
"Export Show Posters",
|
||||
"Extras",
|
||||
"IMDB ID",
|
||||
"IMDB Link",
|
||||
|
|
|
@ -429,12 +429,30 @@
|
|||
"call": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"Export Show Art":
|
||||
{
|
||||
"key": "$.ratingKey",
|
||||
"call": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"Export Posters":
|
||||
{
|
||||
"key": "$.ratingKey",
|
||||
"call": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"Export Season Posters":
|
||||
{
|
||||
"key": "$.ratingKey",
|
||||
"call": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"Export Show Posters":
|
||||
{
|
||||
"key": "$.ratingKey",
|
||||
"call": 1,
|
||||
"type": "string"
|
||||
},
|
||||
"Extras":
|
||||
{
|
||||
"key": "$.Extras.size",
|
||||
|
|
|
@ -1350,80 +1350,79 @@ const etHelper = new class ETHELPER {
|
|||
this.Settings.outFile = newFile;
|
||||
}
|
||||
|
||||
async exportPics( { type: extype, data: data} ) {
|
||||
let ExpDir, picUrl, resolutions;
|
||||
log.verbose(`[etHelper] (exportPics) Going to export ${extype}`);
|
||||
try
|
||||
{
|
||||
if (extype == 'posters')
|
||||
{
|
||||
picUrl = String(JSONPath({path: '$.thumb', json: data})[0]);
|
||||
resolutions = wtconfig.get('ET.Posters_Dimensions', '75*75').split(',');
|
||||
ExpDir = path.join(
|
||||
wtconfig.get('General.ExportPath'),
|
||||
wtutils.AppName,
|
||||
'ExportTools', 'Posters');
|
||||
}
|
||||
else
|
||||
{
|
||||
picUrl = String(JSONPath({path: '$.art', json: data})[0]);
|
||||
resolutions = wtconfig.get('ET.Art_Dimensions', '75*75').split(',');
|
||||
ExpDir = path.join(
|
||||
wtconfig.get('General.ExportPath'),
|
||||
wtutils.AppName,
|
||||
'ExportTools', 'Art');
|
||||
}
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
log.error(`[etHelper] (exportPics) Exception in exportPics is: ${error}`);
|
||||
}
|
||||
async getExportPicsUrlandFileFileName( { type: extype, data: data, res: res} ) { // Get Art/Poster filename
|
||||
let key = String(JSONPath({path: '$.ratingKey', json: data})[0]);
|
||||
let title = String(JSONPath({path: '$.title', json: data})[0]);
|
||||
let fileName = '';
|
||||
const ExpDir = path.join(
|
||||
wtconfig.get('General.ExportPath'),
|
||||
wtutils.AppName,
|
||||
i18n.t('Modules.ET.Name'),
|
||||
extype);
|
||||
// Also create exp dir if it doesn't exists
|
||||
// Create export dir
|
||||
var fs = require('fs');
|
||||
if (!fs.existsSync(ExpDir)){
|
||||
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 title = String(JSONPath({path: '$.title', json: data})[0]);
|
||||
if ( ArtPostersOrigen ){ // Export at original size
|
||||
const fileName = key + '_' + title.replace(/[/\\?%*:|"<>]/g, ' ').trim() + '.jpg';
|
||||
let outFile = path.join(
|
||||
ExpDir,
|
||||
fileName
|
||||
);
|
||||
let URL = this.Settings.baseURL;
|
||||
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} );
|
||||
if ( res ){
|
||||
// Remove whitespace
|
||||
res = res.replace(/\s/g, "");
|
||||
fileName = `${key}_${title.replace(/[/\\?%*:|"<>]/g, ' ').trim()}_${res}`;
|
||||
} else {
|
||||
fileName = `${key}_${title.replace(/[/\\?%*:|"<>]/g, ' ').trim()}`;
|
||||
}
|
||||
else { // Get resolutions to export as
|
||||
let outFile = path.join(
|
||||
ExpDir,
|
||||
fileName + '.jpg'
|
||||
);
|
||||
log.debug(`[ethelper.js] (getExportPicsUrlandFileFileName) - Outfile is: ${outFile}`);
|
||||
return outFile;
|
||||
}
|
||||
|
||||
async getExportPicsUrlandFile( { type: extype, data: data} ) {
|
||||
const ArtPostersOrigen = wtconfig.get('ET.ArtPostersOrigen', false);
|
||||
let resp = [];
|
||||
let picUrl = '';
|
||||
let entry = {};
|
||||
let resolutions;
|
||||
switch ( extype ) {
|
||||
case 'posters':
|
||||
picUrl = String(JSONPath({path: '$.thumb', json: data})[0]);
|
||||
resolutions = wtconfig.get('ET.Posters_Dimensions', '75*75').split(',');
|
||||
break;
|
||||
case 'arts':
|
||||
picUrl = String(JSONPath({path: '$.art', json: data})[0]);
|
||||
resolutions = wtconfig.get('ET.Art_Dimensions', '75*75').split(',');
|
||||
break;
|
||||
}
|
||||
if ( ArtPostersOrigen ) { // Export in origen resolution
|
||||
entry['url'] = `${this.Settings.baseURL}${picUrl}`;
|
||||
entry['outFile'] = await this.getExportPicsUrlandFileFileName( { type: extype, data: data} );
|
||||
resp.push(entry);
|
||||
} else { // Export in defined resolutions
|
||||
for(let res of resolutions) {
|
||||
const fileName = key + '_' + title.replace(/[/\\?%*:|"<>]/g, ' ').trim() + '_' + res.trim().replace("*", "x") + '.jpg';
|
||||
let outFile = path.join(
|
||||
ExpDir,
|
||||
fileName
|
||||
);
|
||||
entry = {};
|
||||
res = res.replace('*', 'x');
|
||||
console.log('Ged 21-3', res)
|
||||
// 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;
|
||||
const hight = res.split('x')[1].trim();
|
||||
const width = res.split('x')[0].trim();
|
||||
entry['url'] = `${this.Settings.baseURL}/photo/:/transcode?width=${width}&height=${hight}&minSize=1&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} );
|
||||
entry['outFile'] = await this.getExportPicsUrlandFileFileName( { type: extype, data: data, res: res} );
|
||||
resp.push(entry);
|
||||
}
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
async exportPics( { type: extype, data: data} ) {
|
||||
let files = await this.getExportPicsUrlandFile( { type: extype, data: data} );
|
||||
let title = String(JSONPath({path: '$.title', json: data})[0]);
|
||||
for (var idx in files){
|
||||
await this.forceDownload( { url:files[idx]['url'], target:files[idx]['outFile'], title:title} );
|
||||
}
|
||||
}
|
||||
|
||||
async createOutFile()
|
||||
|
@ -1831,7 +1830,7 @@ const etHelper = new class ETHELPER {
|
|||
}
|
||||
Object.keys(levels).forEach(function(key) {
|
||||
// Skip picture export fields
|
||||
if ( !["Export Art", "Export Posters"].includes(levels[key]) )
|
||||
if ( !["Export Art", "Export Posters", "Export Show Art", "Export Season Posters", "Export Show Posters"].includes(levels[key]) )
|
||||
{
|
||||
out.push(levels[key])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue