From ec4ab8762c6e6f4ee01e7b75e0debfa918214143 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 18 Mar 2024 19:03:13 +0800 Subject: [PATCH] add Bangumi --- package.json | 2 +- src/api/types.ts | 28 +++++++ src/components/cards/BangumiPersonCard.vue | 95 ++++++++++++++++++++++ src/components/cards/MediaCard.vue | 30 ++++--- src/pages/ranking.vue | 6 ++ src/pages/resource.vue | 2 +- src/views/discover/MediaCardSlideView.vue | 2 +- src/views/discover/MediaDetailView.vue | 81 +++++++++++++++--- src/views/discover/PersonCardSlideView.vue | 7 ++ 9 files changed, 224 insertions(+), 29 deletions(-) create mode 100644 src/components/cards/BangumiPersonCard.vue diff --git a/package.json b/package.json index b359f17e..f4b3961f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moviepilot", - "version": "1.7.3", + "version": "1.7.4", "private": true, "bin": "dist/service.js", "scripts": { diff --git a/src/api/types.ts b/src/api/types.ts index 55a84427..d3deeeb3 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -181,6 +181,9 @@ export interface MediaInfo { // 豆瓣ID douban_id?: string + // Bangumi ID + bangumi_id?: string + // 媒体原语种 original_language?: string @@ -282,6 +285,9 @@ export interface MediaInfo { // 下一集 next_episode_to_air?: object + + // 别名 + names?: string[] } // TMDB季信息 @@ -422,6 +428,28 @@ export interface DoubanPerson { } +// Bangumi人物信息 +export interface BangumiPerson { + // ID + id?: number + + // 名称 + name?: string + + // 类型 + type?: number + + // 角色 + career?: string[] + + // images large/normal + images?: { [key: string]: string } + + // 关系 + relation?: string + +} + // 站点 export interface Site { diff --git a/src/components/cards/BangumiPersonCard.vue b/src/components/cards/BangumiPersonCard.vue new file mode 100644 index 00000000..cfec21e2 --- /dev/null +++ b/src/components/cards/BangumiPersonCard.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/src/components/cards/MediaCard.vue b/src/components/cards/MediaCard.vue index aa1d6927..597ea37f 100644 --- a/src/components/cards/MediaCard.vue +++ b/src/components/cards/MediaCard.vue @@ -57,6 +57,15 @@ const seasonInfos = ref([]) // 选中的订阅季 const seasonsSelected = ref([]) +// 获得mediaid +function getMediaId() { + return props.media?.tmdb_id + ? `tmdb:${props.media?.tmdb_id}` + : props.media?.douban_id + ? `douban:${props.media?.douban_id}` + : `bangumi:${props.media?.bangumi_id}` +} + // 订阅弹窗选择的多季 function subscribeSeasons() { subscribeSeasonDialog.value = false @@ -131,6 +140,7 @@ async function addSubscribe(season = 0) { year: props.media?.year, tmdbid: props.media?.tmdb_id, doubanid: props.media?.douban_id, + bangumiid: props.media?.bangumi_id, season, best_version, }) @@ -186,9 +196,7 @@ async function removeSubscribe() { // 开始处理 startNProgress() try { - const mediaid = props.media?.tmdb_id - ? `tmdb:${props.media?.tmdb_id}` - : `douban:${props.media?.douban_id}` + const mediaid = getMediaId() const result: { [key: string]: any } = await api.delete( `subscribe/media/${mediaid}`, @@ -249,9 +257,7 @@ async function handleCheckExists() { // 调用API检查是否已订阅,电视剧需要指定季 async function checkSubscribe(season = 0) { try { - const mediaid = props.media?.tmdb_id - ? `tmdb:${props.media?.tmdb_id}` - : `douban:${props.media?.douban_id}` + const mediaid = getMediaId() const result: Subscribe = await api.get(`subscribe/media/${mediaid}`, { params: { @@ -362,11 +368,7 @@ function goMediaDetail() { router.push({ path: '/media', query: { - mediaid: `${ - props.media?.tmdb_id - ? `tmdb:${props.media?.tmdb_id}` - : `douban:${props.media?.douban_id}` - }`, + mediaid: getMediaId(), type: props.media?.type, }, }) @@ -377,11 +379,7 @@ function handleSearch() { router.push({ path: '/resource', query: { - keyword: `${ - props.media?.tmdb_id - ? `tmdb:${props.media?.tmdb_id}` - : `douban:${props.media?.douban_id}` - }`, + keyword: getMediaId(), type: props.media?.type, area: 'title', }, diff --git a/src/pages/ranking.vue b/src/pages/ranking.vue index b97538b9..01bea9c9 100644 --- a/src/pages/ranking.vue +++ b/src/pages/ranking.vue @@ -16,6 +16,12 @@ import MediaCardSlideView from '@/views/discover/MediaCardSlideView.vue' title="正在热映" /> + +