/// <summary> /// Extracts cast info for a series. /// </summary> /// <param name="seriesDataPath">The series data path.</param> /// <param name="seriesId">The tvmaze id.</param> /// <param name="cancellationToken">The cancellationToken.</param> /// <returns>Task.</returns> private async Task DownloadCast(string seriesDataPath, string seriesId, CancellationToken cancellationToken) { var url = string.Format(UrlSeriesCast, seriesId); using (var resultStream = await _httpClient.Get(new HttpRequestOptions { Url = url, ResourcePool = TvMazeResourcePool, CancellationToken = cancellationToken }).ConfigureAwait(false)) { var mazeCastMembers = _jsonSerializer.DeserializeFromStream <MazeCastMember[]>(resultStream); var persons = new List <PersonInfo>(); foreach (var mazeCastMember in mazeCastMembers) { var person = TvMazeAdapter.Convert(mazeCastMember); persons.Add(person); } var castPath = GetCastPath(seriesDataPath); _jsonSerializer.SerializeToFile(persons.ToArray(), castPath); } }
/// <summary> /// Fetches the season data. /// </summary> /// <param name="id">The identifier.</param> /// <param name="seriesDataPath">The series data path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{Season}.</returns> private MetadataResult <Season> FetchSeasonData(SeasonInfo info, string seriesDataPath, CancellationToken cancellationToken) { var seasonFileName = TvMazeSeriesProvider.Current.GetSeasonPath(seriesDataPath, info.IndexNumber.Value); var mazeSeason = _jsonSerializer.DeserializeFromFile <MazeSeason>(seasonFileName); var season = TvMazeAdapter.Convert(mazeSeason); if (string.IsNullOrEmpty(season.Name)) { season.Name = info.Name; } if (!season.IndexNumber.HasValue) { season.IndexNumber = info.IndexNumber.Value; } var result = new MetadataResult <Season>() { Item = season, HasMetadata = true }; return(result); }
/// <summary> /// Fetches the episode data. /// </summary> /// <param name="id">The identifier.</param> /// <param name="seriesDataPath">The series data path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{Episode}.</returns> private MetadataResult <Episode> FetchEpisodeData(EpisodeInfo id, string seriesDataPath, CancellationToken cancellationToken) { var episodeFileName = TvMazeSeriesProvider.Current.GetEpisodePath(seriesDataPath, id.ParentIndexNumber.Value, id.IndexNumber.Value); var mazeEpisode = _jsonSerializer.DeserializeFromFile <MazeEpisode>(episodeFileName); var episode = TvMazeAdapter.Convert(mazeEpisode); var result = new MetadataResult <Episode>() { Item = episode, HasMetadata = true }; return(result); }
private Series FetchSeriesInfo(string seriesJsonPath, CancellationToken cancellationToken) { var mazeSeries = _jsonSerializer.DeserializeFromFile <MazeSeries>(seriesJsonPath); return(TvMazeAdapter.Convert(mazeSeries)); }