Skip to content

Commit

Permalink
chapter title config for videos
Browse files Browse the repository at this point in the history
related to #474
  • Loading branch information
MrBrax committed Nov 8, 2023
1 parent 7a2466a commit 95b7a8b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 11 additions & 0 deletions common/ServerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,17 @@ export const settingsFields: Record<string, SettingField> = {
type: "boolean",
default: true,
},
"video.chapters.title": {
group: "Video",
text: "Video chapters title",
type: "object",
default: "title_and_game",
choices: {
title_and_game: "Title and game",
title: "Title",
game: "Game",
},
},
create_kodi_nfo: {
group: "Video",
text: "Create kodi nfo",
Expand Down
18 changes: 15 additions & 3 deletions server/src/Core/Providers/Base/BaseVOD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,14 +1200,26 @@ export class BaseVOD {

if (this.started_at) meta.setDate(this.started_at);

const titleConfig = Config.getInstance().cfg("video.chapters.title");

this.chapters.forEach((chapter) => {
const offset = chapter.offset || 0;
const duration = chapter.duration || 0;
const start = Math.floor(offset * 1000);
const end = Math.floor((offset + duration) * 1000);
const title = isTwitchVODChapter(chapter)
? `${chapter.title} (${chapter.game_name})`
: chapter.title;
// const title = isTwitchVODChapter(chapter)
// ? `${chapter.title} (${chapter.game_name})`
// : chapter.title;
let title = chapter.title;
if (
titleConfig == "title_and_game" &&
isTwitchVODChapter(chapter)
) {
title = `${chapter.title} (${chapter.game_name})`;
} else if (titleConfig == "game" && isTwitchVODChapter(chapter)) {
title = `${chapter.game_name ?? chapter.title}`;
}

try {
meta.addChapter(start, end, title, "1/1000", [
isTwitchVODChapter(chapter)
Expand Down

0 comments on commit 95b7a8b

Please sign in to comment.