fix subscribe season

This commit is contained in:
jxxghp
2023-07-04 19:24:19 +08:00
parent 43f2f57633
commit fd1b774b94
3 changed files with 104 additions and 49 deletions
+69 -43
View File
@@ -123,54 +123,80 @@ export interface MediaInfo {
} }
// TMDB季信息
export interface TmdbSeason {
air_date?: string
episode_count?: number
name?: string
overview?: string
poster_path?: string
season_number?: number
vote_average?: number
}
// TMDB集信息
export interface TmdbEpisodes {
air_date?: string
episode_number?: number
name?: string
overview?: string
runtime?: number
season_number?: number
still_path?: string
vote_average?: number
crew: Object[]
guest_stars: Object[]
}
// 站点 // 站点
export interface Site { export interface Site {
// ID // ID
id: number id: number
// 站点名称 // 站点名称
name: string name: string
// 站点主域名Key // 站点主域名Key
domain: string domain: string
// 站点地址 // 站点地址
url: string url: string
// 站点优先级 // 站点优先级
pri?:number pri?: number
// RSS地址 // RSS地址
rss?: string rss?: string
// Cookie // Cookie
cookie?: string cookie?: string
// User-Agent // User-Agent
ua?: string ua?: string
// 是否使用代理 // 是否使用代理
proxy?:number proxy?: number
// 过滤规则 // 过滤规则
filter?: string filter?: string
// 是否演染 // 是否演染
render?:number render?: number
// 备注 // 备注
note?: string note?: string
// 流控单位周期 // 流控单位周期
limit_interval?:number limit_interval?: number
// 流控次数 // 流控次数
limit_count?:number limit_count?: number
// 流控间隔 // 流控间隔
limit_seconds?:number limit_seconds?: number
// 是否启用 // 是否启用
is_active: boolean is_active: boolean
} }
// 正在下载 // 正在下载
export interface DownloadingInfo { export interface DownloadingInfo {
hash?: string hash?: string
title?: string title?: string
name?: string name?: string
year?: string year?: string
season_episode?: string season_episode?: string
size?: number size?: number
progress?: number progress?: number
state?: string state?: string
dlspeed?: string dlspeed?: string
upspeed?: string upspeed?: string
media: {[key: string]: any} media: { [key: string]: any }
} }
+35 -5
View File
@@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import api from "@/api"; import api from "@/api";
import { doneNProgress, startNProgress } from "@/api/nprogress"; import { doneNProgress, startNProgress } from "@/api/nprogress";
import { MediaInfo, Subscribe } from "@/api/types"; import { MediaInfo, Subscribe, TmdbSeason } from "@/api/types";
import { useToast } from "vue-toast-notification"; import { useToast } from "vue-toast-notification";
// 输入参数 // 输入参数
@@ -31,8 +31,28 @@ const getChipColor = (type: string) => {
} }
}; };
// 添加订阅 const handleAddSubscribe = async () => {
const addSubscribe = async () => { // 检查是否多季
let season = props.media?.season;
if (!season && props.media?.tmdb_id && props.media?.type == "电视剧") {
// TMDB且是电视剧
let seasons = await getMediaSeasons();
if (!seasons) {
$toast.error(`${props.media?.title} 查询剧集信息失败!`);
return;
}
// 添加最新季
// TODO 弹出季选择列表,支持多选
addSubscribe(seasons[seasons.length - 1].season_number);
} else {
// 电影或者只有1季的电视剧直接添加
addSubscribe(season);
}
};
// 添加订阅,电视剧的话需要指定季
const addSubscribe = async (season: number = 0) => {
// 开始处理
startNProgress(); startNProgress();
try { try {
const result: { [key: string]: any } = await api.post("subscribe", { const result: { [key: string]: any } = await api.post("subscribe", {
@@ -41,7 +61,7 @@ const addSubscribe = async () => {
year: props.media?.year, year: props.media?.year,
tmdbid: props.media?.tmdb_id, tmdbid: props.media?.tmdb_id,
doubanid: props.media?.douban_id, doubanid: props.media?.douban_id,
season: props.media?.season, season: season,
}); });
// 订阅状态 // 订阅状态
if (result.success) { if (result.success) {
@@ -93,12 +113,22 @@ const checkSubscribe = async () => {
} }
}; };
// 查询TMDB的季信息
const getMediaSeasons = async () => {
try {
const result: TmdbSeason[] = await api.get(`tmdb/${props.media?.tmdb_id}/seasons`);
return result;
} catch (error) {
console.error(error);
}
};
// 订阅按钮响应 // 订阅按钮响应
const handleSubscribe = () => { const handleSubscribe = () => {
if (isSubscribed.value) { if (isSubscribed.value) {
removeSubscribe(); removeSubscribe();
} else { } else {
addSubscribe(); handleAddSubscribe();
} }
}; };
-1
View File
@@ -30,7 +30,6 @@ const lastUpdateText = ref(
// 图片加载完成响应 // 图片加载完成响应
const imageLoadHandler = () => { const imageLoadHandler = () => {
console.log(imageLoaded.value);
imageLoaded.value = true; imageLoaded.value = true;
}; };