diff --git a/CHANGELOG.md b/CHANGELOG.md index 5184735..bf2c2c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ **Changes**: * [#598 Refactor tvdb rutines](https://github.com/WebTools-NG/WebTools-NG/issues/598) (Internal) +* [#597 Add PMS Season/EP Count to FindMissing](https://github.com/WebTools-NG/WebTools-NG/issues/597) (Enhancement) ## V1.1.1 ( 20220917 ) diff --git a/src/components/modules/ExportTools/defs/def-Fields.json b/src/components/modules/ExportTools/defs/def-Fields.json index c4cb2cd..0e9ed91 100644 --- a/src/components/modules/ExportTools/defs/def-Fields.json +++ b/src/components/modules/ExportTools/defs/def-Fields.json @@ -1099,6 +1099,12 @@ "type": "string", "postProcess": true }, + "Seasons (PMS)": { + "key": "$.title", + "call": 1, + "type": "string", + "postProcess": true + }, "Series Title": { "key": "$.grandparentTitle", "call": 1, diff --git a/src/components/modules/ExportTools/defs/def-Levels.json b/src/components/modules/ExportTools/defs/def-Levels.json index 93dea2f..eb6076d 100644 --- a/src/components/modules/ExportTools/defs/def-Levels.json +++ b/src/components/modules/ExportTools/defs/def-Levels.json @@ -78,7 +78,7 @@ "Include": { "Level 1": "", "Level 2": "", - "Find Missing Episodes": "includeGuids=1&checkFiles=0&includeRelated=0&includeExtras=0&includeBandwidths=0&includeChapters=0&excludeElements=Actor,Collection,Country,Director,Genre,Label,Mood,Producer,Similar,Writer,Role&excludeFields=summary,tagline", + "Find Missing Episodes": "includeGuids=1&includeChildren=1&checkFiles=0&includeRelated=0&includeExtras=0&includeBandwidths=0&includeChapters=0&excludeElements=Actor,Collection,Country,Director,Genre,Label,Mood,Producer,Similar,Writer,Role&excludeFields=summary,tagline", "All": "includePreferences=1" } }, diff --git a/src/components/modules/ExportTools/defs/def-Show.json b/src/components/modules/ExportTools/defs/def-Show.json index 94b55dc..d5ad2bb 100644 --- a/src/components/modules/ExportTools/defs/def-Show.json +++ b/src/components/modules/ExportTools/defs/def-Show.json @@ -80,6 +80,7 @@ "Status (Cloud)", "Episode Count (PMS)", "Season Count (PMS)", + "Seasons (PMS)", "Episode Count (Cloud)", "Season Count (Cloud)", "Seasons (Cloud)", diff --git a/src/components/modules/ExportTools/scripts/ethelper.js b/src/components/modules/ExportTools/scripts/ethelper.js index 08f6e8e..f01cbf4 100644 --- a/src/components/modules/ExportTools/scripts/ethelper.js +++ b/src/components/modules/ExportTools/scripts/ethelper.js @@ -873,6 +873,12 @@ const etHelper = new class ETHELPER { retVal = JSON.stringify(this.Settings.showInfo['Seasons (Cloud)']); } break; + case "Seasons (PMS)": + retVal = wtconfig.get('ET.NotAvail'); + if ( this.Settings.showInfo['Seasons (PMS)']){ + retVal = JSON.stringify(this.Settings.showInfo['Seasons (PMS)']); + } + break; case "Sort Season by": retVal = this.Settings.showInfo['showOrdering']; break; @@ -1031,7 +1037,7 @@ const etHelper = new class ETHELPER { // Get specific show ordering async getShowOrdering( { ratingKey } ){ - let url = `${this.Settings.baseURL}/library/metadata/${ratingKey}?includeGuids=0&includePreferences=1&checkFiles=0&includeRelated=0&includeExtras=0&includeBandwidths=0&includeChapters=0&excludeElements=Actor,Collection,Country,Director,Genre,Label,Mood,Producer,Similar,Writer,Role&excludeFields=summary,tagline`; + let url = `${this.Settings.baseURL}/library/metadata/${ratingKey}?includeGuids=1&includeChildren=1&includePreferences=1&checkFiles=0&includeRelated=0&includeExtras=0&includeBandwidths=0&includeChapters=0&excludeElements=Actor,Collection,Country,Director,Genre,Label,Mood,Producer,Similar,Writer,Role&excludeFields=summary,tagline`; this.PMSHeader["X-Plex-Token"] = this.Settings.accessToken; log.verbose(`[ethelper.js] (getShowOrdering) Calling url: ${url}`); let response = await fetch(url, { method: 'GET', headers: this.PMSHeader}); @@ -1042,6 +1048,16 @@ const etHelper = new class ETHELPER { } else { this.Settings.showInfo['showOrdering'] = await this.SelectedLibShowOrdering(); } + console.log('Ged 88-3', JSON.stringify(resp)) + let seasonCountPMS = {}; + const children = JSONPath({path: `$..Children.Metadata[*]`, json: resp}); + for (var idx in children){ + const child = children[idx]; + seasonCountPMS[JSONPath({path: `$..index`, json: child})] = JSONPath({path: `$..leafCount`, json: child})[0]; + } + this.Settings.showInfo['Seasons (PMS)'] = seasonCountPMS; + console.log('Ged 77-3', JSON.stringify(this.Settings.showInfo['Seasons (PMS)'])) + } async addRowToTmp( { data }) { @@ -1050,7 +1066,6 @@ const etHelper = new class ETHELPER { let id, ids, attributename; await this.getShowOrdering( { "ratingKey": data["ratingKey"] } ); if ( this.Settings.showInfo["showOrdering"] == "tmdbAiring" ){ - console.log('Ged 66-3 tmdb airing') // Special level, so we need to get info from tmdb log.info(`[ethelper.js] (addRowToTmp) - Level "Find Missing Episodes" selected, so we must contact tmdb`); ids = JSONPath({ path: "$.Guid[?(@.id.startsWith('tmdb'))].id", json: data }); @@ -1073,7 +1088,6 @@ const etHelper = new class ETHELPER { this.Settings.showInfo["showOrdering"] = "TMDB Airing"; this.Settings.showInfo["Status"] = this.Settings.showInfo["TMDBStatus"]; } else { - console.log('Ged 66-3-2 use tvdb') // Special level, so we need to get info from tvdb log.info(`[ethelper.js] (addRowToTmp) - Level "Find Missing Episodes" selected, so we must contact tvdb`); ids = JSONPath({ path: "$.Guid[?(@.id.startsWith('tvdb'))].id", json: data }); @@ -1342,7 +1356,6 @@ const etHelper = new class ETHELPER { let chunck; // placeholder for items fetched let chunckItems; // Array of items in the chunck this.Settings.element = this.getElement(); -// let postURI = this.getPostURI(); // Get the fields for this level do // Walk section in steps {