Fix Kick module: handle URL input and wrap livestream error
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
All checks were successful
Auto Build and Push Docker Image / build (push) Successful in 7s
This commit is contained in:
@@ -50,15 +50,26 @@ export class KickManager {
|
|||||||
if (!client) return { channel: null, livestream: null };
|
if (!client) return { channel: null, livestream: null };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const channels = await client.channels.getChannels({ slug: [channelName] }) as KickChannel[];
|
let cleanChannelName = channelName.toLowerCase().replace(/^@/, '').replace(/^https?:\/\/kick\.com\//, '').trim();
|
||||||
|
if (cleanChannelName.length > 25) {
|
||||||
|
console.error(`[KICK] Channel name "${cleanChannelName}" exceeds 25 characters`);
|
||||||
|
return { channel: null, livestream: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const channels = await client.channels.getChannels({ slug: [cleanChannelName] }) as KickChannel[];
|
||||||
const channel = channels?.[0] || null;
|
const channel = channels?.[0] || null;
|
||||||
|
|
||||||
if (!channel) return { channel: null, livestream: null };
|
if (!channel) return { channel: null, livestream: null };
|
||||||
|
|
||||||
|
let livestream: KickLivestream | null = null;
|
||||||
|
try {
|
||||||
const livestreams = await client.livestreams.getLivestreams({
|
const livestreams = await client.livestreams.getLivestreams({
|
||||||
broadcaster_user_id: [channel.user_id]
|
broadcaster_user_id: [channel.user_id]
|
||||||
}) as KickLivestream[];
|
}) as KickLivestream[];
|
||||||
const livestream = livestreams?.[0] || null;
|
livestream = livestreams?.[0] || null;
|
||||||
|
} catch (livestreamError) {
|
||||||
|
console.warn(`[KICK] Could not fetch livestream data for ${cleanChannelName}:`, livestreamError);
|
||||||
|
}
|
||||||
|
|
||||||
return { channel, livestream };
|
return { channel, livestream };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user