mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-04-24 10:30:33 +08:00
Support bilibili ugc collection
This commit is contained in:
@@ -83,5 +83,25 @@ namespace Jellyfin.Plugin.Danmu.Test
|
||||
}
|
||||
}).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetVideoByBvidForCollectionAsync()
|
||||
{
|
||||
var bvid = "BV1z34y1h7yQ";
|
||||
var _bilibiliApi = new BilibiliApi(loggerFactory);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _bilibiliApi.GetVideoByBvidAsync(bvid, CancellationToken.None);
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,9 +64,21 @@ public class Bilibili : AbstractScraper
|
||||
|
||||
media.Id = id;
|
||||
media.Name = video.Title;
|
||||
foreach (var (page, idx) in video.Pages.WithIndex())
|
||||
if (video.UgcSeason != null && video.UgcSeason.Sections != null && video.UgcSeason.Sections.Count > 0)
|
||||
{
|
||||
media.Episodes.Add(new ScraperEpisode() { Id = "", CommentId = $"{page.Cid}" });
|
||||
// 合集
|
||||
foreach (var (page, idx) in video.UgcSeason.Sections[0].Episodes.WithIndex())
|
||||
{
|
||||
media.Episodes.Add(new ScraperEpisode() { Id = "", CommentId = $"{page.CId}" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 分P
|
||||
foreach (var (page, idx) in video.Pages.WithIndex())
|
||||
{
|
||||
media.Episodes.Add(new ScraperEpisode() { Id = "", CommentId = $"{page.Cid}" });
|
||||
}
|
||||
}
|
||||
|
||||
return media;
|
||||
|
||||
@@ -24,5 +24,8 @@ namespace Jellyfin.Plugin.Danmu.Scrapers.Bilibili.Entity
|
||||
|
||||
[JsonPropertyName("pages")]
|
||||
public VideoPart[] Pages { get; set; }
|
||||
|
||||
[JsonPropertyName("ugc_season")]
|
||||
public VideoUgcSeason? UgcSeason { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jellyfin.Plugin.Danmu.Scrapers.Bilibili.Entity
|
||||
{
|
||||
public class VideoUgcSeason
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonPropertyName("sections")]
|
||||
public List<VideoUgcSection> Sections { get; set; }
|
||||
}
|
||||
|
||||
public class VideoUgcSection
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonPropertyName("episodes")]
|
||||
public List<VideoEpisode> Episodes { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user