Skip to content

Commit

Permalink
Fix PMS >=1.40.0 chapter parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
danrahn committed Jan 19, 2024
1 parent 19f6673 commit e0f8fae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Server/PlexQueryManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,14 @@ INNER JOIN metadata_items b ON media_items.metadata_item_id=b.id`;

let chapterEnd = extraData.indexOf('&', chapterStart);
if (chapterEnd === -1) {
chapterEnd = extraData.length;
// With PMS >=1.40, the url-encoded chapter data is its own element in a JSON string,
// so adjust the cutoff accordingly.
// TODO: Use ExtraData.isLegacy, and parse the JSON directly if we're not legacy.
if (extraData[extraData.length - 1] === '}') {
chapterEnd = extraData.length - 2;
} else {
chapterEnd = extraData.length;
}
}

/** @type {{ Chapters : { Chapter : { name : string, start : number, end : number }[] }}} */
Expand Down

0 comments on commit e0f8fae

Please sign in to comment.