Skip to content

Commit

Permalink
fix some crash with anilist,
Browse files Browse the repository at this point in the history
add marin
  • Loading branch information
insomniachi committed Jan 16, 2023
1 parent e4607ac commit 2486e10
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion Totoro.Core/Services/StreamPageMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ private long GetId(AnimeId animeId)
_ => throw new NotSupportedException()
};

var json = await _httpClient.GetStringAsync($"https://raw.githubusercontent.com/MALSync/MAL-Sync-Backup/master/data/{listService}/anime/{id}.json");
var url = $"https://raw.githubusercontent.com/MALSync/MAL-Sync-Backup/master/data/{listService}/anime/{id}.json";
var result = await _httpClient.GetAsync(url);

if(!result.IsSuccessStatusCode)
{
return null;
}

var json = await result.Content.ReadAsStringAsync();
var jObject = JsonNode.Parse(json);
var key = GetKey(provider);
var pages = jObject["Pages"];
Expand Down
2 changes: 1 addition & 1 deletion Totoro.Core/Totoro.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="5.1.0" />
<PackageReference Include="Humanizer.Core.uk" Version="2.14.1" />
<PackageReference Include="MalApi.V2" Version="2.0.8" />
<PackageReference Include="AnimDL.Core" Version="0.5.6.1" />
<PackageReference Include="AnimDL.Core" Version="0.5.7.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="MonoTorrent" Version="2.0.7" />
Expand Down
2 changes: 1 addition & 1 deletion Totoro.Core/ViewModels/DiscoverViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DiscoverViewModel(IProviderFactory providerFacotory,
.Subscribe()
.DisposeWith(Garbage);

CardWidth = settings.DefaultProviderType == ProviderType.AnimePahe ? 480 : 190; // animepahe image is thumbnail
CardWidth = settings.DefaultProviderType is ProviderType.AnimePahe or ProviderType.Marin ? 480 : 190; // animepahe image is thumbnail
DontUseImageEx = settings.DefaultProviderType == ProviderType.Yugen; // using imagex for yugen is crashing

SelectEpisode = ReactiveCommand.CreateFromTask<AiredEpisode>(OnEpisodeSelected);
Expand Down
2 changes: 1 addition & 1 deletion Totoro.Core/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class SettingsViewModel : NavigatableViewModel
public Version Version { get; }
public Version ScrapperVersion { get; }
public List<ElementTheme> Themes { get; } = Enum.GetValues<ElementTheme>().Cast<ElementTheme>().ToList();
public List<ProviderType> ProviderTypes { get; } = new List<ProviderType> { ProviderType.AllAnime, ProviderType.AnimePahe, ProviderType.GogoAnime, ProviderType.Yugen, ProviderType.Tenshi };
public List<ProviderType> ProviderTypes { get; } = new List<ProviderType> { ProviderType.AllAnime, ProviderType.AnimePahe, ProviderType.GogoAnime, ProviderType.Yugen, ProviderType.Marin };
public List<LogLevel> LogLevels { get; } = new List<LogLevel> { LogLevel.Debug, LogLevel.Information, LogLevel.Warning, LogLevel.Error, LogLevel.Critical };
public List<ListServiceType> ServiceTypes { get; } = new List<ListServiceType> { ListServiceType.MyAnimeList, ListServiceType.AniList };
public ICommand AuthenticateCommand { get; }
Expand Down
5 changes: 5 additions & 0 deletions Totoro.Core/ViewModels/WatchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ private void OnSubmitTimeStamps()
{
var results = await Provider.Catalog.Search(title).ToListAsync();

if(results.Count == 0)
{
return (null, null);
}

if (results.Count == 1)
{
return (results[0], null);
Expand Down

0 comments on commit 2486e10

Please sign in to comment.