Files
RSSHub/lib/routes/javtrailers/utils.ts
T
DIYgod cf4e772de8 refactor: replace art template with jsx (#20777)
* refactor: replace art template with jsx

* fix: tsx files

* fix: renderToString import

* fix: hono html raw import

* feat: remove art
2025-12-29 12:27:32 +08:00

44 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
import { renderDescription } from './templates/description';
import type { Video } from './types';
export const baseUrl = 'https://javtrailers.com';
export const headers = {
Authorization: 'AELAbPQCh_fifd93wMvf_kxMD_fqkUAVf@BVgb2!md@TNW8bUEopFExyGCoKRcZX',
};
export const hdGallery = (gallery) =>
gallery.map((item) => {
if (item.startsWith('https://pics.dmm.co.jp/')) {
return item.replace(/-(\d+)\.jpg$/, 'jp-$1.jpg');
} else if (item.startsWith('https://image.mgstage.com/')) {
return item.replace(/cap_t1_/, 'cap_e_');
}
return item;
});
export const parseList = (videos) =>
videos.map((item) => ({
title: `${item.dvdId} ${item.title}`,
link: `${baseUrl}/video/${item.contentId}`,
pubDate: parseDate(item.releaseDate),
contentId: item.contentId,
}));
export const getItem = async (item) => {
const response = await ofetch(`${baseUrl}/api/video/${item.contentId}`, {
headers,
});
const videoInfo: Video = response.video;
videoInfo.gallery = hdGallery(videoInfo.gallery);
item.description = renderDescription(videoInfo);
item.author = videoInfo.casts.map((cast) => `${cast.name} ${cast.jpName}`).join(', ');
item.category = videoInfo.categories.map((category) => `${category.name}/${category.jpName}/${category.zhName}`);
return item;
};