[PR #5064] feat: Add total duration and total listened to series page #4410

Open
opened 2026-04-25 00:19:38 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/5064
Author: @Vb2341
Created: 2/16/2026
Status: 🔄 Open

Base: masterHead: feature/series-duration


📝 Commits (2)

  • 00f9940 feat: add total duration and progress to series
  • 1204936 Updated JSDoc comment for getSeriesForLibrary

📊 Changes

3 files changed (+49 additions, -2 deletions)

View changed files

📝 client/components/app/BookShelfToolbar.vue (+8 -0)
📝 server/controllers/LibraryController.js (+10 -2)
📝 server/models/Series.js (+31 -0)

📄 Description

Brief summary

This PR just adds the total listened duration and total duration of a series onto the series page in the web client (on the toolbar next to the number saying the number of books in the series). While the length of a series can be seen when sorting by series duration, this makes it convenient by showing it on the page (see pictures below).

Which issue is fixed?

This adds a little bit of the functionality requested in #711 (just the total duration of the series), and also adds the total amount already listened in that series.

In-depth Description

No new information is added to the database, but now the Series.js model file includes an extra function to compute the total duration of the series (getTotalDurationById). The database server does a SQL sum on each book's duration, where that book's series must match seriesID.

Then in LibraryController.js calls that function inside of getSeriesForLibrary() which corresponds to the api route /api/libraries/:id/series/:seriesId (which is the route used in the web client when the user clicks on a series). Additionally, an extra bit of logic is added to the seriesProgress object (which is only returned if include=progress is in the api call) to add the total listened duration. This loops over each book in the series, and adds the full duration if the book is finished, or MediaProgress.currentTime if not finished, so it accurately includes partially listened books.

Lastly, the vue file for BookShelfToolbar includes a small update to display these quantities if the user has a series page open.

If other apps (i.e. the android or ios apps) use the same api route when getting a series, then this data for the series should be available there too.

How have you tested this?

I built and ran the server and web client, and checked both the json returned by the request to /api/libraries/:id/series/:seriesId as well as the actual UI in the web client.

Screenshots

Before (no duration on toolbar)
image

If none of the books in the series have been started:
image

If some books are in progress and or finished (second book has 49 sec elapsed)
image

If no books are finished, but at least one in progress:
image


🔄 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/5064 **Author:** [@Vb2341](https://github.com/Vb2341) **Created:** 2/16/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feature/series-duration` --- ### 📝 Commits (2) - [`00f9940`](https://github.com/advplyr/audiobookshelf/commit/00f9940712911c926076f53e95fb967181d59593) feat: add total duration and progress to series - [`1204936`](https://github.com/advplyr/audiobookshelf/commit/1204936bf165ed7645393e707fcce39b5bff5077) Updated JSDoc comment for getSeriesForLibrary ### 📊 Changes **3 files changed** (+49 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `client/components/app/BookShelfToolbar.vue` (+8 -0) 📝 `server/controllers/LibraryController.js` (+10 -2) 📝 `server/models/Series.js` (+31 -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 <!-- Please provide a brief summary of what your PR attempts to achieve. --> This PR just adds the total listened duration and total duration of a series onto the series page in the web client (on the toolbar next to the number saying the number of books in the series). While the length of a series can be seen when sorting by series duration, this makes it convenient by showing it on the page (see pictures below). ## Which issue is fixed? <!-- Which issue number does this PR fix? Ex: "Fixes #1234" --> This adds a little bit of the functionality requested in #711 (just the total duration of the series), and also adds the total amount already listened in that series. ## In-depth Description <!-- 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? --> No new information is added to the database, but now the Series.js model file includes an extra function to compute the total duration of the series (getTotalDurationById). The database server does a SQL sum on each book's duration, where that book's series must match seriesID. Then in LibraryController.js calls that function inside of `getSeriesForLibrary()` which corresponds to the api route `/api/libraries/:id/series/:seriesId` (which is the route used in the web client when the user clicks on a series). Additionally, an extra bit of logic is added to the seriesProgress object (which is only returned if include=progress is in the api call) to add the total listened duration. This loops over each book in the series, and adds the full duration if the book is finished, or `MediaProgress.currentTime` if not finished, so it accurately includes partially listened books. Lastly, the vue file for BookShelfToolbar includes a small update to display these quantities if the user has a series page open. If other apps (i.e. the android or ios apps) use the same api route when getting a series, then this data for the series should be available there too. ## How have you tested this? I built and ran the server and web client, and checked both the json returned by the request to `/api/libraries/:id/series/:seriesId` as well as the actual UI in the web client. ## Screenshots <!-- If your PR includes any changes to the web client, please include screenshots or a short video from before and after your changes. --> Before (no duration on toolbar) <img width="1603" height="776" alt="image" src="https://github.com/user-attachments/assets/f8b0c606-cf48-4b32-8ed4-846469ac182b" /> If none of the books in the series have been started: <img width="1606" height="749" alt="image" src="https://github.com/user-attachments/assets/407f2efc-7fb0-41d8-83b2-64e93cdc457c" /> If some books are in progress and or finished (second book has 49 sec elapsed) <img width="1607" height="744" alt="image" src="https://github.com/user-attachments/assets/59575949-6d52-45a4-8c23-b776b4040870" /> If no books are finished, but at least one in progress: <img width="1608" height="733" alt="image" src="https://github.com/user-attachments/assets/e8c329c5-183c-4e3b-985d-9a90f9c954ee" /> --- <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:19:38 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4410