Merge pull request #564 from WebTools-NG/#561-Find-episodes-I-miss-in-my-library

#561 find episodes i miss in my library
This commit is contained in:
Tommy Mikkelsen 2022-08-12 00:03:52 +02:00 committed by GitHub
commit 0204adf94b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 196 additions and 12 deletions

View file

@ -14,6 +14,7 @@
* [#550 Export posters for Seasons and Shows](https://github.com/WebTools-NG/WebTools-NG/issues/550) (Enhancement)
* [#551 Exporting posters and Arts into tree](https://github.com/WebTools-NG/WebTools-NG/issues/551) (Enhancement)
* [#553 Request Tooltips be replaced with Info or ? icons](https://github.com/WebTools-NG/WebTools-NG/issues/553) (Enhancement)
* [#561 Find episodes I miss in my library](https://github.com/WebTools-NG/WebTools-NG/issues/561) (Enhancement)
## V1.0.0 First Official Release (20220724)

View file

@ -390,7 +390,7 @@
"key": "$.createdAtTZOffset",
"call": 1,
"type": "time"
},
},
"Deleted":
{
"key": "$.deletedAt",
@ -617,7 +617,7 @@
"key": "$.leafCount",
"call": 1,
"type": "string"
},
},
"Key":
{
"key": "$.ratingKey",
@ -1118,6 +1118,20 @@
"call": 1,
"type": "string"
},
"Show Episode Count (PMS)":
{
"key": "$.leafCount",
"call": 1,
"type": "string",
"postProcess": true
},
"Show Episode Count (TMDB)":
{
"key": "$.parentTitle",
"call": 1,
"type": "string",
"postProcess": true
},
"Show Prefs Delete episodes after playing":
{
"key": "$..Preferences.Setting[?(@.id=='autoDeletionItemPolicyWatchedLibrary')].value",
@ -1174,12 +1188,33 @@
"include": "includePreferences=1",
"postProcess": true
},
"Show Season Count (PMS)":
{
"key": "$.childCount",
"call": 1,
"type": "string",
"postProcess": true
},
"Show Season Count (TMDB)":
{
"key": "$.parentTitle",
"call": 1,
"type": "string",
"postProcess": true
},
"Missing":
{
"key": "$.parentTitle",
"call": 1,
"type": "string",
"postProcess": true
},
"Show Title":
{
"key": "$.parentTitle",
"call": 1,
"type": "string"
},
},
"Similar":
{
"key": "$.Similar[*]",
@ -1397,6 +1432,13 @@
"subkey": "$.id",
"postProcess": true
},
"TMDB Status":
{
"key": "$.title",
"call": 1,
"type": "string",
"postProcess": true
},
"Updated":
{
"key": "$.updatedAt",

View file

@ -66,18 +66,20 @@
"levels": {
"Level 1": "level1",
"Level 2": "level2",
"All": "all"
"All": "all",
"Find Missing Episodes": "findmissingEp"
},
"LevelCount": {
"Level 1": 1,
"Level 2": 1,
"All": 2,
"all": 2
"Find Missing Episodes": 1
},
"Include": {
"Level 1": "",
"Level 2": "",
"all": "includePreferences=1"
"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",
"All": "includePreferences=1"
}
},
"10": {

View file

@ -71,6 +71,17 @@
"TVDB Language (Legacy)",
"Updated",
"Year"
],
"findmissingEp": [
"Key",
"Title",
"TMDB Link",
"Show Episode Count (PMS)",
"Show Episode Count (TMDB)",
"Show Season Count (PMS)",
"Show Season Count (TMDB)",
"TMDB Status",
"Missing"
]
}
}

View file

