chore: update Angular cache and TypeScript build info files
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Minimal Twitch provider handler
|
||||
*/
|
||||
const handler = {
|
||||
id: 'tw',
|
||||
label: 'Twitch',
|
||||
/**
|
||||
* @param {string} q
|
||||
* @param {{ limit: number, page?: number }} opts
|
||||
* @returns {Promise<Array<any>>}
|
||||
*/
|
||||
async search(q, opts) {
|
||||
const { limit = 10 } = opts;
|
||||
try {
|
||||
// Use Twitch Kraken API (older but public)
|
||||
const response = await fetch(
|
||||
`https://api.twitch.tv/kraken/search/streams?` +
|
||||
new URLSearchParams({
|
||||
query: q,
|
||||
limit: Math.min(limit, 25).toString()
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
'Accept': 'application/vnd.twitchtv.v5+json',
|
||||
'Client-ID': process.env.TWITCH_CLIENT_ID || ''
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Twitch API error: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return (data.streams || []).map(item => ({
|
||||
title: item.channel.status || item.channel.display_name,
|
||||
id: item.channel.name, // Channel name as ID
|
||||
url: `https://www.twitch.tv/${item.channel.name}`,
|
||||
thumbnail: item.preview?.medium || item.channel.logo,
|
||||
uploaderName: item.channel.display_name,
|
||||
type: 'stream',
|
||||
isLive: true
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('Twitch search error:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
export default handler;
|
||||
Reference in New Issue
Block a user