mirror of
https://github.com/cxfksword/jellyfin-plugin-danmu.git
synced 2026-02-03 02:04:47 +08:00
Update README.md
This commit is contained in:
@@ -41,6 +41,37 @@ namespace Jellyfin.Plugin.Danmu.Test
|
||||
}).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSearchFrequently()
|
||||
{
|
||||
|
||||
|
||||
var loggerFactory = LoggerFactory.Create(builder =>
|
||||
builder.AddSimpleConsole(options =>
|
||||
{
|
||||
options.IncludeScopes = true;
|
||||
options.SingleLine = true;
|
||||
options.TimestampFormat = "hh:mm:ss ";
|
||||
}));
|
||||
var _bilibiliApi = new BilibiliApi(loggerFactory);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var keyword = "哆啦A梦 第四季";
|
||||
var result = await _bilibiliApi.SearchAsync(keyword, CancellationToken.None);
|
||||
keyword = "哆啦A梦";
|
||||
result = await _bilibiliApi.SearchAsync(keyword, CancellationToken.None);
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetVideoByBvidAsync()
|
||||
{
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Jellyfin.Plugin.Danmu.Api
|
||||
private HttpClient httpClient;
|
||||
private CookieContainer _cookieContainer;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
private static readonly object _lock = new object();
|
||||
private DateTime lastRequestTime = DateTime.Now.AddDays(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BilibiliApi"/> class.
|
||||
@@ -150,6 +152,7 @@ namespace Jellyfin.Plugin.Danmu.Api
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
// this.LimitRequestFrequently();
|
||||
await EnsureSessionCookie(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
keyword = HttpUtility.UrlEncode(keyword);
|
||||
@@ -275,6 +278,24 @@ namespace Jellyfin.Plugin.Danmu.Api
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
protected void LimitRequestFrequently()
|
||||
{
|
||||
var startTime = DateTime.Now;
|
||||
lock (_lock)
|
||||
{
|
||||
var ts = DateTime.Now - lastRequestTime;
|
||||
var diff = (int)(200 - ts.TotalMilliseconds);
|
||||
if (diff > 0)
|
||||
{
|
||||
Thread.Sleep(diff);
|
||||
}
|
||||
lastRequestTime = DateTime.Now;
|
||||
}
|
||||
var endTime = DateTime.Now;
|
||||
var tt = (endTime - startTime).TotalMilliseconds;
|
||||
Console.WriteLine(tt);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
11
README.md
11
README.md
@@ -60,4 +60,13 @@ $ dotnet publish -c Release Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj
|
||||
|
||||
2. Create a folder, like `Danmu` and copy `bin/Release/Jellyfin.Plugin.Danmu.dll` into it
|
||||
|
||||
3. Move folder `Danmu` to jellyfin `data/plugin` folder
|
||||
3. Move folder `Danmu` to jellyfin `data/plugin` folder
|
||||
|
||||
## Thanks
|
||||
|
||||
[downkyi](https://github.com/leiurayer/downkyi)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Apache License Version 2.0
|
||||
Reference in New Issue
Block a user