更新 ChineseNfoRegistry 类中的 JobExecute 方法,增加可选参数以支持 TMDB ID、季号和集号;改进错误处理,使用日志记录替代控制台输出。
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 15s
Docker Build & Deploy / Deploy to Production (push) Successful in 5s

This commit is contained in:
孙诚
2025-04-17 18:46:41 +08:00
parent ec3434da82
commit 3288df0f25
2 changed files with 23 additions and 15 deletions

View File

@@ -58,7 +58,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
{
try
{
await JobExecute(ignoreLocked, ignoreCompleted);
await JobExecute(tmdbId, seasonNumber, episodeNumber, ignoreLocked, ignoreCompleted);
}
catch (Exception e)
{
@@ -67,8 +67,11 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
private async Task JobExecute(
bool ignoreLocked,
bool ignoreCompleted)
string? tmdbId = null,
string? seasonNumber = null,
string? episodeNumber = null,
bool ignoreLocked = false,
bool ignoreCompleted = false)
{
var tvFolder = _configuration["ChineseNfo:TvFolder"];
@@ -631,7 +634,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbTv() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -648,7 +651,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbTv() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}
@@ -682,7 +685,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbPerson() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -700,7 +703,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbPerson() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}
@@ -733,7 +736,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbPersonSearch() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -761,7 +764,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbPersonSearch() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}
@@ -778,7 +781,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbImage() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -786,7 +789,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbImage() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}
@@ -822,7 +825,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbSeason() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -838,7 +841,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbSeason() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}
@@ -875,7 +878,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
if (!response.IsSuccessStatusCode)
{
Console.WriteLine($"{requestUrl} & {path} & {response.StatusCode}");
_logger.LogError("ChineseNfoRegistry.GetTmdbEpisode() 接口调用失败 {requestUrl} & {path} & {response.StatusCode}", requestUrl, path, response.StatusCode);
return null;
}
@@ -891,7 +894,7 @@ public class ChineseNfoRegistry : Registry, IChineseNfoRegistry
}
catch (Exception e)
{
Console.WriteLine($"{requestUrl} & {path} \r {e}");
_logger.LogError("ChineseNfoRegistry.GetTmdbEpisode() 接口调用失败 {requestUrl} & {path} \r {e}", requestUrl, path, e);
return null;
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.Json.Nodes;
using Core;
using Interface.Jobs;
using Microsoft.AspNetCore.Mvc;
@@ -118,6 +119,10 @@ public class JobTriggerController : BaseController
var tmdbId = json?["series"]?["tmdbId"]?.ToString();
var seasonNumber = json?["episodes"]?[0]?["seasonNumber"]?.ToString();
var episodeNumber = json?["episodes"]?[0]?["episodeNumber"]?.ToString();
var path = json?["series"]?["path"]?.ToString();
var eventType = json?["eventType"]?.ToString();
await WxNotify.SendCommonAsync($"SonarrChangedConvertChineseNfo: {tmdbId}, {seasonNumber}, {episodeNumber}, {path}, {eventType}");
_chineseNfoRegistry.Job(tmdbId: tmdbId, seasonNumber: seasonNumber, episodeNumber: episodeNumber);