mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-06-28 00:27:06 +08:00
fix iqiyi
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Jellyfin.Plugin.Danmu.Test
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var keyword = "与凤行";
|
var keyword = "又见逍遥";
|
||||||
var result = await api.SearchAsync(keyword, CancellationToken.None);
|
var result = await api.SearchAsync(keyword, CancellationToken.None);
|
||||||
Console.WriteLine(result);
|
Console.WriteLine(result);
|
||||||
}
|
}
|
||||||
@@ -51,8 +51,8 @@ namespace Jellyfin.Plugin.Danmu.Test
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// var id = "25f5iplvm8s"; // 综艺
|
var id = "25f5iplvm8s"; // 综艺
|
||||||
var id = "xkt6z3z798"; // 电视剧
|
// var id = "19tfhh8axvc"; // 电视剧
|
||||||
// var id = "1e54n0pt5ro"; // 电影
|
// var id = "1e54n0pt5ro"; // 电影
|
||||||
var result = await api.GetVideoAsync(id, CancellationToken.None);
|
var result = await api.GetVideoAsync(id, CancellationToken.None);
|
||||||
Console.WriteLine(result);
|
Console.WriteLine(result);
|
||||||
@@ -73,7 +73,7 @@ namespace Jellyfin.Plugin.Danmu.Test
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var albumId = "7765466759502501";
|
var albumId = "252894801";
|
||||||
var result = await api.GetZongyiEpisodesAsync(albumId, CancellationToken.None);
|
var result = await api.GetZongyiEpisodesAsync(albumId, CancellationToken.None);
|
||||||
Console.WriteLine(result);
|
Console.WriteLine(result);
|
||||||
}
|
}
|
||||||
@@ -125,5 +125,6 @@ namespace Jellyfin.Plugin.Danmu.Test
|
|||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,5 +175,28 @@ namespace Jellyfin.Plugin.Danmu.Test
|
|||||||
}).GetAwaiter().GetResult();
|
}).GetAwaiter().GetResult();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetEpisodesForApi()
|
||||||
|
{
|
||||||
|
var api = new Iqiyi(loggerFactory);
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var id = "25f5iplvm8s"; // 综艺
|
||||||
|
// var id = "19tfhh8axvc"; // 电视剧
|
||||||
|
// var id = "1e54n0pt5ro"; // 电影
|
||||||
|
var result = await api.GetEpisodesForApi(id);
|
||||||
|
Console.WriteLine(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
using System.Text.RegularExpressions;
|
|
||||||
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.Iqiyi.Entity
|
|
||||||
{
|
|
||||||
public class IqiyiHtmlAlbumInfo
|
|
||||||
{
|
|
||||||
[JsonPropertyName("qipuId")]
|
|
||||||
public Int64 AlbumId { get; set; }
|
|
||||||
[JsonPropertyName("albumName")]
|
|
||||||
public string AlbumName { get; set; }
|
|
||||||
[JsonPropertyName("albumPageUrl")]
|
|
||||||
public string AlbumUrl { get; set; }
|
|
||||||
[JsonPropertyName("videoCount")]
|
|
||||||
public int VideoCount { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity
|
namespace Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity
|
||||||
{
|
{
|
||||||
@@ -12,26 +8,24 @@ namespace Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity
|
|||||||
{
|
{
|
||||||
private static readonly Regex regLinkId = new Regex(@"v_(\w+?)\.html", RegexOptions.Compiled);
|
private static readonly Regex regLinkId = new Regex(@"v_(\w+?)\.html", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
[JsonPropertyName("albumId")]
|
||||||
[JsonPropertyName("albumQipuId")]
|
public long AlbumId { get; set; }
|
||||||
public Int64 AlbumId { get; set; }
|
[JsonPropertyName("tvId")]
|
||||||
[JsonPropertyName("tvid")]
|
public long TvId { get; set; }
|
||||||
public Int64 TvId { get; set; }
|
[JsonPropertyName("name")]
|
||||||
[JsonPropertyName("videoName")]
|
public string VideoName { get; set; }
|
||||||
public String VideoName { get; set; }
|
[JsonPropertyName("playUrl")]
|
||||||
[JsonPropertyName("videoUrl")]
|
public string VideoUrl { get; set; }
|
||||||
public String VideoUrl { get; set; }
|
[JsonPropertyName("channelId")]
|
||||||
[JsonPropertyName("channelName")]
|
public int channelId { get; set; }
|
||||||
public string ChannelName { get; set; }
|
[JsonPropertyName("durationSec")]
|
||||||
[JsonPropertyName("duration")]
|
|
||||||
public int Duration { get; set; }
|
public int Duration { get; set; }
|
||||||
|
[JsonPropertyName("videoCount")]
|
||||||
|
public int VideoCount { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<IqiyiEpisode> Epsodelist { get; set; }
|
public List<IqiyiEpisode> Epsodelist { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public IqiyiHtmlAlbumInfo? AlbumInfo { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string LinkId
|
public string LinkId
|
||||||
{
|
{
|
||||||
@@ -49,5 +43,30 @@ namespace Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string ChannelName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (channelId)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return "电影";
|
||||||
|
case 2:
|
||||||
|
return "电视剧";
|
||||||
|
case 3:
|
||||||
|
return "纪录片";
|
||||||
|
case 4:
|
||||||
|
return "动漫";
|
||||||
|
case 6:
|
||||||
|
return "综艺";
|
||||||
|
case 15:
|
||||||
|
return "儿童";
|
||||||
|
default:
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class Iqiyi : AbstractScraper
|
|||||||
{
|
{
|
||||||
foreach (var ep in video.Epsodelist)
|
foreach (var ep in video.Epsodelist)
|
||||||
{
|
{
|
||||||
media.Episodes.Add(new ScraperEpisode() { Id = $"{ep.LinkId}", CommentId = $"{ep.TvId}" });
|
media.Episodes.Add(new ScraperEpisode() { Id = $"{ep.LinkId}", CommentId = $"{ep.TvId}", Title = ep.Name });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ public class Iqiyi : AbstractScraper
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ScraperEpisode() { Id = id, CommentId = $"{video.TvId}" };
|
return new ScraperEpisode() { Id = id, CommentId = $"{video.TvId}", Title = video.VideoName };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ScraperDanmaku?> GetDanmuContent(BaseItem item, string commentId)
|
public override async Task<ScraperDanmaku?> GetDanmuContent(BaseItem item, string commentId)
|
||||||
|
|||||||
@@ -2,22 +2,17 @@ using System.IO;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using ComposableAsync;
|
using ComposableAsync;
|
||||||
using Jellyfin.Plugin.Danmu.Core.Extensions;
|
using Jellyfin.Plugin.Danmu.Core.Extensions;
|
||||||
using Jellyfin.Plugin.Danmu.Scrapers.Entity;
|
|
||||||
using Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity;
|
using Jellyfin.Plugin.Danmu.Scrapers.Iqiyi.Entity;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using RateLimiter;
|
using RateLimiter;
|
||||||
using ICSharpCode.SharpZipLib.Core;
|
|
||||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
@@ -25,8 +20,8 @@ namespace Jellyfin.Plugin.Danmu.Scrapers.Iqiyi;
|
|||||||
|
|
||||||
public class IqiyiApi : AbstractApi
|
public class IqiyiApi : AbstractApi
|
||||||
{
|
{
|
||||||
private new const string HTTP_USER_AGENT = "Mozilla/5.0 (Linux; Android 10; SM-G981B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Mobile Safari/537.36 Edg/115.0.0.0";
|
private new const string HTTP_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.183";
|
||||||
private static readonly Regex regVideoInfo = new Regex(@"""videoInfo"":(\{.+?\}),", RegexOptions.Compiled);
|
private static readonly Regex regVideoInfo = new Regex(@"pageProps"":\{""videoInfo"":(\{.+?\}),""featureInfo", RegexOptions.Compiled);
|
||||||
private static readonly Regex regAlbumInfo = new Regex(@"""albumInfo"":(\{.+?\}),", RegexOptions.Compiled);
|
private static readonly Regex regAlbumInfo = new Regex(@"""albumInfo"":(\{.+?\}),", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
|
||||||
@@ -104,21 +99,21 @@ public class IqiyiApi : AbstractApi
|
|||||||
var videoInfo = await GetVideoBaseAsync(id, cancellationToken).ConfigureAwait(false);
|
var videoInfo = await GetVideoBaseAsync(id, cancellationToken).ConfigureAwait(false);
|
||||||
if (videoInfo != null)
|
if (videoInfo != null)
|
||||||
{
|
{
|
||||||
if (videoInfo.ChannelName == "综艺" && videoInfo.AlbumInfo != null)
|
if (videoInfo.channelId == 6)
|
||||||
{ // 综艺需要特殊处理
|
{ // 综艺需要特殊处理
|
||||||
videoInfo.Epsodelist = await this.GetZongyiEpisodesAsync($"{videoInfo.AlbumInfo.AlbumId}", cancellationToken).ConfigureAwait(false);
|
videoInfo.Epsodelist = await this.GetZongyiEpisodesAsync($"{videoInfo.AlbumId}", cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (videoInfo.ChannelName != "电影" && videoInfo.AlbumInfo != null)
|
else if (videoInfo.channelId == 1)
|
||||||
{ // 电视剧需要再获取剧集信息
|
|
||||||
videoInfo.Epsodelist = await this.GetEpisodesAsync($"{videoInfo.AlbumId}", videoInfo.AlbumInfo.VideoCount, cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
else if (videoInfo.ChannelName == "电影")
|
|
||||||
{ // 电影
|
{ // 电影
|
||||||
var duration = new TimeSpan(0, 0, videoInfo.Duration);
|
var duration = new TimeSpan(0, 0, videoInfo.Duration);
|
||||||
videoInfo.Epsodelist = new List<IqiyiEpisode>() {
|
videoInfo.Epsodelist = new List<IqiyiEpisode>() {
|
||||||
new IqiyiEpisode() {TvId = videoInfo.TvId, Order = 1, Name = videoInfo.VideoName, Duration = duration.ToString(@"hh\:mm\:ss"), PlayUrl = videoInfo.VideoUrl}
|
new IqiyiEpisode() {TvId = videoInfo.TvId, Order = 1, Name = videoInfo.VideoName, Duration = duration.ToString(@"hh\:mm\:ss"), PlayUrl = videoInfo.VideoUrl}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{ // 电视剧需要再获取剧集信息
|
||||||
|
videoInfo.Epsodelist = await this.GetEpisodesAsync($"{videoInfo.AlbumId}", videoInfo.VideoCount, cancellationToken).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
_memoryCache.Set<IqiyiHtmlVideoInfo?>(cacheKey, videoInfo, expiredOption);
|
_memoryCache.Set<IqiyiHtmlVideoInfo?>(cacheKey, videoInfo, expiredOption);
|
||||||
return videoInfo;
|
return videoInfo;
|
||||||
@@ -144,7 +139,7 @@ public class IqiyiApi : AbstractApi
|
|||||||
|
|
||||||
await this.LimitRequestFrequently();
|
await this.LimitRequestFrequently();
|
||||||
|
|
||||||
var url = $"https://m.iqiyi.com/v_{id}.html";
|
var url = $"https://www.iqiyi.com/v_{id}.html";
|
||||||
var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
var response = await httpClient.GetAsync(url, cancellationToken).ConfigureAwait(false);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
@@ -153,13 +148,9 @@ public class IqiyiApi : AbstractApi
|
|||||||
var videoInfo = videoJson.FromJson<IqiyiHtmlVideoInfo>();
|
var videoInfo = videoJson.FromJson<IqiyiHtmlVideoInfo>();
|
||||||
if (videoInfo != null)
|
if (videoInfo != null)
|
||||||
{
|
{
|
||||||
var albumJson = regAlbumInfo.FirstMatchGroup(body);
|
this._memoryCache.Set(cacheKey, videoInfo, expiredOption);
|
||||||
videoInfo.AlbumInfo = albumJson.FromJson<IqiyiHtmlAlbumInfo>();
|
|
||||||
_memoryCache.Set<IqiyiHtmlVideoInfo?>(cacheKey, videoInfo, expiredOption);
|
|
||||||
return videoInfo;
|
return videoInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
_memoryCache.Set<IqiyiHtmlVideoInfo?>(cacheKey, null, expiredOption);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user