更新 ChineseNfoRegistry 类中的 JobExecute 方法,增加可选参数以支持 TMDB ID、季号和集号;改进错误处理,使用日志记录替代控制台输出。
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user