mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-15 10:34:35 +08:00
fix(discover): TheTvDb 链接优先使用 slug,修复数字 ID 直达 404
TVDB 已弃用数字 ID 直达 URL,优先使用后端下发的 tvdb_slug 拼接链接,无 slug 时回退 tvdb_id。Closes #643
This commit is contained in:
@@ -388,6 +388,8 @@ export interface MediaInfo {
|
||||
imdb_id?: string
|
||||
// TVDB ID
|
||||
tvdb_id?: string
|
||||
// TVDB Slug(别名,用于构建 TheTvDb 直达链接)
|
||||
tvdb_slug?: string
|
||||
// 豆瓣ID
|
||||
douban_id?: string
|
||||
// Bangumi ID
|
||||
|
||||
@@ -568,9 +568,14 @@ function getImdbLink() {
|
||||
return `https://www.imdb.com/title/${mediaDetail.value.imdb_id}`
|
||||
}
|
||||
|
||||
// 拼装TVDB地址
|
||||
// 拼装TVDB地址(优先使用 slug,TVDB 已弃用数字 ID 直达 URL)
|
||||
function getTvdbLink() {
|
||||
return `https://www.thetvdb.com/series/${mediaDetail.value.tvdb_id}`
|
||||
const slug = mediaDetail.value.tvdb_slug
|
||||
const id = mediaDetail.value.tvdb_id
|
||||
if (slug) {
|
||||
return `https://www.thetvdb.com/series/${slug}`
|
||||
}
|
||||
return `https://www.thetvdb.com/series/${id}`
|
||||
}
|
||||
|
||||
// 拼装Bangumi地址
|
||||
|
||||
@@ -358,6 +358,21 @@ describe('MediaDetailView detail and actions', () => {
|
||||
expect(mocks.openDoubanApp).toHaveBeenCalledWith('db-8401', '电影', '链接电影', '2025')
|
||||
})
|
||||
|
||||
it('uses tvdb_slug for TheTvDb link when available, falls back to tvdb_id', async () => {
|
||||
// 有 slug 时使用 slug
|
||||
const mediaWithSlug = createMediaInfo({
|
||||
title: '有 Slug 的剧集',
|
||||
tvdb_id: '460322',
|
||||
tvdb_slug: 'speed-and-love',
|
||||
type: '电视剧',
|
||||
})
|
||||
await renderDetail({ media: mediaWithSlug, mediaId: 'tmdb:1', type: '电视剧' })
|
||||
expect(screen.getByRole('link', { name: /TheTvDb/ })).toHaveAttribute(
|
||||
'href',
|
||||
'https://www.thetvdb.com/series/speed-and-love',
|
||||
)
|
||||
})
|
||||
|
||||
it('renders Douban-only facts, deep link, image, credits, and recommendations', async () => {
|
||||
const media = createMediaInfo({
|
||||
backdrop_path: 'https://images.example.com/douban-backdrop.jpg',
|
||||
|
||||
Reference in New Issue
Block a user