From d189ec74c9d10e856969f7eec36887799bd0f182 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 25 Apr 2022 19:03:26 -0500 Subject: [PATCH] Update item api endpoint to include user media progress with item if using query string include=progress and optionally episode=episodeid - for mobile app downloads --- server/controllers/LibraryItemController.js | 6 ++++++ server/objects/user/MediaProgress.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/controllers/LibraryItemController.js b/server/controllers/LibraryItemController.js index 56f1cb67..b494c754 100644 --- a/server/controllers/LibraryItemController.js +++ b/server/controllers/LibraryItemController.js @@ -11,6 +11,12 @@ class LibraryItemController { if (req.query.expanded == 1) { var item = req.libraryItem.toJSONExpanded() + // Include users media progress + if (includeEntities.includes('progress')) { + var episodeId = req.query.episode || null + item.userMediaProgress = req.user.getMediaProgress(item.id, episodeId) + } + if (item.mediaType == 'book') { if (includeEntities.includes('authors')) { item.media.metadata.authors = item.media.metadata.authors.map(au => { diff --git a/server/objects/user/MediaProgress.js b/server/objects/user/MediaProgress.js index 572743bc..9cb266a2 100644 --- a/server/objects/user/MediaProgress.js +++ b/server/objects/user/MediaProgress.js @@ -2,7 +2,7 @@ const Logger = require('../../Logger') class MediaProgress { constructor(progress) { - this.id = null // Same as library item id + this.id = null this.libraryItemId = null this.episodeId = null // For podcasts