mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-02-03 02:04:47 +08:00
Fix dandanplay json error. fix #17
This commit is contained in:
@@ -125,7 +125,7 @@ public class DanmuSubtitleProvider : ISubtitleProvider
|
||||
{
|
||||
title += $" ({searchInfo.Year})";
|
||||
}
|
||||
if (searchInfo.EpisodeSize > 1)
|
||||
if (item is Episode && searchInfo.EpisodeSize > 0)
|
||||
{
|
||||
title += $"【共{searchInfo.EpisodeSize}集】";
|
||||
}
|
||||
|
||||
@@ -214,11 +214,11 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
}
|
||||
break;
|
||||
case Episode when ev.EventType is EventType.Update:
|
||||
_logger.LogInformation("Episode update: {0}", ev.Item.Name);
|
||||
_logger.LogInformation("Episode update: {0}.{1}", ev.Item.IndexNumber, ev.Item.Name);
|
||||
queuedEpisodeUpdates.Add(ev);
|
||||
break;
|
||||
case Episode when ev.EventType is EventType.Force:
|
||||
_logger.LogInformation("Episode force: {0}", ev.Item.Name);
|
||||
_logger.LogInformation("Episode force: {0}.{1}", ev.Item.IndexNumber, ev.Item.Name);
|
||||
queuedEpisodeForces.Add(ev);
|
||||
break;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "[{0}]Exception handled processing queued movie events", scraper.Name);
|
||||
_logger.LogError(ex, "[{0}]Exception handled processing movie events", scraper.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -501,6 +501,12 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
_logger.LogInformation("[{0}]匹配失败:{1} ({2})", scraper.Name, season.Name, season.ProductionYear);
|
||||
continue;
|
||||
}
|
||||
var media = await scraper.GetMedia(season, mediaId);
|
||||
if (media == null)
|
||||
{
|
||||
_logger.LogInformation("[{0}]匹配成功,但获取不到视频信息. id: {1}", scraper.Name, mediaId);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// 更新seasonId元数据
|
||||
@@ -516,7 +522,7 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Exception handled processing queued movie events");
|
||||
_logger.LogError(ex, "Exception handled processing season events");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -791,10 +797,10 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
public async Task DownloadDanmu(AbstractScraper scraper, BaseItem item, string commentId, bool ignoreCheck = false)
|
||||
{
|
||||
// 下载弹幕xml文件
|
||||
var checkDownloadedKey = $"{item.Id}_{commentId}";
|
||||
try
|
||||
{
|
||||
// 弹幕5分钟内更新过,忽略处理(有时Update事件会重复执行)
|
||||
var checkDownloadedKey = $"{item.Id}_{commentId}";
|
||||
if (!ignoreCheck && _memoryCache.TryGetValue(checkDownloadedKey, out var latestDownloaded))
|
||||
{
|
||||
_logger.LogInformation("[{0}]最近5分钟已更新过弹幕xml,忽略处理:{1}.{2}", scraper.Name, item.IndexNumber, item.Name);
|
||||
@@ -821,6 +827,7 @@ public class LibraryManagerEventsHelper : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_memoryCache.Remove(checkDownloadedKey);
|
||||
_logger.LogError(ex, "[{0}]Exception handled download danmu file. name={1}", scraper.Name, item.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Web;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Jellyfin.Plugin.Danmu.Scrapers.Dandan.Entity;
|
||||
using Jellyfin.Plugin.Danmu.Configuration;
|
||||
using Jellyfin.Plugin.Danmu.Core.Extensions;
|
||||
|
||||
namespace Jellyfin.Plugin.Danmu.Scrapers.Dandan;
|
||||
|
||||
@@ -57,8 +58,7 @@ public class DandanApi : AbstractApi
|
||||
|
||||
var cacheKey = $"search_{keyword}";
|
||||
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5) };
|
||||
List<Anime> searchResult;
|
||||
if (_memoryCache.TryGetValue<List<Anime>>(cacheKey, out searchResult))
|
||||
if (_memoryCache.TryGetValue<List<Anime>>(cacheKey, out var searchResult))
|
||||
{
|
||||
return searchResult;
|
||||
}
|
||||
@@ -89,8 +89,7 @@ public class DandanApi : AbstractApi
|
||||
|
||||
var cacheKey = $"anime_{animeId}";
|
||||
var expiredOption = new MemoryCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(30) };
|
||||
Anime? anime;
|
||||
if (_memoryCache.TryGetValue<Anime?>(cacheKey, out anime))
|
||||
if (_memoryCache.TryGetValue<Anime?>(cacheKey, out var anime))
|
||||
{
|
||||
return anime;
|
||||
}
|
||||
@@ -100,10 +99,16 @@ public class DandanApi : AbstractApi
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var result = await response.Content.ReadFromJsonAsync<AnimeResult>(_jsonOptions, cancellationToken).ConfigureAwait(false);
|
||||
if (result != null && result.Success)
|
||||
if (result != null && result.Success && result.Bangumi != null)
|
||||
{
|
||||
_memoryCache.Set<Anime?>(cacheKey, result.Bangumi, expiredOption);
|
||||
return result.Bangumi;
|
||||
// 过滤掉特典剧集,episodeNumber为S1/S2.。。
|
||||
anime = result.Bangumi;
|
||||
if (anime.Episodes != null)
|
||||
{
|
||||
anime.Episodes = anime.Episodes.Where(x => x.EpisodeNumber.ToInt() > 0).ToList();
|
||||
}
|
||||
_memoryCache.Set<Anime?>(cacheKey, anime, expiredOption);
|
||||
return anime;
|
||||
}
|
||||
|
||||
_memoryCache.Set<Anime?>(cacheKey, null, expiredOption);
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace Jellyfin.Plugin.Danmu.Scrapers.Dandan.Entity
|
||||
public string EpisodeTitle { get; set; }
|
||||
|
||||
[JsonPropertyName("episodeNumber")]
|
||||
public int EpisodeNumber { get; set; }
|
||||
public string EpisodeNumber { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user