mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 03:26:37 +08:00
24 lines
698 B
TypeScript
24 lines
698 B
TypeScript
import type { Library, Media } from '../types'
|
|
import { artworkScore, groupSeries, type SeriesCard } from '../utils/groupSeries'
|
|
|
|
export type LibraryPreview = {
|
|
library: Library
|
|
items: Media[]
|
|
total: number
|
|
cards: SeriesCard[]
|
|
}
|
|
|
|
export function isSeriesLibraryType(type?: string) {
|
|
return type === 'tv' || type === 'anime' || type === 'variety'
|
|
}
|
|
|
|
export function latestLibraryCards(items: Media[]): SeriesCard[] {
|
|
return groupSeries(items)
|
|
.sort((a, b) => mediaTime(b.rep) - mediaTime(a.rep) || artworkScore(b.rep) - artworkScore(a.rep))
|
|
.slice(0, 10)
|
|
}
|
|
|
|
export function mediaTime(media: Media): number {
|
|
return Date.parse(media.updated_at || media.created_at || '') || 0
|
|
}
|