45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
/**
|
|
* Minimal Odysee provider handler
|
|
*/
|
|
const handler = {
|
|
id: 'od',
|
|
label: 'Odysee',
|
|
/**
|
|
* @param {string} q
|
|
* @param {{ limit: number, page?: number }} opts
|
|
* @returns {Promise<Array<any>>}
|
|
*/
|
|
async search(q, opts) {
|
|
const { limit = 10 } = opts;
|
|
try {
|
|
const response = await fetch(
|
|
`https://lighthouse.odysee.tv/content/search?` +
|
|
new URLSearchParams({
|
|
query: q,
|
|
size: Math.min(limit, 50).toString(),
|
|
page: '1'
|
|
})
|
|
);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Odysee API error: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
return (data || []).map(item => ({
|
|
title: item.title,
|
|
id: item.claimId,
|
|
url: `https://odysee.com/${item.canonical_url}`,
|
|
thumbnail: item.thumbnail_url,
|
|
uploaderName: item.channel_name || item.publisher_name,
|
|
type: 'video'
|
|
}));
|
|
} catch (error) {
|
|
console.error('Odysee search error:', error);
|
|
return [];
|
|
}
|
|
}
|
|
};
|
|
export default handler;
|