Spaces:
Running
Running
File size: 1,036 Bytes
761239a a3f1817 1185ec1 761239a a3f1817 761239a a3f1817 6967c22 761239a a3f1817 761239a a3f1817 6967c22 a3f1817 761239a a3f1817 761239a a3f1817 761239a a3f1817 761239a a3f1817 761239a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
"use server"
import { ChannelInfo } from "@/types/general"
import { getChannels } from "./getChannels"
export async function getChannel(options: {
channelId?: string | string[] | null
// apiKey?: string // deprecated, we only work on public content
// owner?: string // deprecated, we only work on public content
renewCache?: boolean
neverThrow?: boolean
} = {}): Promise<ChannelInfo | undefined> {
try {
const id = `${options?.channelId || ""}`
if (!id) {
throw new Error(`invalid channel id: "${id}"`)
}
const channels = await getChannels({
channelId: id,
// apiKey: options?.apiKey, // deprecated, we only work on public content
// owner: options?.owner, // deprecated, we only work on public content
renewCache: options.renewCache,
})
if (channels.length === 1) {
return channels[0]
}
throw new Error(`couldn't find channel ${options.channelId}`)
} catch (err) {
if (options.neverThrow) {
return undefined
}
throw err
}
}
|