diff --git a/CHANGELOG.md b/CHANGELOG.md index f8bc611..ae86e9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # ![Logo](https://github.com/WebTools-NG/WebTools-NG/blob/master/src/assets/WebTools-48x48.png) WebTools-ng Change log +## V1.1.3 ( Not released yet ) + +**Note**: In this version, the following is disabled: + +* Export to xlsx format ([See #331](https://github.com/WebTools-NG/WebTools-NG/issues/331)) +* Photo export + +**Changes**: + +* [#563 Viewstate copy and User Ratings](https://github.com/WebTools-NG/WebTools-NG/issues/563) (Enhancement) +* [#610 Viewstate Copy doesn't copy partial viewed offsets](https://github.com/WebTools-NG/WebTools-NG/issues/610) (Bug) + ## V1.1.2 ( 20220925 ) **Note**: In this version, the following is disabled: diff --git a/package-lock.json b/package-lock.json index da6c91e..6a8225d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "webtools-ng", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "webtools-ng", - "version": "1.1.2", + "version": "1.1.3", "hasInstallScript": true, "license": "MPL-2.0", "dependencies": { diff --git a/package.json b/package.json index 07bb153..73c2f9e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "webtools-ng", "productName": "WebTools-NG", - "version": "1.1.2", + "version": "1.1.3", "description": "WebTools Next Generation 4 Plex", "author": "dane22 & CPSO", "license": "MPL-2.0", diff --git a/src/components/modules/PMS/ViewState/scripts/viewstate.js b/src/components/modules/PMS/ViewState/scripts/viewstate.js index 66c1b82..555a724 100644 --- a/src/components/modules/PMS/ViewState/scripts/viewstate.js +++ b/src/components/modules/PMS/ViewState/scripts/viewstate.js @@ -28,7 +28,7 @@ const viewstate = new class ViewState { this.genRep = false; this.outFile = '', this.csvStream, - this.headers = '"library","ratingKey","title","viewCount","viewOffset"' + this.headers = '"Library","RatingKey","Title","View Count","View Offset","User Ratings"' } async setOwnerStatus( Usr, data ){ @@ -85,23 +85,34 @@ const viewstate = new class ViewState { } async bumpViewCount( media ){ - const ratingKey = JSONPath({path: `$..ratingKey`, json: media}); - const title = JSONPath({path: `$..title`, json: media}); - const viewCount = JSONPath({path: `$..viewCount`, json: media}); - const viewOffset = JSONPath({path: `$..viewOffset`, json: media}); - const duration = JSONPath({path: `$..duration`, json: media}); + const ratingKey = media['ratingKey']; + const title = media['title']; + const viewCount = media['viewCount']; + const duration = media['duration']; + const viewOffset = media['viewOffset']; + let userRating; + if ( media['userRating'] ) { + userRating = media['userRating'] + } else { + userRating = wtconfig.get('ET.NotAvail', 'N/A'); + } if ( this.genRep ){ - let watchTime = await time.convertMsToTime(viewOffset); - if ( watchTime === "00:00:00"){ - watchTime = ""; + let watchTime; + if (viewOffset) { + watchTime = await time.convertMsToTime(viewOffset); + if ( watchTime === "00:00:00"){ + watchTime = ""; + } + else { + watchTime = `"${watchTime}"` + } + } else { + watchTime = wtconfig.get('ET.NotAvail', 'N/A'); } - else { - watchTime = `"${watchTime}"` - } - const row = `"${this.currentLib}",${ratingKey},"${title}",${viewCount},${watchTime}\n`; + const row = `"${this.currentLib}",${ratingKey},"${title}",${viewCount},${watchTime},${userRating}\n`; this.csvStream.write( row ); } - log.info(`Bumbing viewcount to ${viewCount} for media ${ratingKey}`); + log.info(`Bumbing viewcount to ${viewCount} for media ${ratingKey} with a title of: "${title}"`); let url = `${store.getters.getSelectedServerAddress}/:/scrobble?identifier=com.plexapp.plugins.library&key=${ratingKey}`; // We need to bump viewcount for target user same amount as for SrcUsr let header = wtutils.PMSHeader; @@ -144,6 +155,28 @@ const viewstate = new class ViewState { } }); } + // Do we need to also set a user rating? + if ( userRating ) + { + if ( userRating != wtconfig.get('ET.NotAvail', 'N/A') ){ + url = `${store.getters.getSelectedServerAddress}/:/rate?identifier=com.plexapp.plugins.library&key=${ratingKey}&rating=${userRating}`; + await axios({ + method: 'put', + url: url, + headers: header + }) + .catch(function (error) { + if (error.response) { + log.error('[viewState.js] (bumpViewCount) viewOffset: ' + JSON.stringify(error.response.data)); + alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message); + } else if (error.request) { + log.error('[viewState.js] (bumpViewCount) viewOffset error: ' + error.request); + } else { + log.error('[viewState.js] (bumpViewCount) viewOffset last error: ' + error.message); + } + }); + } + } status.updateStatusMsg(status.RevMsgType.TimeElapsed, await time.getTimeElapsed()); } @@ -180,6 +213,7 @@ const viewstate = new class ViewState { listProcessDetails['viewCount'] = JSONPath({path: `$..viewCount`, json: medias[media]})[0]; listProcessDetails['duration'] = JSONPath({path: `$..duration`, json: medias[media]})[0]; listProcessDetails['ratingKey'] = JSONPath({path: `$..ratingKey`, json: medias[media]})[0]; + listProcessDetails['userRating'] = JSONPath({path: `$..userRating`, json: medias[media]})[0]; listProcess[JSONPath({path: `$..ratingKey`, json: medias[media]})[0]] = listProcessDetails; index += 1; this.bumpViewCount( listProcessDetails );