[PR #3690] [MERGED] Improved Metadata Handling and PlaybackSession Metadata Robustness #4055

Closed
opened 2026-04-25 00:18:08 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/3690
Author: @Vito0912
Created: 12/7/2024
Status: Merged
Merged: 4/19/2025
Merged by: @advplyr

Base: masterHead: feat/metadataForPlaybackSessions


📝 Commits (8)

  • 33e0987 Added mediaMetadata to playbackSessions
  • 8916754 added author for podcasts
  • 2fbb31e added null saftey and added displayTitle and displayAuthor
  • f9bbd71 added type to be saved. Should support podcasts
  • 121805b Merge branch 'master' into feat/metadataForPlaybackSessions
  • e6ab05e update so also populates data if mediaMetadata is not null
  • d7f0815 Merge branch 'master' into feat/metadataForPlaybackSessions
  • 2caa861 Update local session mediaMetadata with current item mediaMetadata for undefined values

📊 Changes

1 file changed (+19 additions, -0 deletions)

View changed files

📝 server/managers/PlaybackSessionManager.js (+19 -0)

📄 Description

Brief summary

This appends the server's existing mediaMetadata to the playbackSession if the client does not supply it.

Which issue is fixed?

This resolves server crashes caused by missing mediaMetadata (even though they are addressed separately) and corrects inaccurate stats when the client does not provide mediaMetadata. Additionally, it slightly reduces bandwidth usage during local session syncing.

In-depth Description

If mediaMetadata is absent in the payload sent by the client, the server will use the metadata it already has (libraryitem.media.metadata).
Only essential attributes are included in the playbackSession to avoid unnecessary data, such as descriptions, which are often lengthy and typically unneeded.
Additionally, displayTitle and displayAuthor will fall back to the corresponding mediaMetadata values when not provided, ensuring they are displayed even if the client does not sends them.

How have you tested this?

This has been tested with both my own client and the web client.


Copilot summary

This pull request includes changes to the PlaybackSessionManager class to ensure that client-provided metadata is preferred over library metadata when available. This change aims to make the system more robust and user-friendly by prioritizing user-specific information.

Improvements to metadata handling:

  • server/managers/PlaybackSessionManager.js: Added logic to prefer client-provided metadata (such as title, subtitle, narrators, authors, series, genres, and author) over library metadata if available. This ensures that important metadata is synchronized and displayed correctly.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/3690 **Author:** [@Vito0912](https://github.com/Vito0912) **Created:** 12/7/2024 **Status:** ✅ Merged **Merged:** 4/19/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `feat/metadataForPlaybackSessions` --- ### 📝 Commits (8) - [`33e0987`](https://github.com/advplyr/audiobookshelf/commit/33e0987d7325191b82bc99b51ef3426b5d300e80) Added mediaMetadata to playbackSessions - [`8916754`](https://github.com/advplyr/audiobookshelf/commit/89167543fa18e43eab06bf194bbc1996bb08b648) added author for podcasts - [`2fbb31e`](https://github.com/advplyr/audiobookshelf/commit/2fbb31e0ea84fabe0e08564141d427e3ab385cbf) added null saftey and added displayTitle and displayAuthor - [`f9bbd71`](https://github.com/advplyr/audiobookshelf/commit/f9bbd7117405e393c8bef56653cb279575896c32) added type to be saved. Should support podcasts - [`121805b`](https://github.com/advplyr/audiobookshelf/commit/121805ba390f139b0b787d220197cbad4505df0a) Merge branch 'master' into feat/metadataForPlaybackSessions - [`e6ab05e`](https://github.com/advplyr/audiobookshelf/commit/e6ab05e1772eef30c0be27d47d3c9d7a5cf43627) update so also populates data if mediaMetadata is not null - [`d7f0815`](https://github.com/advplyr/audiobookshelf/commit/d7f0815fb3ad8d2bcb4b7736e04a84b3ca706c1e) Merge branch 'master' into feat/metadataForPlaybackSessions - [`2caa861`](https://github.com/advplyr/audiobookshelf/commit/2caa861b8a56694f70ad26229d3e2d6899c7301d) Update local session mediaMetadata with current item mediaMetadata for undefined values ### 📊 Changes **1 file changed** (+19 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/managers/PlaybackSessionManager.js` (+19 -0) </details> ### 📄 Description <!-- For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details. If you do not follow this template, the PR may be closed without review. Please ensure all checks pass. If you are a new contributor, the workflows will need to be manually approved before they run. --> ## Brief summary This appends the server's existing `mediaMetadata` to the `playbackSession` if the client does not supply it. <!-- Please provide a brief summary of what your PR attempts to achieve. --> ## Which issue is fixed? This resolves server crashes caused by missing `mediaMetadata` (even though they are addressed separately) and corrects inaccurate stats when the client does not provide `mediaMetadata`. Additionally, it slightly reduces bandwidth usage during local session syncing. <!-- Which issue number does this PR fix? Ex: "Fixes #1234" --> ## In-depth Description If `mediaMetadata` is absent in the payload sent by the client, the server will use the metadata it already has (`libraryitem.media.metadata`). Only essential attributes are included in the `playbackSession` to avoid unnecessary data, such as descriptions, which are often lengthy and typically unneeded. Additionally, `displayTitle` and `displayAuthor` will fall back to the corresponding `mediaMetadata` values when not provided, ensuring they are displayed even if the client does not sends them. <!-- Describe your solution in more depth. How does it work? Why is this the best solution? Does it solve a problem that affects multiple users or is this an edge case for your setup? --> ## How have you tested this? <!-- Please describe in detail with reproducible steps how you tested your changes. --> This has been tested with both my own client and the web client. ---- ### Copilot summary This pull request includes changes to the `PlaybackSessionManager` class to ensure that client-provided metadata is preferred over library metadata when available. This change aims to make the system more robust and user-friendly by prioritizing user-specific information. ### Improvements to metadata handling: * [`server/managers/PlaybackSessionManager.js`](diffhunk://#diff-1c399b59a75a97b2f162fed8967242975e2f87b54d0730701e4b74bbf966dcdeR178-R189): Added logic to prefer client-provided metadata (such as title, subtitle, narrators, authors, series, genres, and author) over library metadata if available. This ensures that important metadata is synchronized and displayed correctly. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:18:08 +02:00
adam closed this issue 2026-04-25 00:18:08 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4055