Jump to content

How Emby Determines the Next Chapter ID in Audiobooks


Recommended Posts

Posted

I don't understand how Emby finds the id of the next chapter for audiobooks. I inspected the web app and observed this request.

Here is the process and the requests that were sent:

I start the first chapter of an audiobook. After 10 seconds, the progress is reported:

Header: Sessions/Playing/Progress?
Payload: ItemId: "57632"

Then I press the next chapter button:

Header: Sessions/Playing/Stopped?
Payload: ItemId: "57632"

Header: Users/{UserId}/Items/Resume?
Payload: MediaTypes: Audio
Response: "Items": [{ItemId: "57632"}]

Header: /Audio/57538/universal?UserId={UserId}

The next chapter starts.

I don't understand how Emby gets the next ID (57538).

Posted

Hi, it is that /Resume api that provides the next one. Another way would be to get the entire list from the album and then find the next one in the list.

What exactly is your question?

Posted

My question is how the server knows which audio file to play after I click on the Next Chapter button when the current chapter is only halfway through.

So I'm listening to Chapter 1 and I'm halfway through, then I press the Next Chapter button.

This ends the first chapter and makes a /Resume request. But since the first chapter is not yet finished, the /Resume request returns the ID of the first chapter, as you can continue listening to it. However, the file of the 2nd chapter is loaded via Audio/{FileId}/universal.

As can be seen in the flow of my first post. My question is how do I get this ID of the next chapter?

My goal is to write a widget for Android that allows me to listen to my audiobooks and always have them on the home screen.

 

I just found /AudioBooks/NextUp?AlbumId=64090 in the Inspector and I think I can use it to implement the logic for the next chapter. Am I correct that there is no documentation for this?

Now the question is how can I find the ID of the previous chapters?

How do I get the list of all chapters of an album? Via /emby/Items?Albums=64090 I only get one entry and it doesn't contain a list of chapters.

 

Thank you very much for your help and especially for Emby in general, this has become an essential part of my daily life ❤️ 

Posted

They are essentially sorted by track numbers. Not much more to it than that.

Quote

However, the file of the 2nd chapter is loaded via Audio/{FileId}/universal.

This isn't really true. If you use the ID of the first chapter, the universal endpoint will send back the first chapter. It will not decide on it's own to send back a different one.

Quote

I just found /AudioBooks/NextUp?AlbumId=64090 in the Inspector and I think I can use it to implement the logic for the next chapter. Am I correct that there is no documentation for this?

Now the question is how can I find the ID of the previous chapters?

Right unfortunately there is not as much as it should be. Things tend to move quickly based on what Emby apps need, and then the api plays catchup after that.

Posted
Quote

This isn't really true. If you use the ID of the first chapter, the universal endpoint will send back the first chapter. It will not decide on it's own to send back a different one.

I never said that the endpoint sent back a different file than I expected. 

1. Request

Header: Sessions/Playing/Stopped?

Payload: ItemId: "57632"

2. Request

Header: Users/{UserId}/Items/Resume?

Payload: MediaTypes: Audio

Response: "Items": [{ItemId: "57632"}]

3. Request

Header: /Audio/57538/universal?UserId={UserId}

 

Here again are the 3 requests that are sent when I click on the button for the next chapter in the browser. It's just these three requests in that order.

As you can see, the /Resume request returns the id from the 1st chapter, but to load the file the id from the 2nd chapter is used.

My question is where does this ID of the 2nd chapter come from? The two requests before loading the 2nd chapter do not contain any information about the ID of the 2nd chapter. I hope you now understand what I mean.

Can you tell me which API endpoint I have to use to get a list of all chapters of an album via the AlbumId

Posted

When it starts playing it gets all items from the audiobook in order, so this way it already knows which one will be next.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...