-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove references to animix play in ui
- Loading branch information
1 parent
b8868ad
commit f8939d7
Showing
21 changed files
with
223 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Reactive.Subjects; | ||
using Splat; | ||
|
||
namespace Totoro.Core.Services; | ||
|
||
public class AiredEpisodeNotifier : IAiredEpisodeNotifier | ||
{ | ||
private List<AiredEpisode> _previousState = new(); | ||
private readonly Subject<AiredEpisode> _onNewEpisode = new(); | ||
|
||
public IObservable<AiredEpisode> OnNewEpisode => _onNewEpisode; | ||
|
||
public AiredEpisodeNotifier(IRecentEpisodesProvider recentEpisodesProvider) | ||
{ | ||
Observable | ||
.Timer(TimeSpan.Zero, TimeSpan.FromMinutes(30)) | ||
.SelectMany(_ => recentEpisodesProvider.GetRecentlyAiredEpisodes()) | ||
.Select(enumerable => enumerable.ToList()) | ||
.Do(async list => | ||
{ | ||
list.RemoveAll(_previousState.Contains); | ||
_previousState = list; | ||
foreach (var item in list) | ||
{ | ||
item.MalId = await recentEpisodesProvider.GetMalId(item); | ||
_onNewEpisode.OnNext(item); | ||
} | ||
}) | ||
.Subscribe(_ => { }, RxApp.DefaultExceptionHandler.OnError); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
Totoro.Core/Services/GogoAnime/GogoAnimeEpisodesProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System.Text.RegularExpressions; | ||
using AngleSharp.Dom; | ||
using AnimDL.Api; | ||
using AnimDL.Core; | ||
using HtmlAgilityPack; | ||
using HtmlAgilityPack.CssSelectors.NetCore; | ||
|
||
namespace Totoro.Core.Services.GogoAnime; | ||
|
||
public partial class GogoAnimeEpisodesProvider : IRecentEpisodesProvider | ||
{ | ||
public const string AJAX_URL = "https://ajax.gogo-load.com/ajax/page-recent-release.html?page=1&type=1"; | ||
private readonly HttpClient _httpClient; | ||
private readonly IStreamPageMapper _streamPageMapper; | ||
private readonly string _urlStripped; | ||
private readonly HtmlWeb _web = new(); | ||
|
||
public GogoAnimeEpisodesProvider(HttpClient httpClient, | ||
IStreamPageMapper streamPageMapper) | ||
{ | ||
_httpClient = httpClient; | ||
_streamPageMapper = streamPageMapper; | ||
_urlStripped = DefaultUrl.GogoAnime.EndsWith("/") || DefaultUrl.GogoAnime.EndsWith("\\") ? DefaultUrl.GogoAnime[..^1] : DefaultUrl.GogoAnime; | ||
} | ||
|
||
public IObservable<long> GetMalId(AiredEpisode ep) | ||
{ | ||
var uri = new Uri(ep.EpisodeUrl); | ||
var match = IdentifierRegex().Match(uri.AbsolutePath); | ||
|
||
if (!match.Success) | ||
{ | ||
return Observable.Return((long)0); | ||
} | ||
|
||
return _streamPageMapper.GetMalId(match.Groups[1].Value, ProviderType.GogoAnime).ToObservable(); | ||
} | ||
|
||
public IObservable<IEnumerable<AiredEpisode>> GetRecentlyAiredEpisodes() | ||
{ | ||
return Observable.Create<IEnumerable<AiredEpisode>>(async observer => | ||
{ | ||
var doc = await _web.LoadFromWebAsync(AJAX_URL); | ||
|
||
var nodes = doc.QuerySelectorAll(".items li"); | ||
var list = new List<AiredEpisode>(); | ||
|
||
foreach (var item in nodes) | ||
{ | ||
var title = item.SelectSingleNode("div/a").Attributes["title"].Value; | ||
var url = _urlStripped + item.SelectSingleNode("div/a").Attributes["href"].Value; | ||
var img = item.SelectSingleNode("div/a/img").Attributes["src"].Value; | ||
var ep = item.QuerySelector(".episode").InnerText.Trim(); | ||
list.Add(new AiredEpisode | ||
{ | ||
Anime = title, | ||
EpisodeUrl = url, | ||
Image = img, | ||
InfoText = ep | ||
}); | ||
} | ||
|
||
observer.OnNext(list); | ||
observer.OnCompleted(); | ||
}); | ||
} | ||
|
||
[GeneratedRegex("/?(.+)-episode-\\d+")] | ||
private static partial Regex IdentifierRegex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.