Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
Adds logs if episode has no streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcos Cordeiro committed Sep 24, 2022
1 parent 983ba98 commit d197317
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Wasari.Crunchyroll/CrunchyrollDownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ public override async Task<DownloadedEpisode[]> DownloadEpisodes(string url, int
return await base.DownloadEpisodes(url, levelOfParallelism);
}

private static async IAsyncEnumerable<IWasariEpisodeInput> ProcessEpisode(ApiEpisode i, CrunchyrollApiService crunchyrollApiService)
private async IAsyncEnumerable<IWasariEpisodeInput> ProcessEpisode(ApiEpisode episode, CrunchyrollApiService crunchyrollApiService)
{
await i.LoadStreams(crunchyrollApiService);
var stream = i.ApiEpisodeStreams.Streams.Single(o => o.Type == "adaptive_hls" && string.IsNullOrEmpty(o.Locale));
await episode.LoadStreams(crunchyrollApiService);

if (episode.ApiEpisodeStreams?.Streams == null || episode.ApiEpisodeStreams.Streams.Length > 0)
{
Logger.LogWarning("Episode found with no stream options: {@Episode}", episode);
yield break;
}

var stream = episode.ApiEpisodeStreams.Streams.Single(o => o.Type == "adaptive_hls" && string.IsNullOrEmpty(o.Locale));
var mediaInfo = await FFProbe.AnalyseAsync(new Uri(stream.Url));
var bestVideo = mediaInfo.VideoStreams.OrderBy(vStream => vStream.Height + vStream.Width).Last();

yield return new WasariEpisodeInputWithStream(stream.Url, i.Locale, !i.IsDubbed ? InputType.VideoWithAudio : InputType.Audio, mediaInfo.PrimaryAudioStream?.Index, !i.IsDubbed ? bestVideo.Index : null);
yield return new WasariEpisodeInputWithStream(stream.Url, episode.Locale, !episode.IsDubbed ? InputType.VideoWithAudio : InputType.Audio, mediaInfo.PrimaryAudioStream?.Index, !episode.IsDubbed ? bestVideo.Index : null);
}
}

0 comments on commit d197317

Please sign in to comment.