Skip to content

Commit

Permalink
fix all anime #76
Browse files Browse the repository at this point in the history
  • Loading branch information
insomniachi committed Dec 24, 2023
1 parent 2fcfa81 commit 87bd0e4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 36 deletions.
Binary file modified Plugins Store/Totoro.Plugins.Anime.AllAnime.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@
namespace Totoro.Plugins.Anime.AllAnime.Tests;

[ExcludeFromCodeCoverage]
public class CatalogTests
public class CatalogTests(ITestOutputHelper output)
{
private readonly ITestOutputHelper _output;
private readonly ITestOutputHelper _output = output;
private readonly JsonSerializerOptions _searializerOption = new() { WriteIndented = true };

public CatalogTests(ITestOutputHelper output)
{
_output = output;
}

[Theory]
[InlineData("hyouka")]
[InlineData("one pi")]
[InlineData("hyakkano")]
public async Task Search(string query)
{
// arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@
namespace Totoro.Plugins.Anime.AllAnime.Tests;

[ExcludeFromCodeCoverage]
public class StreamProviderTests
public class StreamProviderTests(ITestOutputHelper output)
{
public const string Hyouka = "hyouka";
public const string Hyakkano = "hyakkano";

private readonly ITestOutputHelper _output;
private readonly ITestOutputHelper _output = output;
private readonly JsonSerializerOptions _searializerOption = new() { WriteIndented = true };
private readonly Dictionary<string, string> _urlMap = new()
{
{ Hyouka, Url.Combine(Config.Url, "/anime/dxxqKsaMhdrdQxczP") }
{ Hyouka, Url.Combine(Config.Url, "/anime/dxxqKsaMhdrdQxczP") },
{ Hyakkano, Url.Combine(Config.Url, "/anime/pp9g8Qt7iem4RMjbJ") }
};
private readonly bool _allEpisodes = false;

public StreamProviderTests(ITestOutputHelper output)
{
_output = output;
}

[Theory]
[InlineData(Hyouka, 22)]
[InlineData(Hyakkano, 12)]
public async Task GetNumberOfEpisodes(string key, int expected)
{
// arrange
Expand All @@ -40,14 +38,15 @@ public async Task GetNumberOfEpisodes(string key, int expected)

[Theory]
[InlineData(Hyouka)]
[InlineData(Hyakkano)]
public async Task GetStreams(string key)
{
// arrange
var url = _urlMap[key];
var sut = new StreamProvider();

// act
var result = await sut.GetStreams(url, _allEpisodes ? Range.All : 1..1, Models.StreamType.EnglishSubbed).ToListAsync();
var result = await sut.GetStreams(url, _allEpisodes ? Range.All : 12..12, Models.StreamType.EnglishSubbed).ToListAsync();

Assert.NotEmpty(result);
foreach (var item in result)
Expand Down
39 changes: 22 additions & 17 deletions Plugins/Anime/Totoro.Plugins.Anime.AllAnime/StreamProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,32 @@ public async IAsyncEnumerable<VideoStreamsForEpisode> GetStreams(string url, Ran
var sourceArray = jsonNode?["episode"]?["sourceUrls"];
var sourceObjs = sourceArray?.ToObject<List<SourceUrlObj>>() ?? [];
sourceObjs.Sort((x, y) => y.priority.CompareTo(x.priority));
var item = sourceObjs.First();
item.sourceUrl = DecryptSourceUrl(item.sourceUrl);
if (item.type == "iframe")
{
var clockUrl = ClockRegex().Replace(apiEndPoint + item.sourceUrl, ".json");
var stream = await Extract(clockUrl);
if (stream is not null)
{
stream.Episode = e;
yield return stream;
}
}
else

foreach (var item in sourceObjs)
{
if (await Unpack(item.sourceUrl) is { } stream)
item.sourceUrl = DecryptSourceUrl(item.sourceUrl);

if (item.type == "iframe")
{
stream.Episode = e;
yield return stream;
var clockUrl = ClockRegex().Replace(apiEndPoint + item.sourceUrl, ".json");
var stream = await Extract(clockUrl);
if (stream is not null)
{
stream.Episode = e;
yield return stream;
yield break;
}
}
//else
//{
// if (await Unpack(item.sourceUrl) is { } stream)
// {
// stream.Episode = e;
// yield return stream;
// yield break;
// }
//}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
<Version>2.5</Version>
<Version>2.6</Version>
<OutputPath Condition="$(Configuration) == Release">..\..\..\Plugins Store\</OutputPath>
<AppendTargetFrameworkToOutputPath Condition="$(Configuration) == Release">false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath Condition="$(Configuration) == Release">false</AppendRuntimeIdentifierToOutputPath>
Expand Down
2 changes: 1 addition & 1 deletion plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
{
"DisplayName": "Allanime",
"Version": "2.5.0.0",
"Version": "2.6.0.0",
"FileName": "Totoro.Plugins.Anime.AllAnime.dll"
},
{
Expand Down

0 comments on commit 87bd0e4

Please sign in to comment.