Skip to content

Commit

Permalink
Resolved a server crash when a playback session lacked associated med…
Browse files Browse the repository at this point in the history
…ia metadata.
  • Loading branch information
Vito0912 committed Dec 7, 2024
1 parent 3b4a5b8 commit 7486d63
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/utils/queries/userStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ module.exports = {
bookListeningMap[ls.displayTitle] += listeningSessionListeningTime
}

const authors = ls.mediaMetadata.authors || []
const authors = ls.mediaMetadata?.authors || []
authors.forEach((au) => {
if (!authorListeningMap[au.name]) authorListeningMap[au.name] = 0
authorListeningMap[au.name] += listeningSessionListeningTime
})

const narrators = ls.mediaMetadata.narrators || []
const narrators = ls.mediaMetadata?.narrators || []
narrators.forEach((narrator) => {
if (!narratorListeningMap[narrator]) narratorListeningMap[narrator] = 0
narratorListeningMap[narrator] += listeningSessionListeningTime
})

// Filter out bad genres like "audiobook" and "audio book"
const genres = (ls.mediaMetadata.genres || []).filter((g) => g && !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book'))
const genres = (ls.mediaMetadata?.genres || []).filter((g) => g && !g.toLowerCase().includes('audiobook') && !g.toLowerCase().includes('audio book'))
genres.forEach((genre) => {
if (!genreListeningMap[genre]) genreListeningMap[genre] = 0
genreListeningMap[genre] += listeningSessionListeningTime
Expand Down

0 comments on commit 7486d63

Please sign in to comment.