Merge pull request #513 from WebTools-NG/#505-Revisit

#505 revisit
This commit is contained in:
Tommy Mikkelsen 2022-07-02 00:32:45 +02:00 committed by GitHub
commit 25cf47ab1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 112 additions and 94 deletions

View file

@ -15,6 +15,7 @@
* [#500 Library Path Mapping](https://github.com/WebTools-NG/WebTools-NG/issues/500) * [#500 Library Path Mapping](https://github.com/WebTools-NG/WebTools-NG/issues/500)
* [#505 FindMedia](https://github.com/WebTools-NG/WebTools-NG/issues/505) * [#505 FindMedia](https://github.com/WebTools-NG/WebTools-NG/issues/505)
* [#509 Refactor Settings](https://github.com/WebTools-NG/WebTools-NG/issues/509) * [#509 Refactor Settings](https://github.com/WebTools-NG/WebTools-NG/issues/509)
* [#512 ET Intro Start/End isn't exported](https://github.com/WebTools-NG/WebTools-NG/issues/512)
## V0.3.17 (20220601) ## V0.3.17 (20220601)

View file

@ -576,7 +576,8 @@
"call": 2, "call": 2,
"type": "array", "type": "array",
"subtype": "time", "subtype": "time",
"subkey": "$.startTimeOffset" "subkey": "$.startTimeOffset",
"include": "includeMarkers=1"
}, },
"Intro Stop": "Intro Stop":
{ {
@ -584,7 +585,8 @@
"call": 2, "call": 2,
"type": "array", "type": "array",
"subtype": "time", "subtype": "time",
"subkey": "$.endTimeOffset" "subkey": "$.endTimeOffset",
"include": "includeMarkers=1"
}, },
"Item Counts": "Item Counts":
{ {

View file

@ -40,7 +40,7 @@
"Include": { "Include": {
"Level 1": "", "Level 1": "",
"Level 2": "", "Level 2": "",
"all": "checkFiles=1&includeExtras=1&includeBandwidths=1&includeChapters=1" "all": "checkFiles=1&includeExtras=1&includeBandwidths=1&includeChapters=1&includeMarkers=1"
} }
}, },
"1" : { "1" : {

View file

@ -353,7 +353,7 @@ const etHelper = new class ETHELPER {
}; };
this.PMSHeader = wtutils.PMSHeader; this.PMSHeader = wtutils.PMSHeader;
this.uriParams = 'checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1'; this.uriParams = 'checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExtras=1&includeFields=1&includeGeolocation=1&includeMarkers=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1';
this.ETmediaType = { this.ETmediaType = {
Movie: 1, Movie: 1,
Show: 2, Show: 2,

View file

@ -25,14 +25,13 @@ const pms = new class PMS {
if (Array.isArray(sections) && sections.length) { if (Array.isArray(sections) && sections.length) {
sections.forEach(req => { sections.forEach(req => {
if ( libTypes.includes(req.type)){ if ( libTypes.includes(req.type)){
log.debug(`[pms.js] (getPMSSections) - pushing library: ${req.title} to results`); log.silly(`[pms.js] (getPMSSections) - pushing library: ${req.title} to results`);
let item = []; let item = [];
let itemVal = {}; let itemVal = {};
itemVal['key'] = JSONPath({path: '$..key', json: req})[0]; itemVal['key'] = JSONPath({path: '$..key', json: req})[0];
itemVal['location'] = JSONPath({path: '$..path', json: req.location}); itemVal['location'] = JSONPath({path: '$..path', json: req.location});
itemVal['type'] = JSONPath({path: '$..type', json: req})[0]; itemVal['type'] = JSONPath({path: '$..type', json: req})[0];
item['text']=req.title; item['text']=req.title;
//item['value']=JSONPath({path: '$..path', json: req.location});
item['value']=itemVal; item['value']=itemVal;
result.push(Object.assign({}, item)); result.push(Object.assign({}, item));
} }

View file

@ -58,6 +58,7 @@
<script> <script>
import i18n from '../../../../i18n'; import i18n from '../../../../i18n';
import { wtconfig } from '../../General/wtutils'; import { wtconfig } from '../../General/wtutils';
const log = require("electron-log"); const log = require("electron-log");
export default { export default {
data() { data() {
@ -177,6 +178,18 @@
case '20971520': case '20971520':
logSizeDisp = '20Mb'; logSizeDisp = '20Mb';
break; break;
case '41943040':
logSizeDisp = '40Mb';
break;
case '62914560':
logSizeDisp = '60Mb';
break;
case '104857600':
logSizeDisp = '100Mb';
break;
case '209715200':
logSizeDisp = '200Mb';
break;
default: default:
logSizeDisp = '1Mb'; logSizeDisp = '1Mb';
} }

View file

@ -37,6 +37,7 @@
{{ $t('Modules.PMS.FindMedia.Settings.IgnoreHidden') }} {{ $t('Modules.PMS.FindMedia.Settings.IgnoreHidden') }}
</b-form-checkbox> </b-form-checkbox>
</div> </div>
<!-- Disabled for now, since req a call for each media in lib
<div> <div>
<b-form-checkbox <b-form-checkbox
id="IgnoreExtras" id="IgnoreExtras"
@ -49,6 +50,8 @@
{{ $t('Modules.PMS.FindMedia.Settings.IgnoreExtras') }} {{ $t('Modules.PMS.FindMedia.Settings.IgnoreExtras') }}
</b-form-checkbox> </b-form-checkbox>
</div> </div>
-->
<br> <br>
<br> <br>
<!-- Buttons --> <!-- Buttons -->
@ -85,7 +88,7 @@
}, },
methods: { methods: {
setIgnoreHidden( value ){ setIgnoreHidden( value ){
wtconfig.set('PMS.FindMedia.Settings.IgnoreHidden', value); wtconfig.set('PMS.FindMedia.Settings.IgnoreHidden', value === 'true');
}, },
setIgnoreExtras( value ){ setIgnoreExtras( value ){
wtconfig.set('PMS.FindMedia.Settings.IgnoreExtras', value); wtconfig.set('PMS.FindMedia.Settings.IgnoreExtras', value);
@ -121,8 +124,8 @@
}, },
// Reset to factory Std // Reset to factory Std
reset(){ reset(){
this.Ext = findMedia.validExt.toString(); this.Ext = findMedia.defValidExt.toString();
wtconfig.set('PMS.FindMedia.Settings.Ext', findMedia.validExt); wtconfig.set('PMS.FindMedia.Settings.Ext', findMedia.defValidExt);
this.ignoreDirs = findMedia.ignoreDirs.toString(); this.ignoreDirs = findMedia.ignoreDirs.toString();
wtconfig.set('PMS.FindMedia.Settings.ignoreDirs', findMedia.ignoreDirs); wtconfig.set('PMS.FindMedia.Settings.ignoreDirs', findMedia.ignoreDirs);
this.IgnoreHidden = true; this.IgnoreHidden = true;

View file

@ -20,27 +20,28 @@ import {csv} from '../../../ExportTools/scripts/csv';
const validDir = function( dirName ) { const validDir = function( dirName ) {
/* Will check if directory is not hidden or should be ignored /* Will check if directory is not hidden or should be ignored
returns true or false */ returns true or false */
log.silly(`Checking if ${dirName} is valid`); log.silly(`[FindMedia.js] (validDir) - Checking if ${dirName} is valid`);
// Got a hidden one? // Got a hidden one?
if ( wtconfig.get('PMS.FindMedia.Settings.IgnoreHidden', true) === 'true' ){ if ( wtconfig.get('PMS.FindMedia.Settings.IgnoreHidden') ){
if ( dirName.startsWith('.') ){ if ( dirName.startsWith('.') ){
log.silly(`We do not allow hidden dirs like: ${dirName}`); log.silly(`[FindMedia.js] (validDir) - We do not allow hidden dirs like: ${dirName}`);
return false; return false;
} }
} }
// Got an Extra dir? // Got an Extra dir?
if ( findMedia.settingsIgnoreExtras ){ if ( wtconfig.get('PMS.FindMedia.Settings.IgnoreExtras', true) ){
if ( findMedia.ExtraDirs.includes( dirName )){ if ( findMedia.ExtraDirs.includes( dirName )){
log.silly(`We do not allow extra dirs like: ${dirName}`); log.silly(`[FindMedia.js] (validDir) - We do not allow extra dirs like: ${dirName}`);
return false; return false;
} }
} }
// Got a dir to ignore? // Got a dir to ignore?
if ( findMedia.settingsIgnoreDirs.includes( dirName ) ){ if ( findMedia.settingsIgnoreDirs.includes( dirName.toLowerCase() ) ){
log.silly(`We do not allow ignore dirs like: ${dirName}`); log.silly(`[FindMedia.js] (validDir) - We do not allow ignore dirs like: ${dirName}`);
return false; return false;
} }
log.silly(`${dirName} is valid`); log.silly(`[FindMedia.js] (validDir) - ${dirName} is valid`);
return true; return true;
} }
@ -50,16 +51,27 @@ const validFile = function( fileName ) {
log.silly(`[FindMedia.js] (validFile) - Checking file: ${fileName}`) log.silly(`[FindMedia.js] (validFile) - Checking file: ${fileName}`)
if ( findMedia.validExt.includes(path.extname(fileName).toLowerCase().slice(1))){ if ( findMedia.validExt.includes(path.extname(fileName).toLowerCase().slice(1))){
log.silly(`[FindMedia.js] (validFile) - Valid ext for file: ${fileName}`); log.silly(`[FindMedia.js] (validFile) - Valid ext for file: ${fileName}`);
if ( findMedia.settingsIgnoreExtras ){ // Got a hidden one?
log.silly(`[FindMedia.js] (validFile) - Checking IgnoreExtras for file: ${fileName}`) if ( wtconfig.get('PMS.FindMedia.Settings.IgnoreHidden') ){
for (let eFile of findMedia.Extrafiles) { if ( fileName.startsWith('.') ){
if ( path.parse(fileName).name.endsWith(eFile) ){ log.silly(`[FindMedia.js] (validFile) - We do not allow hidden files like: ${fileName}`);
log.silly(`We ignore extra file: ${fileName}`)
return false; return false;
} }
} }
// Ignore extras
if ( wtconfig.get('PMS.FindMedia.Settings.IgnoreExtras', true) ){
log.silly(`[FindMedia.js] (validFile) - Checking IgnoreExtras for file: ${fileName}`)
for (let eFile of findMedia.Extrafiles) {
if ( path.parse(fileName).name.endsWith(eFile) ){
log.silly(`[FindMedia.js] (validFile) - We ignore extra file: ${fileName}`)
return false;
}
}
//return true;
} // else { return true }
log.debug(`[FindMedia.js] (validFile) - *** Valid file found: ${fileName} ***`)
return true; return true;
} else { return true }
} else { } else {
log.silly(`[FindMedia.js] (validFile) - Ext not valid for file: ${fileName}`) log.silly(`[FindMedia.js] (validFile) - Ext not valid for file: ${fileName}`)
return false return false
@ -90,7 +102,6 @@ const getAllFiles = function( dirPath, orgDirPath, arrayOfFiles ) {
// Force forward slash // Force forward slash
let lookupPath = path.join(dirPath, curFile).replaceAll('\\', '/'); let lookupPath = path.join(dirPath, curFile).replaceAll('\\', '/');
log.silly(`[FindMedia.js] (getAllFiles) - Adding ${lookupPath.slice(orgDirPath.length + 1)}: ${ path.join(dirPath, curFile) }`); log.silly(`[FindMedia.js] (getAllFiles) - Adding ${lookupPath.slice(orgDirPath.length + 1)}: ${ path.join(dirPath, curFile) }`);
//status.updateStatusMsg( status.RevMsgType.Item, `GED Found file: ${curFile}`);
findMedia.filesFound[lookupPath.slice(orgDirPath.length + 1)] = path.join(dirPath, curFile); findMedia.filesFound[lookupPath.slice(orgDirPath.length + 1)] = path.join(dirPath, curFile);
} }
} }
@ -99,24 +110,21 @@ const getAllFiles = function( dirPath, orgDirPath, arrayOfFiles ) {
return arrayOfFiles return arrayOfFiles
} }
const findMedia = new class FINDMEDIA { const findMedia = new class FINDMEDIA {
constructor() { constructor() {
this.validExt = [ // Defaults for ext
this.defValidExt = [
'3g2','3gp','asf','asx','avc','avi','avs','bivx','bup','divx','dv','dvr-ms', '3g2','3gp','asf','asx','avc','avi','avs','bivx','bup','divx','dv','dvr-ms',
'evo','fli','flv','m2t','m2ts','m2v','m4v', 'evo','fli','flv','m2t','m2ts','m2v','m4v',
'mkv','mov','mp4','mpeg','mpg','mts','nsv','nuv','ogm','ogv','tp','pva','qt','rm','rmvb','sdp','svq3', 'mkv','mov','mp4','mpeg','mpg','mts','nsv','nuv','ogm','ogv','tp','pva','qt','rm','rmvb','sdp','svq3',
'strm','ts','ty','vdr','viv','vob','vp3','wmv','wpl','wtv','xsp','xvid','webm' 'strm','ts','ty','vdr','viv','vob','vp3','wmv','wpl','wtv','xsp','xvid','webm'
]; ];
// Extra dirs
this.ExtraDirs = [ this.ExtraDirs = [
'Behind The Scenes', 'Deleted Scenes', 'Featurettes', 'Behind The Scenes', 'Deleted Scenes', 'Featurettes',
'Interviews', 'Scenes', 'Shorts', 'Trailers', 'Other' 'Interviews', 'Scenes', 'Shorts', 'Trailers', 'Other'
]; ];
// Extra files
this.Extrafiles = [ this.Extrafiles = [
'-behindthescenes', '-deleted', '-featurette', '-behindthescenes', '-deleted', '-featurette',
'-interview', '-scene', '-short', '-trailer', '-other' '-interview', '-scene', '-short', '-trailer', '-other'
@ -124,19 +132,14 @@ const findMedia = new class FINDMEDIA {
this.ignoreDirs = [ this.ignoreDirs = [
'lost+found' 'lost+found'
]; ];
this.libPaths = []; this.filePath = []; // Tmp store
this.filePath = []; this.validExt = []; // Valid ext to use
this.validExt = []; this.filesFound = {}; // files from FS to be included in result
this.currentLibPathLength; this.libFiles = []; // files from PMS to be included in result
this.filesFound = {}; this.PMSLibPaths = []; // All PMS Library paths (Wkstn)
this.libFiles = []; this.csvFile = ''; // Filename for output file
this.PMSLibPaths = []; this.csvStream; // Output stream
this.csvFile = ''; this.settingsIgnoreDirs; // Directories to ignore
this.libName = '';
this.csvStream;
this.settingsIgnoreExtras;
this.ignoreDirs;
} }
// Generate the filename for an export // Generate the filename for an export
@ -197,11 +200,12 @@ const findMedia = new class FINDMEDIA {
async findMedia( libpaths, libKey, libType ){ async findMedia( libpaths, libKey, libType ){
status.updateStatusMsg( status.RevMsgType.Status, i18n.t('Common.Status.Msg.Processing')); status.updateStatusMsg( status.RevMsgType.Status, i18n.t('Common.Status.Msg.Processing'));
// Get settings needed // Get settings needed
this.validExt = await wtconfig.get('PMS.FindMedia.Settings.Ext'); this.validExt = await wtconfig.get('PMS.FindMedia.Settings.Ext', this.defValidExt);
this.settingsIgnoreExtras = await wtconfig.get('PMS.FindMedia.Settings.IgnoreExtras'); this.settingsIgnoreDirs = await wtconfig.get('PMS.FindMedia.Settings.ignoreDirs', this.ExtraDirs);
this.settingsIgnoreDirs = await wtconfig.get('PMS.FindMedia.Settings.ignoreDirs'); log.info(`[FindMedia.js] (findMedia) - Starting FindMedia`);
log.info(`[FindMedia.js] (findMedia) - Ignore Hidden files: ${wtconfig.get('PMS.FindMedia.Settings.IgnoreHidden', true)}`);
log.info(`[FindMedia.js] (findMedia) - Ignore Extra files/Dirs: ${wtconfig.get('PMS.FindMedia.Settings.IgnoreExtras', true)}`);
log.info(`[FindMedia.js] (findMedia) - Extra dirs to ignore: ${this.settingsIgnoreDirs}`);
// Scan file system // Scan file system
this.filesFound = []; this.filesFound = [];
await findMedia.scanFileSystemPaths( libpaths ); await findMedia.scanFileSystemPaths( libpaths );
@ -209,13 +213,9 @@ const findMedia = new class FINDMEDIA {
await findMedia.scanPMSLibrary(libKey, libType); await findMedia.scanPMSLibrary(libKey, libType);
// Create output file // Create output file
let outFile = await this.makeOutFile( libKey ); let outFile = await this.makeOutFile( libKey );
status.clearStatus(); status.clearStatus();
status.updateStatusMsg( status.RevMsgType.Status, i18n.t('Common.Status.Msg.Finished')); status.updateStatusMsg( status.RevMsgType.Status, i18n.t('Common.Status.Msg.Finished'));
status.updateStatusMsg( status.RevMsgType.OutFile, outFile); status.updateStatusMsg( status.RevMsgType.OutFile, outFile);
libType
} }
async checkPathMapping( paths ){ async checkPathMapping( paths ){
@ -267,7 +267,6 @@ libType
status.updateStatusMsg( status.RevMsgType.Info, `Now Scanning ${mappedLibPath}`); status.updateStatusMsg( status.RevMsgType.Info, `Now Scanning ${mappedLibPath}`);
log.debug(`[FindMedia.js] (scanFileSystemPaths) - PMS path is: ${libPath}`); log.debug(`[FindMedia.js] (scanFileSystemPaths) - PMS path is: ${libPath}`);
log.debug(`[FindMedia.js] (scanFileSystemPaths) - Wkstn path is: ${mappedLibPath}`); log.debug(`[FindMedia.js] (scanFileSystemPaths) - Wkstn path is: ${mappedLibPath}`);
//findMedia.filePath.push(...getAllFiles( mappedLibPath, mappedLibPath ));
findMedia.filePath.push(...getAllFiles( mappedLibPath, mappedLibPath )); findMedia.filePath.push(...getAllFiles( mappedLibPath, mappedLibPath ));
}); });
log.info(`[FindMedia.js] (scanFileSystemPaths) - End`); log.info(`[FindMedia.js] (scanFileSystemPaths) - End`);
@ -277,7 +276,7 @@ libType
async scanPMSLibrary( library, libType ){ async scanPMSLibrary( library, libType ){
/* /*
This will scan the PMS library, and add result to this.libPaths, This will scan the PMS library, and add result to this.libFiles,
if not present in this.filePath. if not present in this.filePath.
If present, then pop it from this.filePath If present, then pop it from this.filePath
*/ */
@ -321,11 +320,6 @@ libType
log.error(`[FindMedia.js] (scanPMSLibrary) - ${JSON.stringify(error.message)}`); log.error(`[FindMedia.js] (scanPMSLibrary) - ${JSON.stringify(error.message)}`);
} }
}); });
// totalSize, size
// resolve();
step = wtconfig.get("PMS.ContainerSize." + mediaType, 20); step = wtconfig.get("PMS.ContainerSize." + mediaType, 20);
let metaData; let metaData;
do { do {
@ -347,12 +341,10 @@ libType
var title = JSONPath({path: `$..title`, json: metaData[parseInt(idxMetaData)]})[0]; var title = JSONPath({path: `$..title`, json: metaData[parseInt(idxMetaData)]})[0];
var files = JSONPath({path: `$..Part[*].file`, json: metaData[parseInt(idxMetaData)]}); var files = JSONPath({path: `$..Part[*].file`, json: metaData[parseInt(idxMetaData)]});
for (var idxFiles in files){ for (var idxFiles in files){
if (this.validExt.includes(path.extname(files[idxFiles]).toLowerCase().slice(1))){ const pmsFile = files[idxFiles].replaceAll('\\', '/');
for (var idxPMSLibPaths in this.PMSLibPaths){ if (this.validExt.includes(path.extname(pmsFile).toLowerCase().slice(1))){
if (files[idxFiles].startsWith(this.PMSLibPaths[idxPMSLibPaths])){ const libPathFound = this.getLibPath( files[idxFiles] );
// Slice to lookup in files found var lookup = pmsFile.slice(libPathFound.length + 1);
var lookup = files[idxFiles].slice(this.PMSLibPaths[idxPMSLibPaths].length + 1)
lookup = lookup.replaceAll('\\', '/');
if ( Object.prototype.hasOwnProperty.call(this.filesFound, lookup)) { if ( Object.prototype.hasOwnProperty.call(this.filesFound, lookup)) {
// We need to remove from detected files, since we found it // We need to remove from detected files, since we found it
delete this.filesFound[lookup]; delete this.filesFound[lookup];
@ -367,8 +359,6 @@ libType
} }
} }
} }
}
}
index += step; index += step;
}) })
.catch(function (error) { .catch(function (error) {
@ -389,6 +379,21 @@ libType
resolve(); resolve();
} }
getLibPath( fileName ){
let foundPath = { };
foundPath['found'] = [0, ""];
for (var Idx in this.PMSLibPaths){
if ( fileName.startsWith(this.PMSLibPaths[Idx])){
const PMSLibPathsLength = this.PMSLibPaths[Idx].length;
if ( PMSLibPathsLength > foundPath['found'][0] ){
foundPath['found'] = [PMSLibPathsLength, this.PMSLibPaths[Idx]];
}
}
}
return foundPath['found'][1];
}
async getPMSPathArr(){ async getPMSPathArr(){
/* /*
This will populate this.PMSLibPaths This will populate this.PMSLibPaths

View file

@ -26,11 +26,6 @@
<br /> <br />
* {{ $t("Modules.PMS.FindMedia.Description") }}</p> * {{ $t("Modules.PMS.FindMedia.Description") }}</p>
</div> </div>
<div v-if="showLibMapping">
<p><b>{{ $t("Modules.PMS.LibMapping.Name") }}</b>
<br />
* {{ $t("Modules.PMS.LibMapping.Description") }}</p>
</div>
<div v-if="showSettings"> <div v-if="showSettings">
<p><b>{{ $t("Modules.PMS.Settings.Name") }}</b> <p><b>{{ $t("Modules.PMS.Settings.Name") }}</b>
<br /> <br />