Skip to content

Commit

Permalink
feat: override the persons of media_profile when refresh the media pr…
Browse files Browse the repository at this point in the history
…ofile
  • Loading branch information
ltaoo committed Jul 9, 2024
1 parent 5f00092 commit 4409192
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/domains/media_profile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ export class MediaProfileClient {
if (season_number === undefined) {
return Result.Err("详情 id 不包含 season_number");
}
const r0 = await this.cache_tv_profile({ id: tmdb_id });
const r0 = await this.cache_tv_profile({ id: tmdb_id }, { force: true });
if (r0.error) {
return Result.Err(r0.error.message);
}
Expand Down Expand Up @@ -984,7 +984,10 @@ export class MediaProfileClient {
}
return Result.Err("未知类型");
}
async refresh_profile_with_douban(data: MediaProfileRecord & { series: MediaSeriesProfileRecord | null }) {
async refresh_profile_with_douban(
data: MediaProfileRecord & { series: MediaSeriesProfileRecord | null },
extra: Partial<{ override: number }> = {}
) {
const { id, name, order, air_date, series } = data;
const client = this.$douban;
const store = this.$store;
Expand Down Expand Up @@ -1025,7 +1028,7 @@ export class MediaProfileClient {
return;
}
const matched = match_r.data;
const r2 = await this.refresh_profile_with_douban_id(data, { douban_id: matched.id });
const r2 = await this.refresh_profile_with_douban_id(data, { douban_id: matched.id, override: extra.override });
if (r2.error) {
tips.push(r2.error.message);
}
Expand Down Expand Up @@ -1069,7 +1072,7 @@ export class MediaProfileClient {
return Result.Err(tip);
}
const profile = profile_r.data;
console.log("[DOMAIN]media_profile/index - refresh_profile_with_douban_id", profile, media.air_date);
// console.log("[DOMAIN]media_profile/index - refresh_profile_with_douban_id", profile, media.air_date);
for (let i = 0; i < profile.genres.length; i += 1) {
const { id, text } = profile.genres[i];
const e = await store.prisma.media_genre.findFirst({
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/v2/media_profile/init_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default async function v2_media_profile_init_series(
return Result.Err(profile_client_res.error.message);
}
const profile_client = profile_client_res.data;
const r = await profile_client.cache_tv_profile({ id: series_id });
const r = await profile_client.cache_tv_profile({ id: series_id }, { force: true });
if (r.error) {
return Result.Err(r.error.message);
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/v2/media_profile/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export default async function v2_media_profile_refresh(
}
const r2 = await (async () => {
if (douban_id) {
return client.refresh_profile_with_douban_id(media, { douban_id: Number(douban_id), override });
return client.refresh_profile_with_douban_id(media, { douban_id: Number(douban_id), override: 1 });
}
return client.refresh_profile_with_douban(media);
return client.refresh_profile_with_douban(media, { override: 1 });
})();
if (r2.error) {
return e(Result.Err(r2.error.message));
Expand Down

0 comments on commit 4409192

Please sign in to comment.