diff --git a/Jellyfin.Plugin.Danmu/Controllers/DanmuController.cs b/Jellyfin.Plugin.Danmu/Controllers/DanmuController.cs
index fc1c9b0..33b0647 100644
--- a/Jellyfin.Plugin.Danmu/Controllers/DanmuController.cs
+++ b/Jellyfin.Plugin.Danmu/Controllers/DanmuController.cs
@@ -104,6 +104,40 @@ namespace Jellyfin.Plugin.Danmu.Controllers
return File(System.IO.File.ReadAllBytes(danmuPath), "text/xml");
}
+ ///
+ /// 跳转链接.
+ ///
+ [Route("goto")]
+ [HttpGet]
+ public RedirectResult GoTo(string provider, string id, string type)
+ {
+ var url = $"/";
+ switch (provider)
+ {
+ case "bilibili":
+ if (id.StartsWith("BV"))
+ {
+ url = $"https://www.bilibili.com/video/{id}/";
+ }
+ else
+ {
+ if (type == "movie")
+ {
+ url = $"https://www.bilibili.com/bangumi/play/ep{id}";
+ }
+ else
+ {
+ url = $"https://www.bilibili.com/bangumi/play/ss{id}";
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return Redirect(url);
+ }
+
+
///
/// 重新获取对应的弹幕id.
diff --git a/Jellyfin.Plugin.Danmu/DanmuSubtitleProvider.cs b/Jellyfin.Plugin.Danmu/DanmuSubtitleProvider.cs
index dda4351..39c36d7 100644
--- a/Jellyfin.Plugin.Danmu/DanmuSubtitleProvider.cs
+++ b/Jellyfin.Plugin.Danmu/DanmuSubtitleProvider.cs
@@ -61,7 +61,16 @@ public class DanmuSubtitleProvider : ISubtitleProvider
var scraper = _scraperManager.All().FirstOrDefault(x => x.ProviderId == info.ProviderId);
if (scraper != null)
{
- UpdateDanmuMetadata(item, scraper.ProviderId, info.Id);
+ // 注意!!:item这里要使用临时对象,假如直接修改原始item的ProviderIds,会导致直接修改原始item数据
+ if (item is Movie)
+ {
+ item = new Movie() { Id = item.Id, Name = item.Name, ProviderIds = new Dictionary() { { scraper.ProviderId, info.Id } } };
+ }
+ if (item is Episode)
+ {
+ item = new Episode() { Id = item.Id, Name = item.Name, ProviderIds = new Dictionary() { { scraper.ProviderId, info.Id } } };
+ }
+
_libraryManagerEventsHelper.QueueItem(item, EventType.Force);
}
diff --git a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs
index 56fb9c1..1262bda 100644
--- a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs
+++ b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs
@@ -364,25 +364,29 @@ public class LibraryManagerEventsHelper : IDisposable
// 强制刷新指定来源弹幕
if (eventType == EventType.Force)
{
- foreach (var item in movies)
+ foreach (var queueItem in movies)
{
- // 找到强制的scraper
- var scraper = _scraperManager.All().FirstOrDefault(x => item.ProviderIds.ContainsKey(x.ProviderId));
+ // 找到选择的scraper
+ var scraper = _scraperManager.All().FirstOrDefault(x => queueItem.ProviderIds.ContainsKey(x.ProviderId));
if (scraper == null)
{
continue;
}
- var mediaId = item.GetProviderId(scraper.ProviderId);
+ // 获取选择的弹幕Id
+ var mediaId = queueItem.GetProviderId(scraper.ProviderId);
if (string.IsNullOrEmpty(mediaId))
{
continue;
}
-
+ // 获取最新的item数据
+ var item = _libraryManager.GetItemById(queueItem.Id);
var media = await scraper.GetMedia(item, mediaId);
if (media != null)
{
+ await this.ForceSaveProviderId(item, scraper.ProviderId, media.Id);
+
var episode = await scraper.GetMediaEpisode(item, media.Id);
if (episode != null)
{
@@ -390,7 +394,6 @@ public class LibraryManagerEventsHelper : IDisposable
await this.DownloadDanmu(scraper, item, episode.CommentId, true).ConfigureAwait(false);
}
- await this.ForceSaveProviderId(item, scraper.ProviderId, media.Id);
}
}
}
@@ -659,22 +662,25 @@ public class LibraryManagerEventsHelper : IDisposable
// 强制刷新指定来源弹幕
if (eventType == EventType.Force)
{
- foreach (var item in episodes)
+ foreach (var queueItem in episodes)
{
- // 找到强制的scraper
- var scraper = _scraperManager.All().FirstOrDefault(x => item.ProviderIds.ContainsKey(x.ProviderId));
+ // 找到选择的scraper
+ var scraper = _scraperManager.All().FirstOrDefault(x => queueItem.ProviderIds.ContainsKey(x.ProviderId));
if (scraper == null)
{
continue;
}
- var mediaId = item.GetProviderId(scraper.ProviderId);
+ // 获取选择的弹幕Id
+ var mediaId = queueItem.GetProviderId(scraper.ProviderId);
if (string.IsNullOrEmpty(mediaId))
{
continue;
}
+ // 获取最新的item数据
+ var item = _libraryManager.GetItemById(queueItem.Id);
var season = ((Episode)item).Season;
if (season == null)
{
@@ -684,6 +690,9 @@ public class LibraryManagerEventsHelper : IDisposable
var media = await scraper.GetMedia(season, mediaId);
if (media != null)
{
+ // 更新季元数据
+ await ForceSaveProviderId(season, scraper.ProviderId, media.Id);
+
// 更新所有剧集元数据,GetEpisodes一定要取所有fields,要不然更新会导致重建虚拟season季信息
var episodeList = season.GetEpisodes(null, new DtoOptions(true));
foreach (var (episode, idx) in episodeList.WithIndex())
@@ -704,10 +713,6 @@ public class LibraryManagerEventsHelper : IDisposable
// 更新剧集元数据
await ForceSaveProviderId(episode, scraper.ProviderId, epId);
}
-
- // 更新季元数据
- await ForceSaveProviderId(season, scraper.ProviderId, media.Id);
-
}
}
}