Skip to content

Conversation

dstapp
Copy link

@dstapp dstapp commented Feb 26, 2024

First off, thanks for this great project. This really helps me to get away from AirPlay :-)

There are a few things that I didn't get to work and seem to overlap with information provided in #2, namely:

  • Listing audiobooks sometimes does not work. It seems that if you have a big library in ABS (> 100 audiobooks), the Sonos app fails silently, since it does a paginated request with the assumption to get the correct amount of items (see https://docs.sonos.com/docs/getmetadata and https://docs.sonos.com/docs/add-pagination). Added pagination accordingly.
  • The same problem is also true for fetching metadata for a specific audiobook. If there are more than x files (> 200 in that case, at least according to my checks on a Era 100), listing works but playback fails. Therefore, I also added pagination there. That works, and you see Sonos requesting multiple pages if needed, however, still, audiobooks with more than 200 files, don't seem to play for me - maybe anyone has some insights here?
  • Progress conversion from what ABS provides to the relative per-file had a bug (see comment on line annotation below) that was fixed
  • Sonos also saves progress when you select a different song or something. However, when you just paused audiobook playback on Sonos and pick it up, say on your phone, when you later change the song in Sonos, it would report back it's previous playback state before switching the file to play. This is prevented by only listening to progress data with type "update" instead of "final".
  • Audiobook covers were taken from a property that provides the local file path instead of using the designated API endpoint (https://api.audiobookshelf.org/#get-a-library-item-39-s-cover)

For convenience, I also updated Node to 20 and added an overlay to start the container in dev mode, where it mounts all the source from local (so that you don't need to build) and starts the server with nodemon for auto-reloading.

Those changes provide fixes to an extend that I can play back Audiobooks and track progress in both directions.

Only problem remaining for me at the moment is the 200 file limit per audiobook. There's no mention in Sonos' dev docs, so maybe someone else can help here.

// -> if you are not in the first part, subtract the previous' parts total sums from currentTime to get the relative time
// in the current track
res.relativeTimeForPart =
durations[closestIndex] == 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

durations[closestIndex] can never be 0 unless the first file in your audiobook is 0ms long, so I hope my fix is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant