Skip to content

Commit

Permalink
fix broken unused kick stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBrax committed Nov 7, 2023
1 parent 1109b7b commit 080407a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
8 changes: 6 additions & 2 deletions common/Api/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,12 @@ export interface ApiYouTubeChannel extends ApiBaseChannel {
chapter_data?: BaseVODChapterJSON;
}

export type ApiChannels = ApiTwitchChannel | ApiYouTubeChannel;
export type ApiVods = ApiTwitchVod | ApiYouTubeVod;
export interface ApiKickChannel extends ApiBaseChannel {
provider: "kick";
}

export type ApiChannels = ApiTwitchChannel | ApiYouTubeChannel | ApiKickChannel;
export type ApiVods = ApiTwitchVod | ApiYouTubeVod | ApiKickVod;

export type ApiSubscription = {
type: string;
Expand Down
12 changes: 11 additions & 1 deletion server/src/Controllers/Channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ export async function GetChannel(
return;
}

/*
if (isBaseChannel(channel)) {
res.api<ApiErrorResponse>(400, {
status: "ERROR",
message: "Channel is not supported",
});
return;
}
*/

res.api<ApiChannelResponse>(200, {
data: await channel.toAPI(),
data: (await channel.toAPI()) as any, // screw typescript
status: "OK",
});
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/Core/LiveStreamDVR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import fs from "node:fs";
import type { Server } from "node:http";
// import { version } from "node:os";
import type { BaseVODChapter } from "@/Core/Providers/Base/BaseVODChapter";
import type { KickChannel } from "@/Core/Providers/Kick/KickChannel";
import type { KickVOD } from "@/Core/Providers/Kick/KickVOD";
import { TwitchChannel } from "@/Core/Providers/Twitch/TwitchChannel";
import { TwitchGame } from "@/Core/Providers/Twitch/TwitchGame";
import type { TwitchVOD } from "@/Core/Providers/Twitch/TwitchVOD";
Expand Down Expand Up @@ -51,6 +49,8 @@ import { Helper } from "./Helper";
import { Job } from "./Job";
import { KeyValue } from "./KeyValue";
import { LOGLEVEL, log } from "./Log";
import { KickChannel } from "./Providers/Kick/KickChannel";
import { KickVOD } from "./Providers/Kick/KickVOD";
import { Scheduler } from "./Scheduler";
import { Webhook } from "./Webhook";

Expand Down
8 changes: 8 additions & 0 deletions server/src/Core/Providers/Kick/KickChannel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ApiKickChannel } from "@common/Api/Client";
import type { KickChannelConfig } from "@common/Config";
import type { Providers } from "@common/Defs";
import type {
Expand Down Expand Up @@ -315,4 +316,11 @@ export class KickChannel extends BaseChannel {

return channel;
}

public override async toAPI(): Promise<ApiKickChannel> {
return {
...(await super.toAPI()),
provider: "kick",
};
}
}
2 changes: 1 addition & 1 deletion server/src/Core/Providers/Twitch/TwitchChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class TwitchChannel extends BaseChannel {
);
}

public async toAPI(): Promise<ApiTwitchChannel> {
public override async toAPI(): Promise<ApiTwitchChannel> {
if (!this.internalId || !this.internalName || !this.displayName)
console.error(
chalk.red(
Expand Down
2 changes: 1 addition & 1 deletion server/src/Core/Providers/YouTube/YouTubeChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class YouTubeChannel extends BaseChannel {
return this.getVods().find((vod) => vod.is_capturing);
}

public async toAPI(): Promise<ApiYouTubeChannel> {
public override async toAPI(): Promise<ApiYouTubeChannel> {
const vods_list = await Promise.all(
this.getVods().map(async (vod) => await vod.toAPI())
);
Expand Down
10 changes: 10 additions & 0 deletions server/src/Helpers/Types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import type { BaseChannel } from "@/Core/Providers/Base/BaseChannel";
import { BaseVOD } from "@/Core/Providers/Base/BaseVOD";
import type { KickChannel } from "@/Core/Providers/Kick/KickChannel";
import type { TwitchChannel } from "@/Core/Providers/Twitch/TwitchChannel";
import type { TwitchVOD } from "@/Core/Providers/Twitch/TwitchVOD";
import type { TwitchVODChapter } from "@/Core/Providers/Twitch/TwitchVODChapter";
import type { YouTubeChannel } from "@/Core/Providers/YouTube/YouTubeChannel";
import type { YouTubeVOD } from "@/Core/Providers/YouTube/YouTubeVOD";

export function isBaseChannel(data: unknown): data is BaseChannel {
return (data as BaseChannel).config?.provider === undefined;
}

export function isBaseVOD(data: unknown): data is BaseVOD {
return (data as BaseVOD).provider === "base";
}

export function isTwitchChannel(data: unknown): data is TwitchChannel {
return (data as TwitchChannel).provider === "twitch";
}
Expand Down

0 comments on commit 080407a

Please sign in to comment.