diff --git a/package-lock.json b/package-lock.json index cb3882e..bc80253 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4723,7 +4723,8 @@ "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true }, "deepmerge": { "version": "1.5.2", @@ -5705,26 +5706,6 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "escodegen": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.2.tgz", - "integrity": "sha512-InuOIiKk8wwuOFg6x9BQXbzjrQhtyXh46K9bqVTPzSo2FnyMBaYGBMC6PhQy7yxxil9vIedFBweQBMK74/7o8A==", - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "optional": true - } - } - }, "eslint": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", @@ -5914,7 +5895,8 @@ "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, "esquery": { "version": "1.3.1", @@ -5945,12 +5927,14 @@ "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true }, "etag": { "version": "1.8.1", @@ -6476,7 +6460,8 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true }, "faye-websocket": { "version": "0.10.0", @@ -6544,6 +6529,11 @@ "resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.2.tgz", "integrity": "sha512-Wz3c3XQ5xroCxd1G8b7yL0Ehkf0TC9oYC6buPFkNnU9EnaPlifeAFCyCh+iewXTyFRcg0a6j3J7FmJsIhlhBdw==" }, + "file-size": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-size/-/file-size-1.0.0.tgz", + "integrity": "sha1-MzgmfV0ga79g9N9gwZ1+04E6Rlc=" + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -8307,22 +8297,10 @@ "graceful-fs": "^4.1.6" } }, - "jsonpath": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.0.2.tgz", - "integrity": "sha512-rmzlgFZiQPc6q4HDyK8s9Qb4oxBnI5sF61y/Co5PV0lc3q2bIuRsNdueVbhoSHdKM4fxeimphOAtfz47yjCfeA==", - "requires": { - "esprima": "1.2.2", - "static-eval": "2.0.2", - "underscore": "1.7.0" - }, - "dependencies": { - "esprima": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", - "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" - } - } + "jsonpath-plus": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-4.0.0.tgz", + "integrity": "sha512-e0Jtg4KAzDJKKwzbLaUtinCn0RZseWBVRTRGihSpvFlM3wTR7ExSp+PTdeTsDrLNJUe7L7JYJe8mblHX5SCT6A==" }, "jsprim": { "version": "1.4.1", @@ -8429,6 +8407,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" @@ -9568,6 +9547,7 @@ "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.6", @@ -10594,7 +10574,8 @@ "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true }, "prepend-http": { "version": "1.0.4", @@ -12259,14 +12240,6 @@ "integrity": "sha512-QjMLR0A3WwFY2aZdV0okfFEJB5TRjkggXZjxP3A1RsWsNHNu3YPv8btmtc6iCFZ0Rul3FE93OYogvhOUClU+ng==", "dev": true }, - "static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "requires": { - "escodegen": "^1.8.1" - } - }, "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", @@ -13004,6 +12977,7 @@ "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, "requires": { "prelude-ls": "~1.1.2" } @@ -13062,11 +13036,6 @@ } } }, - "underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" - }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", @@ -14718,7 +14687,8 @@ "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true }, "wordwrap": { "version": "0.0.3", diff --git a/package.json b/package.json index ef53d94..55033a4 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,9 @@ "exceljs": "^4.0.1", "fetch": "^1.1.0", "file-saver": "^2.0.2", + "file-size": "^1.0.0", "is-electron": "^2.2.0", - "jsonpath": "^1.0.2", + "jsonpath-plus": "^4.0.0", "minimist": "^1.2.5", "node-fetch": "^2.6.0", "secure-ls": "^1.2.6", diff --git a/src/components/modules/ExportTools/definitions.json b/src/components/modules/ExportTools/definitions.json index e8ed991..2188529 100644 --- a/src/components/modules/ExportTools/definitions.json +++ b/src/components/modules/ExportTools/definitions.json @@ -21,10 +21,19 @@ }, "level": { "tommy": [ - "Title", + "Title", "Part Duration" - ], + + + + + ], + "Inspect": [ + "Part Duration" + + + ], "level1": [ "Media ID", "Title", "Sort title", "Studio", "Content Rating", "Year", @@ -187,49 +196,49 @@ "fields": { "Media ID": { - "key": "ratingKey", + "key": "$.ratingKey", "call": 1, "type": "string" }, "Title": { - "key": "title", + "key": "$.title", "call": 1, "type": "string" }, "Sort title": { - "key": "titleSort", + "key": "$.titleSort", "call": 1, "type": "string" }, "Studio": { - "key": "studio", + "key": "$.studio", "call": 1, "type": "string" }, "Content Rating": { - "key": "contentRating", + "key": "$.contentRating", "call": 1, "type": "string" }, "Year": { - "key": "year", + "key": "$.year", "call": 1, "type": "string" }, "Rating": { - "key": "rating", + "key": "$.rating", "call": 1, "type": "string" }, "Summary": { - "key": "summary", + "key": "$.summary", "call": 1, "type": "string" }, @@ -283,7 +292,7 @@ }, "Duration": { - "key": "$..duration", + "key": "$.duration", "call": 1, "type": "time" }, @@ -396,13 +405,13 @@ }, "Added": { - "key": "$..addedAt", + "key": "$.addedAt", "call": 1, "type": "datetime" }, "Updated": { - "key": "$..updatedAt", + "key": "$.updatedAt", "call": 1, "type": "datetime" }, @@ -627,6 +636,7 @@ "key": "$.Media[*].Part[*]", "call": 2, "type": "array", + "postProcess": true, "subtype": "string", "subkey": "$.size" }, @@ -634,8 +644,7 @@ { "key": "$.Media[*].Part[*]", "call": 2, - "type": "array", - "postProcess": true, + "type": "array", "subtype": "string", "subkey": "$.size" }, diff --git a/src/components/modules/ExportTools/et.js b/src/components/modules/ExportTools/et.js index b423358..f22b329 100644 --- a/src/components/modules/ExportTools/et.js +++ b/src/components/modules/ExportTools/et.js @@ -1,10 +1,15 @@ var def = JSON.parse(JSON.stringify(require('./definitions.json'))); const log = require('electron-log'); -import {wtconfig, wtutils} from '../../../wtutils' +log.transports.console.level = false; +import {wtconfig, wtutils} from '../../../wtutils' +import filesize from 'filesize'; +var path = require("path"); const fetch = require('node-fetch'); -const jp = require('jsonpath') +//const {jp} = require('jsonpath'); + +const {JSONPath} = require('jsonpath-plus'); const et = new class ET { constructor() { @@ -12,7 +17,7 @@ const et = new class ET { async getItemData(baseURL, accessToken, element) { - const url = baseURL + element + '?checkFiles=1&includeRelated=1&includeExtras=1&includeBandwidths=1&includeChapters=1'; + const url = baseURL + element + '?checkFiles=1&includeRelated=0&includeExtras=1&includeBandwidths=1&includeChapters=1'; var headers = { "Accept": "application/json", "X-Plex-Token": accessToken @@ -27,8 +32,7 @@ const et = new class ET { getRealLevelName(level, libType) { // First get the real name of the level, and not just the display name - const levelName = def[libType]['levels'][level] - log.debug(`ET LevelName: ${levelName}`) + const levelName = def[libType]['levels'][level] return levelName } @@ -136,9 +140,9 @@ const et = new class ET { const result = {} let response = await fetch(url, { method: 'GET', headers: headers}); let resp = await response.json(); - const respJSON = await Promise.resolve(resp) - result['size'] = jp.value(respJSON, '$.MediaContainer.totalSize'); - result['name'] = jp.value(respJSON, '$.MediaContainer.librarySectionTitle'); + const respJSON = await Promise.resolve(resp) + result['size'] = JSONPath({path: '$.MediaContainer.totalSize', json: respJSON}); + result['name'] = JSONPath({path: '$.MediaContainer.librarySectionTitle', json: respJSON}); return result } } @@ -213,20 +217,49 @@ const excel2 = new class Excel { } async postProcess(name, val){ - log.debug(`Start postProcess. name: ${name} - val: ${val}`) - var retVal - switch ( String(name) ){ - - case "MetaDB Link": - retVal = val.split("?")[0]; - break; - case "MetaData Language": - retVal = val.split("=")[1]; - break; - default: - console.log('Ged NO HIT:' + name + 'END') - break; - } + log.silly(`Start postProcess. name: ${name} - val: ${val}`) + const valArray = val.split(wtconfig.get('ET.ArraySep', ' - ')) + let retArray = [] + let x, retVal + try { + switch ( String(name) ){ + case "MetaDB Link": + for (x=0; x { excel2.AddRow(sheet, element) - }); - } - - - - /* console.log('Ged Cava1: ' + JSON.stringify(keyVal)) - - for (var i=0; i { - excel2.AddRow(sheet, element) - }); - } */ + }); + log.silly(`End addRowToSheet. Row: ${JSON.stringify(row)}`) + } async createOutFile( libName, level, libType, outType, data, baseURL, accessToken ) { @@ -439,27 +395,27 @@ const excel2 = new class Excel { // Now we need to find out how many calls to make const call = await et.getLevelCall(libType, level) if ( call == 1 ) - { - // Single call needed, so simply pass along the individual items - const items = jp.nodes(data, '$.MediaContainer.Metadata[*]') - for (var x=0; x)'); @@ -75,7 +74,8 @@ if (outDir) // We export library named "Ged" of the type movie with a level of "Level 2" const libName = 'Ged' -const level = 'Tommy' +//const level = 'Tommy' +const level = 'Level 6' const libType = 'movie' libType @@ -121,7 +121,7 @@ const testimp3 = require('./components/modules/ExportTools/testimp3.json') const testimp = require('./components/modules/ExportTools/testimp.json') const testimp1 = require('./components/modules/ExportTools/testimp1.json') const AllMovies = require('./components/modules/ExportTools/AllMovies.json') - +const Fast = require('./components/modules/ExportTools/2Fast.json') // Just use to avoid errors later testimp4 @@ -129,12 +129,15 @@ testimp3 testimp testimp1 AllMovies +Fast // EXCEL Stuff // Add a couple of Rows -excel2.createOutFile( libName, level, libType, 'xlsx', testimp3, baseURI, accessToken ); -//excel2.createOutFile( libName, level, libType, 'xlsx', AllMovies, baseURI, accessToken ); +//excel2.createOutFile( libName, level, libType, 'xlsx', testimp1, baseURI, accessToken ); +//excel2.createOutFile( libName, level, libType, 'xlsx', testimp3, baseURI, accessToken ); +//excel2.createOutFile( libName, level, libType, 'xlsx', Fast, baseURI, accessToken ); +excel2.createOutFile( libName, level, libType, 'xlsx', AllMovies, baseURI, accessToken ); new Vue({ render: h => h(App),