fix: actor exception
This commit is contained in:
parent
c79bfc5bd1
commit
528be0ee1c
|
@ -243,6 +243,8 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
EnsureLoadDoubanCookie();
|
||||
await LimitRequestFrequently();
|
||||
|
||||
try
|
||||
{
|
||||
var encodedKeyword = HttpUtility.UrlEncode(keyword);
|
||||
var url = $"https://www.douban.com/j/search_suggest?q={encodedKeyword}";
|
||||
|
||||
|
@ -278,6 +280,11 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this._logger.LogError(ex, "SearchBySuggestAsync error. keyword: {0}", keyword);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -427,7 +434,12 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
var celebrityImg = celebrityImgStr.GetMatchGroup(this.regBackgroundImage);
|
||||
var celebrityNameStr = node.GetText("div.info a.name") ?? string.Empty;
|
||||
var arr = celebrityNameStr.Split(" ");
|
||||
var celebrityName = arr.Length > 1 ? arr[0] : celebrityNameStr;
|
||||
var celebrityName = arr.Length > 1 ? arr[0].Trim() : celebrityNameStr;
|
||||
// 有时存在演员信息缺少名字的
|
||||
if (string.IsNullOrEmpty(celebrityName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var celebrityRoleStr = node.GetText("div.info span.role") ?? string.Empty;
|
||||
var celebrityRole = celebrityRoleStr.GetMatchGroup(this.regRole);
|
||||
var arrRole = celebrityRoleStr.Split(" ");
|
||||
|
@ -588,9 +600,10 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
|
||||
public async Task<List<DoubanPhoto>> GetWallpaperBySidAsync(string sid, CancellationToken cancellationToken)
|
||||
{
|
||||
var list = new List<DoubanPhoto>();
|
||||
if (string.IsNullOrEmpty(sid))
|
||||
{
|
||||
return new List<DoubanPhoto>();
|
||||
return list;
|
||||
}
|
||||
|
||||
var cacheKey = $"photo_{sid}";
|
||||
|
@ -604,12 +617,13 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
EnsureLoadDoubanCookie();
|
||||
await LimitRequestFrequently();
|
||||
|
||||
var list = new List<DoubanPhoto>();
|
||||
try
|
||||
{
|
||||
var url = $"https://movie.douban.com/subject/{sid}/photos?type=W&start=0&sortby=size&size=a&subtype=a";
|
||||
var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new List<DoubanPhoto>();
|
||||
return list;
|
||||
}
|
||||
|
||||
var body = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
@ -650,6 +664,12 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
}
|
||||
|
||||
_memoryCache.Set<List<DoubanPhoto>>(cacheKey, list, expiredOption);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this._logger.LogError(ex, "GetWallpaperBySidAsync error. sid: {0}", sid);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -657,13 +677,20 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
|||
{
|
||||
EnsureLoadDoubanCookie();
|
||||
|
||||
try
|
||||
{
|
||||
var url = "https://www.douban.com/mine/";
|
||||
var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
var requestUrl = response.RequestMessage?.RequestUri?.ToString();
|
||||
if (requestUrl == null || requestUrl.Contains("login") || requestUrl.Contains("sec.douban.com"))
|
||||
if (requestUrl == null || requestUrl.Contains("accounts.douban.com") || requestUrl.Contains("login") || requestUrl.Contains("sec.douban.com"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this._logger.LogError(ex, "CheckLoginAsync error.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace Jellyfin.Plugin.MetaShark.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 代理访问图片.
|
||||
/// 检查豆瓣cookie是否失效.
|
||||
/// </summary>
|
||||
[Route("douban/checklogin")]
|
||||
[HttpGet]
|
||||
|
|
|
@ -80,8 +80,8 @@ namespace Jellyfin.Plugin.MetaShark.Model
|
|||
return limitCelebrities;
|
||||
}
|
||||
|
||||
limitCelebrities.AddRange(Celebrities.Where(x => x.RoleType == MediaBrowser.Model.Entities.PersonType.Director).Take(5));
|
||||
limitCelebrities.AddRange(Celebrities.Where(x => x.RoleType != MediaBrowser.Model.Entities.PersonType.Director));
|
||||
limitCelebrities.AddRange(Celebrities.Where(x => x.RoleType == MediaBrowser.Model.Entities.PersonType.Director && !string.IsNullOrEmpty(x.Name)).Take(5));
|
||||
limitCelebrities.AddRange(Celebrities.Where(x => x.RoleType != MediaBrowser.Model.Entities.PersonType.Director && !string.IsNullOrEmpty(x.Name)));
|
||||
|
||||
return limitCelebrities;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue