diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e2e67..2bb268e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [#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) * [#603 Find Missing Episodes Reorder columns](https://github.com/WebTools-NG/WebTools-NG/issues/603) (Enhancement) +* [#596 Find missing episodes specials](https://github.com/WebTools-NG/WebTools-NG/issues/596) (Enhancement) ## V1.1.1 ( 20220917 ) diff --git a/public/locales/en.json b/public/locales/en.json index f6d8525..31b3742 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -242,7 +242,8 @@ "Note": "Note: * Click here for general settings regarding export *", "Return": "Return to @:Modules.ET.Name", "NoTimeStamp": "Don't add a timestamp to export file name", - "NoItemRange": "Don't add item range to export file name" + "NoItemRange": "Don't add item range to export file name", + "FindMissingNoSpecials": "Ignore specials in 'Find missing episodes'" }, "LevelInfo": "Export level determines which data are going to be exported.", "SelectLevel": "Select level", diff --git a/src/components/modules/ExportTools/Settings/settings.vue b/src/components/modules/ExportTools/Settings/settings.vue index 2326115..1489f10 100644 --- a/src/components/modules/ExportTools/Settings/settings.vue +++ b/src/components/modules/ExportTools/Settings/settings.vue @@ -80,7 +80,8 @@ { text: i18n.t('Modules.ET.Settings.suggestedFileNoExtra'), value: 'suggestedFileNoExtra' }, { text: i18n.t('Modules.ET.Settings.suggestedUseOrigenTitle'), value: 'suggestedUseOrigenTitle' }, { text: i18n.t('Modules.ET.Settings.NoTimeStamp'), value: 'NoTimeStamp' }, - { text: i18n.t('Modules.ET.Settings.NoItemRange'), value: 'NoItemRange' } + { text: i18n.t('Modules.ET.Settings.NoItemRange'), value: 'NoItemRange' }, + { text: i18n.t('Modules.ET.Settings.FindMissingNoSpecials'), value: 'noSpecials' } ], SelectedMoviesIDOptions: ['imdb', 'tmdb'], SelectedMoviesID: '', @@ -97,7 +98,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'); }, getDefaults(){ - const cbItems = ["ExpCSV","ExpXLSX", "OrgTitleNull", "SortTitleNull", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen", "ExportPostersArtsTree"]; + const cbItems = ["ExpCSV","ExpXLSX", "OrgTitleNull", "SortTitleNull", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen", "ExportPostersArtsTree", "noSpecials"]; for(let i = 0; i < cbItems.length; i++){ if (wtconfig.get("ET." + cbItems[i], false)){ this.cbSelected.push(cbItems[i]); @@ -112,7 +113,7 @@ }, filterTable(){ this.$nextTick(()=>{console.log(this.cbSelected);}) - for( var cbItem of ["ExpCSV","ExpXLSX","OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen", "ExportPostersArtsTree"]){ + for( var cbItem of ["ExpCSV","ExpXLSX","OrgTitleNull", "SortTitleNull", "AutoXLSCol", "AutoXLSRow", "suggestedFileNoExtra", "suggestedUseOrigenTitle", "NoTimeStamp", "NoItemRange", "ArtPostersOrigen", "ExportPostersArtsTree", "noSpecials"]){ wtconfig.set("ET." + cbItem, (this.cbSelected.includes(cbItem))) } this.PosterDimDisabled = this.cbSelected.includes('ArtPostersOrigen'); diff --git a/src/components/modules/ExportTools/defs/def-Fields.json b/src/components/modules/ExportTools/defs/def-Fields.json index 0e9ed91..50d2834 100644 --- a/src/components/modules/ExportTools/defs/def-Fields.json +++ b/src/components/modules/ExportTools/defs/def-Fields.json @@ -437,9 +437,9 @@ "postProcess": true }, "Episode Count (PMS)": { - "key": "$.leafCount", + "key": "$.title", "call": 1, - "type": "string", + "type": "int", "postProcess": true }, "Export Art": @@ -1088,9 +1088,9 @@ "postProcess": true }, "Season Count (PMS)": { - "key": "$.childCount", + "key": "$.title", "call": 1, - "type": "string", + "type": "int", "postProcess": true }, "Seasons (Cloud)": { diff --git a/src/components/modules/ExportTools/scripts/ethelper.js b/src/components/modules/ExportTools/scripts/ethelper.js index f01cbf4..d90c3f6 100644 --- a/src/components/modules/ExportTools/scripts/ethelper.js +++ b/src/components/modules/ExportTools/scripts/ethelper.js @@ -556,12 +556,14 @@ const etHelper = new class ETHELPER { } break; case "Episode Count (PMS)": - this.Settings.showInfo['PMSEPCount'] = parseInt(val); - retVal = val; + retVal = wtconfig.get('ET.NotAvail'); + if ( this.Settings.showInfo['Episode Count (PMS)']){ + retVal = this.Settings.showInfo['Episode Count (PMS)']; + } break; case "Missing": retVal = i18n.t('Common.Ok'); - if ( this.Settings.showInfo['Episode Count (Cloud)'] != this.Settings.showInfo['PMSEPCount']){ + if ( this.Settings.showInfo['Episode Count (Cloud)'] != this.Settings.showInfo['Episode Count (PMS)']){ retVal = "Episode mismatch" } if (!this.Settings.showInfo['Episode Count (Cloud)']){ @@ -864,8 +866,10 @@ const etHelper = new class ETHELPER { } break; case "Season Count (PMS)": - this.Settings.showInfo['PMSSCount'] = parseInt(val); - retVal = val; + retVal = wtconfig.get('ET.NotAvail'); + if ( this.Settings.showInfo['Season Count (PMS)']){ + retVal = this.Settings.showInfo['Season Count (PMS)']; + } break; case "Seasons (Cloud)": retVal = wtconfig.get('ET.NotAvail'); @@ -1048,16 +1052,27 @@ const etHelper = new class ETHELPER { } else { this.Settings.showInfo['showOrdering'] = await this.SelectedLibShowOrdering(); } - console.log('Ged 88-3', JSON.stringify(resp)) let seasonCountPMS = {}; + let seasonCount = 0; + let episodeCount = 0; 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]; + if ( JSONPath({path: `$..index`, json: child})[0] == 0) { + if ( !wtconfig.get('ET.noSpecials') ){ + seasonCountPMS[JSONPath({path: `$..index`, json: child})] = JSONPath({path: `$..leafCount`, json: child})[0]; + seasonCount++; + episodeCount = episodeCount + JSONPath({path: `$..leafCount`, json: child})[0]; + } + } else { + seasonCountPMS[JSONPath({path: `$..index`, json: child})] = JSONPath({path: `$..leafCount`, json: child})[0]; + seasonCount++; + episodeCount = episodeCount + JSONPath({path: `$..leafCount`, json: child})[0]; + } } this.Settings.showInfo['Seasons (PMS)'] = seasonCountPMS; - console.log('Ged 77-3', JSON.stringify(this.Settings.showInfo['Seasons (PMS)'])) - + this.Settings.showInfo['Episode Count (PMS)'] = episodeCount; + this.Settings.showInfo['Season Count (PMS)'] = seasonCount; } async addRowToTmp( { data }) { diff --git a/src/components/modules/General/tmdb.js b/src/components/modules/General/tmdb.js index ce0a415..77b5ced 100644 --- a/src/components/modules/General/tmdb.js +++ b/src/components/modules/General/tmdb.js @@ -1,14 +1,10 @@ // TMDB stuff used -//import store from '../../../store'; -//import { wtconfig } from './wtutils'; import axios from 'axios'; -import { wtutils } from './wtutils'; +import { wtconfig, wtutils } from './wtutils'; const log = require('electron-log'); const {JSONPath} = require('jsonpath-plus'); - - const tmdb = new class TMDB { constructor() { this.baseUrl = 'https://www.themoviedb.org/'; @@ -35,6 +31,8 @@ const tmdb = new class TMDB { const apiKey = wtutils.envVarLocal( 'Key_tmdb' ); url = `${url}&api_key=${apiKey}`; const result = {}; + let seasonCount = 0; + let episodeCount = 0; await axios({ method: 'get', url: url, @@ -43,13 +41,21 @@ const tmdb = new class TMDB { .then((response) => { log.debug('[tmdb.js] (getTMDBShowInfo) - Response from getTMDBShowInfo recieved'); result['Status (Cloud)'] = JSONPath({ path: "$.status", json: response.data })[0]; - result['Episode Count (Cloud)'] = JSONPath({ path: "$.number_of_episodes", json: response.data })[0]; - result['Season Count (Cloud)'] = JSONPath({ path: "$.number_of_seasons", json: response.data })[0]; // Now get season/episode const seasons = JSONPath({ path: "$..seasons[*]", json: response.data }) let Seasons_Cloud = {}; for ( var idx in seasons ){ - Seasons_Cloud[JSONPath({ path: "$..season_number", json: seasons[idx]})] = JSONPath({ path: "$..episode_count", json: seasons[idx]})[0]; + if ( JSONPath({ path: "$..season_number", json: seasons[idx]}) == 0) { + if ( !wtconfig.get('ET.noSpecials') ){ + Seasons_Cloud[JSONPath({ path: "$..season_number", json: seasons[idx]})] = JSONPath({ path: "$..episode_count", json: seasons[idx]})[0]; + seasonCount++; + episodeCount = episodeCount + JSONPath({ path: "$..episode_count", json: seasons[idx]})[0]; + } + } else { + Seasons_Cloud[JSONPath({ path: "$..season_number", json: seasons[idx]})] = JSONPath({ path: "$..episode_count", json: seasons[idx]})[0]; + seasonCount++; + episodeCount = episodeCount + JSONPath({ path: "$..episode_count", json: seasons[idx]})[0]; + } } result['Seasons (Cloud)'] = Seasons_Cloud; }) @@ -75,6 +81,8 @@ const tmdb = new class TMDB { return result; } }) + result['Episode Count (Cloud)'] = episodeCount; + result['Season Count (Cloud)'] = seasonCount; log.silly(`[tmdb.js] (getTMDBShowInfo) - Returning: ${JSON.stringify(result)}`); return result; } diff --git a/src/components/modules/General/tvdb.js b/src/components/modules/General/tvdb.js index 29a375b..dc56a41 100644 --- a/src/components/modules/General/tvdb.js +++ b/src/components/modules/General/tvdb.js @@ -1,8 +1,6 @@ // TVDB stuff used -//import store from '../../../store'; -//import { wtconfig } from './wtutils'; import axios from 'axios'; -import { wtutils } from './wtutils'; +import { wtconfig, wtutils } from './wtutils'; const log = require('electron-log'); const {JSONPath} = require('jsonpath-plus'); @@ -43,10 +41,11 @@ const tvdb = new class TVDB { } async getTVDBShow( {tvdbId: tvdbId, bearer: bearer, title: title, order: order} ){ - log.info(`[tvdb.js] (getTVDBShowDVD) - Getting tmdb ${order} info for ${tvdbId}`); + log.info(`[tvdb.js] (getTVDBShowDVD) - Getting tmdb ${order} info for ${tvdbId} with a title of: ${title}`); let url = `${this.baseAPIUrl}series/${tvdbId}/episodes/${order}?page=0`; let headers = this.headers; let seasons = {}; + let episodeCount = 0; headers["Authorization"] = `Bearer ${bearer}`; let result = {}; await axios({ @@ -55,29 +54,33 @@ const tvdb = new class TVDB { headers: headers }) .then((response) => { - log.debug('[tvdb.js] (getTVDBShow) - Response from getTVDBShow recieved'); + log.debug('[tvdb.js] (getTVDBShow) - Response from getTVDBShow recieved. Use silly logging to see the data'); + log.silly(JSON.stringify(response.data)) result['Link (Cloud)'] = `https://thetvdb.com/series/${JSONPath({ path: "$..slug", json: response.data })[0]}`; result['Status (Cloud)'] = JSONPath({ path: "$..status.name", json: response.data })[0]; // Sadly, the tvdb doesn't have a count field for seasons and episodes, so we need to count each :-( let episodes = JSONPath({ path: "$..episodes[*]", json: response.data }); // Gather season/episode info for ( var idx in episodes ){ - const season = JSONPath({ path: "$..seasonNumber", json: episodes[idx] })[0]; - if( Object.prototype.hasOwnProperty.call(seasons, season) ){ - seasons[season] = seasons[season] + 1; - } else { - seasons[season] = 1; - } - } - // Get Season Count - result['Season Count (Cloud)'] = Object.keys(seasons).length; - // Get episode count - let episodeCount = 0; - Object.entries(seasons).forEach(([key, value]) => { - episodeCount = episodeCount + parseInt(value); - key; - }) - result['Episode Count (Cloud)'] = episodeCount; + const seasonNumber = JSONPath({ path: "$..seasonNumber", json: episodes[idx] })[0]; + if ( JSONPath({ path: "$..seasonNumber", json: episodes[idx] })[0] == 0) { + if ( !wtconfig.get('ET.noSpecials') ){ + episodeCount++; + if( Object.prototype.hasOwnProperty.call(seasons, seasonNumber) ){ + seasons[seasonNumber] = seasons[seasonNumber] + 1; + } else { + seasons[seasonNumber] = 1; + } + } + } else { + episodeCount++; + if( Object.prototype.hasOwnProperty.call(seasons, seasonNumber) ){ + seasons[seasonNumber] = seasons[seasonNumber] + 1; + } else { + seasons[seasonNumber] = 1; + } + } + } result['Seasons (Cloud)'] = seasons; }) .catch(function (error) { @@ -102,6 +105,8 @@ const tvdb = new class TVDB { return result; } }) + result['Episode Count (Cloud)'] = episodeCount; + result['Season Count (Cloud)'] = Object.keys(seasons).length; log.silly(`[tmdb.js] (getTVDBShowDVD) - Returning: ${JSON.stringify(result)}`); return result; }