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"
|
:title="topic.name"
|
||||||
class="topic"
|
class="topic"
|
||||||
target="_blank"
|
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" />
|
<VIcon icon="mdi-tag-outline" :size="14" />
|
||||||
<div class="topic-name">
|
<div class="topic-name">
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { getUID, pascalCase } from '@/core/utils'
|
import { getUID, pascalCase } from '@/core/utils'
|
||||||
import { getJsonWithCredentials } from '@/core/ajax'
|
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 { watchlaterList } from '@/components/video/watchlater'
|
||||||
import { getData, registerData } from '@/plugins/data'
|
import { getData, registerData } from '@/plugins/data'
|
||||||
import { descendingStringSort } from '@/core/utils/sort'
|
import { descendingStringSort } from '@/core/utils/sort'
|
||||||
@ -104,59 +104,68 @@ export const getVideoFeeds = withContentFilter(
|
|||||||
if (json.code !== 0) {
|
if (json.code !== 0) {
|
||||||
throw new Error(json.message)
|
throw new Error(json.message)
|
||||||
}
|
}
|
||||||
const dataCards = json.data.cards as any[]
|
const dataCards = json.data.items as any[]
|
||||||
const dataCardsWithoutPreOrder = dataCards.filter(it => !isPreOrderedVideo(JSON.parse(it.card)))
|
|
||||||
if (type === 'video') {
|
if (type === 'video') {
|
||||||
return groupVideoFeeds(
|
return groupVideoFeeds(
|
||||||
dataCards.map((c: any): VideoCard => {
|
dataCards.map((card: any): VideoCard => {
|
||||||
const card = JSON.parse(c.card)
|
const archive = lodash.get(card, 'modules.module_dynamic.major.archive')
|
||||||
const topics = lodash.get(c, 'display.topic_info.topic_details', []).map((it: any) => ({
|
const author = lodash.get(card, 'modules.module_author')
|
||||||
id: it.topic_id,
|
const dynamic = lodash.get(card, 'modules.module_dynamic.desc.text', '')
|
||||||
name: it.topic_name,
|
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 {
|
return {
|
||||||
id: c.desc.dynamic_id_str,
|
id: card.id_str,
|
||||||
aid: card.aid,
|
aid: archive.aid,
|
||||||
bvid: c.desc.bvid || card.bvid,
|
bvid: archive.bvid,
|
||||||
title: card.title,
|
title: archive.title,
|
||||||
upID: c.desc.user_profile.info.uid,
|
upFaceUrl: author.face,
|
||||||
upName: c.desc.user_profile.info.uname,
|
upName: author.name,
|
||||||
upFaceUrl: c.desc.user_profile.info.face,
|
upID: author.mid,
|
||||||
coverUrl: card.pic,
|
coverUrl: archive.cover,
|
||||||
description: card.desc,
|
description: archive.desc,
|
||||||
timestamp: c.timestamp,
|
timestamp: author.pub_ts * 1000,
|
||||||
time: new Date(c.timestamp * 1000),
|
time: new Date(author.pub_ts * 1000),
|
||||||
topics,
|
topics,
|
||||||
dynamic: card.dynamic,
|
dynamic,
|
||||||
like: formatCount(c.desc.like),
|
like: formatCount(stat.like.count),
|
||||||
duration: card.duration,
|
duration: parseDuration(archive.duration_text),
|
||||||
durationText: formatDuration(card.duration, 0),
|
durationText: formatDuration(parseDuration(archive.duration_text)),
|
||||||
playCount: formatCount(card.stat.view),
|
playCount: formatCount(archive.stat.play),
|
||||||
danmakuCount: formatCount(card.stat.danmaku),
|
danmakuCount: formatCount(archive.stat.danmaku),
|
||||||
watchlater: watchlaterList.includes(card.aid),
|
watchlater: watchlaterList.includes(archive.aid),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (type === 'bangumi') {
|
if (type === 'bangumi') {
|
||||||
return dataCardsWithoutPreOrder.map((c: any): VideoCard => {
|
return dataCards.map((card: any): VideoCard => {
|
||||||
const card = JSON.parse(c.card)
|
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 {
|
return {
|
||||||
id: c.desc.dynamic_id_str,
|
id: card.id_str,
|
||||||
aid: card.aid,
|
epID: pgc.epid,
|
||||||
bvid: c.desc.bvid || card.bvid,
|
title: pgc.title.replace(new RegExp(`^${author.name}:`), ''),
|
||||||
epID: card.episode_id,
|
upName: author.name,
|
||||||
title: card.new_desc,
|
upFaceUrl: author.face,
|
||||||
upName: card.apiSeasonInfo.title,
|
coverUrl: pgc.cover,
|
||||||
upFaceUrl: card.apiSeasonInfo.cover,
|
|
||||||
coverUrl: card.cover,
|
|
||||||
description: '',
|
description: '',
|
||||||
timestamp: c.timestamp,
|
timestamp: author.pub_ts * 1000,
|
||||||
time: new Date(c.timestamp * 1000),
|
time: new Date(author.pub_ts * 1000),
|
||||||
like: formatCount(c.desc.like),
|
like: formatCount(stat.like.count),
|
||||||
durationText: '',
|
durationText: '',
|
||||||
playCount: formatCount(card.play_count),
|
playCount: formatCount(pgc.stat.play),
|
||||||
danmakuCount: formatCount(card.bullet_count),
|
danmakuCount: formatCount(pgc.stat.danmaku),
|
||||||
watchlater: false,
|
watchlater: false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -23,6 +23,7 @@ export interface VideoCard {
|
|||||||
topics?: {
|
topics?: {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
url?: string
|
||||||
}[]
|
}[]
|
||||||
type?: string
|
type?: string
|
||||||
points?: number
|
points?: number
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user