feat: connect YMB APIs and add swipe video player
This commit is contained in:
1 parent
eb3eb8dfc6
commit
6ba0ce1179
19 files changed
+113
-11
No files matched your search
@@ -0,0 +1,14 @@
|
||||
// Author: fruit.com.cn
|
||||
const FALLBACK_IMAGE = '/assets/hero.jpg';
|
||||
const getText = (value, lang = 'id') => (typeof value === 'string' ? value : value?.[lang] || value?.en || value?.id || value?.zh || '');
|
||||
const getImage = (item) => item.coverUrl || item.cover || item.posterUrl || item.imageUrl || FALLBACK_IMAGE;
|
||||
|
||||
export function normalizeDrama(item, lang = 'id') {
|
||||
const id = String(item.id ?? item.dramaId ?? item.code ?? '');
|
||||
return { id, title: getText(item.locales || item.title, lang) || item.name || 'YMB Drama', channel: getText(item.channelLocales || item.channel, lang) || item.creatorName || 'YMB Originals', genre: getText(item.categoryLocales || item.genre, lang), image: getImage(item), duration: item.duration || '', views: item.views || item.viewCount || '', episodes: item.episodes || item.episodeList || [] };
|
||||
}
|
||||
|
||||
export function normalizePage(payload) {
|
||||
if (Array.isArray(payload)) return { total: payload.length, list: payload };
|
||||
return { total: payload?.total || 0, list: payload?.list || payload?.records || [] };
|
||||
}
|
||||
Reference in new issue
Block a user