@ -9,6 +9,7 @@ import filesize from 'filesize';
import Excel from 'exceljs';
import { status } from '../../General/status';
import { time } from '../../General/time';
import { tmdb } from '../../General/tmdb';
var path = require("path");
var sanitize = require("sanitize-filename");
@ -306,7 +307,8 @@ const etHelper = new class ETHELPER {
fileMinor: null,
element: null,
SelectedMoviesID: null,
SelectedShowsID: wtconfig.get("ET.SelectedShowsID", "tmdb")
SelectedShowsID: wtconfig.get("ET.SelectedShowsID", "tmdb"),
tmdbShowInfo: null
};
this.PMSHeader = wtutils.PMSHeader;
@ -539,15 +541,20 @@ const etHelper = new class ETHELPER {
const valArray = val.split(wtconfig.get('ET.ArraySep', ' * '));
switch ( String(name) ){
case "Audience Rating":
{
retVal = val.substring(0, 3);
break;
case "Missing":
retVal = i18n.t('Common.Ok');
if ( this.Settings.tmdbShowInfo['TMDBEPCount'] != this.Settings.tmdbShowInfo['PMSEPCount']){
retVal = "Episode mismatch"
}
if (!this.Settings.tmdbShowInfo['TMDBEPCount']){
retVal = "No tmdb Guid found"
}
break;
case "Rating":
{
retVal = val.substring(0, 3);
break;
}
case "Suggested File Name":
retVal = await this.getSuggestedFileName( {data: data} );
break;
@ -773,10 +780,29 @@ const etHelper = new class ETHELPER {
for(const item of guidArr) {
if ( item.startsWith("tmdb://") )
{
retVal = 'https://www.themoviedb.org/movie/' + item.substring(7);
const mediaType = JSONPath({path: '$.type', json: data})[0];
if ( mediaType == 'movie'){
retVal = 'https://www.themoviedb.org/movie/' + item.substring(7);
}
/* else if ( mediaType == 'episode'){
const season = 1
const episode = 1
retVal = `https://www.themoviedb.org/tv/${item.substring(7)}/season/${season}/episode/${episode}`
}
*/
else {
retVal = 'https://www.themoviedb.org/tv/' + item.substring(7);
}
}
}
break;
case "TMDB Status":
retVal = wtconfig.get('ET.NotAvail');
if ( this.Settings.tmdbShowInfo['TMDBStatus']){
retVal = this.Settings.tmdbShowInfo['TMDBStatus'];
}
break;
case "PMS Media Path":
retVal = wtconfig.get('ET.NotAvail');
var hashes = await this.getHash(data);
@ -815,6 +841,16 @@ const etHelper = new class ETHELPER {
//var path = require('path');
retVal = path.join('Metadata', libTypeName, sha1[0], sha1.slice(1) + '.bundle');
break;
case "Show Episode Count (PMS)":
this.Settings.tmdbShowInfo['PMSEPCount'] = parseInt(val);
retVal = val;
break;
case "Show Episode Count (TMDB)":
retVal = wtconfig.get('ET.NotAvail');
if ( this.Settings.tmdbShowInfo['TMDBEPCount']){
retVal = String(this.Settings.tmdbShowInfo['TMDBEPCount']);
}
break;
case "Show Prefs Episode sorting":
switch (val){
case "-1":
@ -935,6 +971,16 @@ const etHelper = new class ETHELPER {
break;
}
break;
case "Show Season Count (PMS)":
this.Settings.tmdbShowInfo['PMSSCount'] = parseInt(val);
retVal = val;
break;
case "Show Season Count (TMDB)":
retVal = wtconfig.get('ET.NotAvail');
if ( this.Settings.tmdbShowInfo['TMDBSCount']){
retVal = String(this.Settings.tmdbShowInfo['TMDBSCount']);
}
break;
default:
log.error(`[ethelper.js] (postProcess) no hit for: ${name}`)
break;
@ -947,6 +993,18 @@ const etHelper = new class ETHELPER {
}
async addRowToTmp( { data }) {
if ( this.Settings.levelName == 'Find Missing Episodes'){
// 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`);
this.Settings.tmdbShowInfo = {};
const tmdbId = String(JSONPath({ path: "$.Guid[?(@.id.startsWith('tmdb'))].id", json: data })).substring(7,);
if ( tmdbId){
this.Settings.tmdbShowInfo = await tmdb.getTMDBShowInfo(tmdbId);
} else {
const title = JSONPath({ path: "$.title", json: data });
log.error(`[ethelper.js] (addRowToTmp) - No tmdb guid found for ${title}`);
}
}
this.Settings.currentItem +=1;
status.updateStatusMsg( status.RevMsgType.Items, i18n.t('Common.Status.Msg.ProcessItem_0_1', {count: this.Settings.count, total: this.Settings.endItem}));
log.debug(`[ethelper.js] (addRowToTmp) Start addRowToTmp item ${this.Settings.currentItem} (Switch to Silly log to see contents)`)
@ -1559,7 +1617,6 @@ const etHelper = new class ETHELPER {
for(let res of resolutions) {
entry = {};
res = res.replace('*', 'x');
console.log('Ged 21-3', res)
// Build up pic url
const hight = res.split('x')[1].trim();
const width = res.split('x')[0].trim();

View file

@ -0,0 +1,71 @@
// TMDB stuff used
//import store from '../../../store';
//import { wtconfig } from './wtutils';
import axios from 'axios';
const log = require('electron-log');
const {JSONPath} = require('jsonpath-plus');
const tmdb = new class TMDB {
constructor() {
this.baseUrl = 'https://www.themoviedb.org/';
this.baseAPIUrl = 'https://api.themoviedb.org';
this.BearerKey = 'eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwNzZjOTRlOTM5YThkNzhjOTg1NGY4MTc0YTI5NGVhYSIsInN1YiI6IjYyNTA5NjcxYzYxM2NlMDA1MWYwMjMyYSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.Ch9U33tcVeh5qbVUG12LZ7qX8ulbIZjURlyGuj3ULBk';
this.apiKey = '076c94e939a8d78c9854f8174a294eaa';
}
get tmdbHeader(){
var headers = {
"Accept": "application/json",
"X-Plex-Product": this.AppName,
"X-Plex-Version": this.AppVersion,
"X-Plex-Device": this.Platform
}
return headers
}
async getTMDBShowInfo( tmdbId ){
log.info(`[tmdb.js] (getTMDBShowInfo) - Getting tmdb info for ${tmdbId}`);
let url = `${this.baseAPIUrl}/3/tv/${tmdbId}?language=en-US`
// api_key=<<api_key>>
let header = {
"Accept": "application/json"
};
log.info(`[tmdb.js] (getTMDBShowInfo) - Url is ${url}`)
url = `${url}&api_key=${this.apiKey}`;
const result = {};
await axios({
method: 'get',
url: url,
headers: header
})
.then((response) => {
log.debug('[tmdb.js] (getTMDBShowInfo) - Response from getTMDBShowInfo recieved');
result['TMDBStatus'] = JSONPath({ path: "$.status", json: response.data })[0];
result['TMDBEPCount'] = JSONPath({ path: "$.number_of_episodes", json: response.data })[0];
result['TMDBSCount'] = JSONPath({ path: "$.number_of_seasons", json: response.data })[0];
result['seasons'] = {};
const arrSeasons = JSONPath({ path: "$.seasons", json: response.data })[0];
for (const season of arrSeasons) {
const season_number = JSONPath({ path: "$.season_number", json: season })[0];
result['seasons'][season_number] = JSONPath({ path: "$.episode_count", json: season });
}
})
.catch(function (error) {
if (error.response) {
log.error('getTMDBShowInfo: ' + error.response.data);
alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message);
} else if (error.request) {
log.error('getTMDBShowInfo: ' + error.request);
} else {
log.error('getTMDBShowInfo: ' + error.message);
}
})
return result;
}
}
export { tmdb };