* feat: 添加 Iwara 排行功能,支持视频和图片的排序与筛选 * fix: 更新维护者信息 * feat: 使用 Puppeteer 优化 Iwara 排行数据获取 * fix: 修复链接生成逻辑以正确处理 slug * refactor: 提取公共常量和函数到 utils.ts 文件以简化代码结构 * fix: 修复 Iwara URL 以确保正确访问网站
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
export const rootUrl = 'https://www.iwara.tv';
|
|
export const apiRootUrl = 'https://api.iwara.tv';
|
|
export const apiqRootUrl = 'https://apiq.iwara.tv';
|
|
export const imageRootUrl = 'https://i.iwara.tv';
|
|
|
|
export const typeMap = {
|
|
video: 'Videos',
|
|
image: 'Images',
|
|
};
|
|
|
|
export const parseThumbnail = (type: 'video' | 'image', item: any) => {
|
|
if (type === 'image') {
|
|
const thumbnail = item.thumbnail || item.file;
|
|
return thumbnail ? `<img src="${imageRootUrl}/image/original/${thumbnail.id}/${thumbnail.name}">` : '';
|
|
}
|
|
|
|
if (item.embedUrl === null) {
|
|
return item.file ? `<img src="${imageRootUrl}/image/original/${item.file.id}/thumbnail-${String(item.thumbnail).padStart(2, '0')}.jpg">` : '';
|
|
}
|
|
|
|
// regex borrowed from https://stackoverflow.com/a/3726073
|
|
const match = /https?:\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w-]*)(&(amp;)?[\w=?]*)?/.exec(item.embedUrl);
|
|
if (match) {
|
|
return `<img src="${imageRootUrl}/image/embed/original/youtube/${match[1]}">`;
|
|
}
|
|
|
|
return '';
|
|
};
|