Skip to content

Commit

Permalink
fix vod splitting function
Browse files Browse the repository at this point in the history
related to #472
  • Loading branch information
MrBrax committed Nov 6, 2023
1 parent 9cfbfdd commit 57aafe6
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 41 deletions.
2 changes: 1 addition & 1 deletion client-vue/src/components/vod/ExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const { t } = useI18n();
const exportVodSettings = ref<ExporterOptions>({
// exporter: "file",
title_template: "[{login}] {title} ({date})",
title_template: "[{internalName}] {title} ({date})",
directory: "",
host: "",
username: "",
Expand Down
10 changes: 9 additions & 1 deletion common/Replacements.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface VodBasenameTemplate extends Record<string, string> {
login: string;
// login: string;
internalName: string;
displayName: string;
date: string;
Expand All @@ -17,6 +17,14 @@ export interface VodBasenameTemplate extends Record<string, string> {
absolute_episode: string;
title: string;
game_name: string;
game_id: string;
}

export interface VodBasenameWithChapterTemplate extends VodBasenameTemplate {
chapter_number: string;
chapter_title: string;
chapter_game_name: string;
chapter_game_id: string;
}

export interface ExporterFilenameTemplate extends Record<string, string> {
Expand Down
15 changes: 13 additions & 2 deletions common/ReplacementsConsts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ClipBasenameTemplate, ExporterFilenameTemplate, TemplateField, VodBasenameTemplate } from "./Replacements";
import type { ClipBasenameTemplate, ExporterFilenameTemplate, TemplateField, VodBasenameTemplate, VodBasenameWithChapterTemplate } from "./Replacements";

export const VodBasenameFields: Record<keyof VodBasenameTemplate, TemplateField> = {
login: { display: "MooseStreamer", deprecated: true },
// login: { display: "MooseStreamer", deprecated: true },
internalName: { display: "moosestreamer" },
displayName: { display: "MooseStreamer", },
date: { display: "2022-12-31T12_05_04Z" },
Expand All @@ -15,11 +15,22 @@ export const VodBasenameFields: Record<keyof VodBasenameTemplate, TemplateField>
id: { display: "123456789" },
season: { display: "202212" },
absolute_season: { display: "5" },
absolute_episode: { display: "3" },
episode: { display: "3" },
title: { display: "Moose crosses river HOT NEW CONTENT COME LOOK" },
game_name: { display: "Moose Simulator 2022" },
game_id: { display: "123456789" },
};

export const VodBasenameChapterFields: Record<keyof VodBasenameWithChapterTemplate, TemplateField> = {
...VodBasenameFields, // extends VodBasenameTemplate
chapter_number: { display: "1" },
chapter_title: { display: "Moose crosses river" },
chapter_game_name: { display: "Moose Simulator 2022" },
chapter_game_id: { display: "123456789" },
};


export const ClipBasenameFields: Record<keyof ClipBasenameTemplate, TemplateField> = {
id: { display: "MinimalMooseOtterCatcher1234" },
quality: { display: "720p" },
Expand Down
27 changes: 24 additions & 3 deletions common/ServerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { SettingField } from "./Config";
import {
ClipBasenameFields,
ExporterFilenameFields,
VodBasenameChapterFields,
VodBasenameFields,
} from "./ReplacementsConsts";
import { YouTubeCategories } from "./YouTube";
Expand Down Expand Up @@ -667,7 +668,7 @@ export const settingsFields: Record<
group: "Video",
text: "Vod filename",
type: "template",
default: "{login}_{date}_{id}",
default: "{internalName}_{date}_{id}",
help: "Vod filename.",
replacements: VodBasenameFields,
context: "{template}.json, {template}.mp4",
Expand All @@ -677,10 +678,30 @@ export const settingsFields: Record<
group: "Video",
text: "Vod folder name",
type: "template",
default: "{login}_{date}_{id}",
default: "{internalName}_{date}_{id}",
help: "Vod folder filename.",
replacements: VodBasenameFields,
context: "/vods/{login}/{template}/",
context: "/vods/{internalName}/{template}/",
},

"template.vodsplit.folder": {
group: "Video",
text: "Vodsplit folder name",
type: "template",
default: "{internalName}_{date}_{id}",
help: "Vodsplit folder filename. If same as Vod folder name, it will be placed in the same folder.",
replacements: VodBasenameChapterFields,
context: "/vods/{internalName}/{template}/",
},

"template.vodsplit.filename": {
group: "Video",
text: "Vodsplit filename",
type: "template",
default: "{internalName}_{date}_{id}-{chapter_number}._{chapter_title}_({game_name})",
help: "Vodsplit filename.",
replacements: VodBasenameChapterFields,
context: "{template}.mp4",
},

min_chapter_duration: {
Expand Down
1 change: 1 addition & 0 deletions server/src/Controllers/Vod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ export async function RenameVod(
: "",
title: vod.stream_title || "",
game_name: vod.game_name || "",
game_id: vod.game_id || "",
};

const basename = sanitize(
Expand Down
14 changes: 14 additions & 0 deletions server/src/Core/Providers/Base/BaseAutomator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class BaseAutomator {
: "",
title: this.getTitle(),
game_name: this.getGameName(),
game_id: this.getGameID(),
};

return sanitize(
Expand Down Expand Up @@ -175,6 +176,7 @@ export class BaseAutomator {
: "",
title: this.getTitle(),
game_name: this.getGameName(),
game_id: this.getGameID(),
};

return sanitize(
Expand Down Expand Up @@ -244,6 +246,18 @@ export class BaseAutomator {
return "";
}

public getGameID(): string {
if (KeyValue.getInstance().has(`${this.getLogin()}.chapterdata`)) {
const data = KeyValue.getInstance().getObject<TwitchVODChapterJSON>(
`${this.getLogin()}.chapterdata`
);
if (data && data.game_id) {
return data.game_id || "";
}
}
return "";
}

public streamURL(): string {
// return `twitch.tv/${this.broadcaster_user_login}`;
if (!this.channel) {
Expand Down
4 changes: 4 additions & 0 deletions server/src/Core/Providers/Base/BaseVOD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,10 @@ export class BaseVOD {
return ""; // base vod does not have game_name
}

public get game_id(): string {
return ""; // base vod does not have game_id
}

public calculateBookmarks(): boolean {
if (!this.bookmarks || this.bookmarks.length == 0) return false;
if (!this.started_at) return false;
Expand Down
Loading

0 comments on commit 57aafe6

Please sign in to comment.