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

This commit is contained in:
advplyr 2022-04-25 19:03:26 -05:00
parent 4291769b93
commit d189ec74c9
2 changed files with 7 additions and 1 deletions

View File

@ -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 => {

View File

@ -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