mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Upgrade getVideoFeeds API (#4305)
This commit is contained in:
parent
a49bfa2c09
commit
61ab51687f
@ -38,7 +38,7 @@
|
||||
:title="topic.name"
|
||||
class="topic"
|
||||
target="_blank"
|
||||
:href="'https://t.bilibili.com/topic/name/' + topic.name + '/feed'"
|
||||
:href="topic.url || 'https://t.bilibili.com/topic/name/' + topic.name + '/feed'"
|
||||
>
|
||||
<VIcon icon="mdi-tag-outline" :size="14" />
|
||||
<div class="topic-name">
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { getUID, pascalCase } from '@/core/utils'
|
||||
import { getJsonWithCredentials } from '@/core/ajax'
|
||||
import { formatCount, formatDuration } from '@/core/utils/formatters'
|
||||
import { formatCount, formatDuration, parseDuration } from '@/core/utils/formatters'
|
||||
import { watchlaterList } from '@/components/video/watchlater'
|
||||
import { getData, registerData } from '@/plugins/data'
|
||||
import { descendingStringSort } from '@/core/utils/sort'
|
||||
@ -104,59 +104,68 @@ export const getVideoFeeds = withContentFilter(
|
||||
if (json.code !== 0) {
|
||||
throw new Error(json.message)
|
||||
}
|
||||
const dataCards = json.data.cards as any[]
|
||||
const dataCardsWithoutPreOrder = dataCards.filter(it => !isPreOrderedVideo(JSON.parse(it.card)))
|
||||
const dataCards = json.data.items as any[]
|
||||
if (type === 'video') {
|
||||
return groupVideoFeeds(
|
||||
dataCards.map((c: any): VideoCard => {
|
||||
const card = JSON.parse(c.card)
|
||||
const topics = lodash.get(c, 'display.topic_info.topic_details', []).map((it: any) => ({
|
||||
id: it.topic_id,
|
||||
name: it.topic_name,
|
||||
}))
|
||||
dataCards.map((card: any): VideoCard => {
|
||||
const archive = lodash.get(card, 'modules.module_dynamic.major.archive')
|
||||
const author = lodash.get(card, 'modules.module_author')
|
||||
const dynamic = lodash.get(card, 'modules.module_dynamic.desc.text', '')
|
||||
const stat = lodash.get(card, 'modules.module_stat')
|
||||
const topics = (
|
||||
lodash.get(card, 'modules.module_dynamic.desc.rich_text_nodes', []) as any[]
|
||||
)
|
||||
.filter(node => node.type === 'RICH_TEXT_NODE_TYPE_TOPIC')
|
||||
.map(node => {
|
||||
return {
|
||||
id: node.text,
|
||||
name: node.text,
|
||||
url: node.jump_url,
|
||||
}
|
||||
})
|
||||
return {
|
||||
id: c.desc.dynamic_id_str,
|
||||
aid: card.aid,
|
||||
bvid: c.desc.bvid || card.bvid,
|
||||
title: card.title,
|
||||
upID: c.desc.user_profile.info.uid,
|
||||
upName: c.desc.user_profile.info.uname,
|
||||
upFaceUrl: c.desc.user_profile.info.face,
|
||||
coverUrl: card.pic,
|
||||
description: card.desc,
|
||||
timestamp: c.timestamp,
|
||||
time: new Date(c.timestamp * 1000),
|
||||
id: card.id_str,
|
||||
aid: archive.aid,
|
||||
bvid: archive.bvid,
|
||||
title: archive.title,
|
||||
upFaceUrl: author.face,
|
||||
upName: author.name,
|
||||
upID: author.mid,
|
||||
coverUrl: archive.cover,
|
||||
description: archive.desc,
|
||||
timestamp: author.pub_ts * 1000,
|
||||
time: new Date(author.pub_ts * 1000),
|
||||
topics,
|
||||
dynamic: card.dynamic,
|
||||
like: formatCount(c.desc.like),
|
||||
duration: card.duration,
|
||||
durationText: formatDuration(card.duration, 0),
|
||||
playCount: formatCount(card.stat.view),
|
||||
danmakuCount: formatCount(card.stat.danmaku),
|
||||
watchlater: watchlaterList.includes(card.aid),
|
||||
dynamic,
|
||||
like: formatCount(stat.like.count),
|
||||
duration: parseDuration(archive.duration_text),
|
||||
durationText: formatDuration(parseDuration(archive.duration_text)),
|
||||
playCount: formatCount(archive.stat.play),
|
||||
danmakuCount: formatCount(archive.stat.danmaku),
|
||||
watchlater: watchlaterList.includes(archive.aid),
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
||||
if (type === 'bangumi') {
|
||||
return dataCardsWithoutPreOrder.map((c: any): VideoCard => {
|
||||
const card = JSON.parse(c.card)
|
||||
return dataCards.map((card: any): VideoCard => {
|
||||
const pgc = lodash.get(card, 'modules.module_dynamic.major.pgc')
|
||||
const author = lodash.get(card, 'modules.module_author')
|
||||
const stat = lodash.get(card, 'modules.module_stat')
|
||||
return {
|
||||
id: c.desc.dynamic_id_str,
|
||||
aid: card.aid,
|
||||
bvid: c.desc.bvid || card.bvid,
|
||||
epID: card.episode_id,
|
||||
title: card.new_desc,
|
||||
upName: card.apiSeasonInfo.title,
|
||||
upFaceUrl: card.apiSeasonInfo.cover,
|
||||
coverUrl: card.cover,
|
||||
id: card.id_str,
|
||||
epID: pgc.epid,
|
||||
title: pgc.title.replace(new RegExp(`^${author.name}:`), ''),
|
||||
upName: author.name,
|
||||
upFaceUrl: author.face,
|
||||
coverUrl: pgc.cover,
|
||||
description: '',
|
||||
timestamp: c.timestamp,
|
||||
time: new Date(c.timestamp * 1000),
|
||||
like: formatCount(c.desc.like),
|
||||
timestamp: author.pub_ts * 1000,
|
||||
time: new Date(author.pub_ts * 1000),
|
||||
like: formatCount(stat.like.count),
|
||||
durationText: '',
|
||||
playCount: formatCount(card.play_count),
|
||||
danmakuCount: formatCount(card.bullet_count),
|
||||
playCount: formatCount(pgc.stat.play),
|
||||
danmakuCount: formatCount(pgc.stat.danmaku),
|
||||
watchlater: false,
|
||||
}
|
||||
})
|
||||
|
||||
@ -23,6 +23,7 @@ export interface VideoCard {
|
||||
topics?: {
|
||||
id: number
|
||||
name: string
|
||||
url?: string
|
||||
}[]
|
||||
type?: string
|
||||
points?: number
|
||||
|
||||
Loading…
Reference in New Issue
Block a user