diff --git a/package.json b/package.json index faf6f46..8776f17 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "bulma-switch": "^2.0.4", "bulma-tooltip": "^3.0.2", "classnames": "^2.5.1", + "lodash.groupby": "^4.6.0", "query-string": "^9.1.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/packages/index/src/components/comment/index.tsx b/packages/index/src/components/comment/index.tsx index f087217..aec7d03 100644 --- a/packages/index/src/components/comment/index.tsx +++ b/packages/index/src/components/comment/index.tsx @@ -73,7 +73,7 @@ const Comment = ({ comments, onFocus, onBlur, postId, player, setMetaInfo }: Com {comments.map((item, i) => (
  • - +
    #{comments.length - i}

    {getTimeDistance(item.createdAt)}

    diff --git a/packages/index/src/enime.adp.ts b/packages/index/src/enime.adp.ts index 5b33104..3240c54 100644 --- a/packages/index/src/enime.adp.ts +++ b/packages/index/src/enime.adp.ts @@ -1,84 +1,4 @@ -export const enimeAdapter = (item: any) => { - if (!item.anime) item.anime = item - return { - ...item, - enime: true, - adp: true, - ID: item.anime?.slug, - Cover: item.anime?.coverImage || '', - Title: item.anime?.title.native || '', - Content: item.description || '', - Tags: '其他', - Type: 'video', - CreatedAt: item.createdAt, - UpdatedAt: item.updatedAt, - Meta: { - TitleJapanese: '', - TitleRomanji: '', - Genre: item.genre?.toString(), - Region: 'enime', - Episodes: 13, - IsEnd: 2, - PublishDate: '2015-01-01T08:00:00+08:00', - UpdatedDate: null - }, - Creator: { - ID: 1, - Name: 'enime.moe', - Nickname: 'enime', - Avatar: 'https://q1.qlogo.cn/g?b=qq&nk=7619376472&s=640', - Bio: '这个人很酷,什么都没有留下' - }, - episodes: item.anime?.episodes?.map((ep: any) => ({ - ID: ep.id, - Episode: ep.number, - Cover: ep.image, - Title: ep.title, - TitleJapanese: '', - TitleRomanji: '', - VideoUrl: '', - Synopsis: '', - Uid: 1, - Pid: item.anime?.slug, - CreatedAt: ep.airedAt || ep.createdAt, - UpdatedAt: ep.updatedAt - })) - } -} - -export const enimesAdapter = (data: any[] = []) => data.map(enimeAdapter) - -export const enimeSearchAdapter = (data: any[] = []) => { - return data.map((item) => ({ - ...item, - enime: true, - ID: item?.slug, - Cover: item?.coverImage || '', - Title: item?.title.native || '', - Content: item.description || '', - Tags: '其他', - Type: 'video', - CreatedAt: item.createdAt, - UpdatedAt: item.updatedAt, - Meta: { - TitleJapanese: '', - TitleRomanji: '', - Genre: item.genre?.toString(), - Region: 'enime', - Episodes: 13, - IsEnd: 2, - PublishDate: '2015-01-01T08:00:00+08:00', - UpdatedDate: null - }, - Creator: { - ID: 1, - Name: 'enime.moe', - Nickname: 'enime', - Avatar: 'https://q1.qlogo.cn/g?b=qq&nk=7619376472&s=640', - Bio: '这个人很酷,什么都没有留下' - } - })) -} +import groupBy from 'lodash.groupby' export function getSuo(content) { if (!content) return 'https://ae01.alicdn.com/kf/U6751d35799cc4d06965aa7b1879e0fc6i.jpg' @@ -86,7 +6,27 @@ export function getSuo(content) { return m ? m[1].slice(2) : 'https://cdn-us.imgs.moe/2023/02/27/63fcb180cbb30.jpg' } +const getVideos = (s: string) => { + return s + .split('\n') + .filter(Boolean) + .map((v, i) => { + const [chunkString, src] = v.split('$') + const [Episode, Title] = chunkString.split(' ') + return { + Episode: i, + Title: Title || Episode, + VideoUrl: src, + title: Title || Episode, + src, + poster: 'https://www.loliapi.com/acg/pc/' + } + }) +} + export const clicliAdapter = (item: any) => { + const Episodes = getVideos(item.videos) + return { ...item, adp: true, @@ -116,20 +56,8 @@ export const clicliAdapter = (item: any) => { Avatar: 'https://q1.qlogo.cn/g?b=qq&nk=7619376472&s=640', Bio: '这个人很酷,什么都没有留下' }, - Episodes: item.videos - .split('\n') - .filter(Boolean) - .map((v, i) => { - const [chunkString, src] = v.split('$') - const [Episode, Title] = chunkString.split(' ') - return { - Episode: Title ? Episode : i, - Title: Title || Episode, - VideoUrl: src, - title: Title || Episode, - src - } - }) + Episodes, + EpisodesGroup: groupBy(Episodes, (v) => v.Title) } } diff --git a/packages/index/src/pages/player/index.tsx b/packages/index/src/pages/player/index.tsx index 0ef249c..f6c9bcd 100644 --- a/packages/index/src/pages/player/index.tsx +++ b/packages/index/src/pages/player/index.tsx @@ -27,7 +27,7 @@ export default function PlayerPage({ id }: any) { const player = useRef(null) const [isAdp, setIsAdp] = useState(false) - const [source, _] = useState({ poster: 'https://api.imlazy.ink/img', title: 'LOADING ...' }) + const [source, _] = useState({ poster: 'https://www.loliapi.com/acg/pc/', title: 'LOADING ...' }) const [displayEpBar, setDisplayEpBar] = useState(false) const [metaInfo, setMetaInfo] = useState<{ like: number; comment?: any[] }>({ like: 0 }) @@ -106,6 +106,8 @@ export default function PlayerPage({ id }: any) { .then((it) => { setState(it) setVideo(it.Episodes) + // const groupIndex = localStorage.getItem('video_group') || 1 + player.current?.context.playlist.changeSourceList(it.Episodes) }) }, [isAdp]) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67e9643..9de09e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: classnames: specifier: ^2.5.1 version: 2.5.1 + lodash.groupby: + specifier: ^4.6.0 + version: 4.6.0 query-string: specifier: ^9.1.1 version: 9.1.1 @@ -2874,6 +2877,9 @@ packages: lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + lodash.groupby@4.6.0: + resolution: {integrity: sha512-5dcWxm23+VAoz+awKmBaiBvzox8+RqMgFhi7UvX9DHZr2HdxHXM/Wrf8cfKpsW37RNrvtPn6hSwNqurSILbmJw==} + lodash.memoize@4.1.2: resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} @@ -7230,6 +7236,8 @@ snapshots: lodash.debounce@4.0.8: {} + lodash.groupby@4.6.0: {} + lodash.memoize@4.1.2: {} lodash.uniq@4.5.0: {}