/// <summary> /// Gets one movie or tv item by doubanID. /// </summary> /// <param name="doubanID">The subject ID in Douban.</param> /// <param name="type">Subject type.</param> /// <param name="cancellationToken">Used to cancel the request.</param> /// <returns>The subject of one item.</returns> public async Task <Response.Subject> GetSubject(string doubanID, MediaType type, CancellationToken cancellationToken) { _logger.LogInformation($"Start to GetSubject by Id: {doubanID}"); string path = $"/api/v2/{type:G}/{doubanID}"; Dictionary <string, string> queryParams = new Dictionary <string, string>(); var contentStream = await GetResponse(path, queryParams, cancellationToken); Response.Subject subject = await _jsonSerializer.DeserializeFromStreamAsync <Response.Subject>(contentStream); _logger.LogTrace($"Finish doing GetSubject by Id: {doubanID}"); return(subject); }
internal async Task <Response.Subject> GetFrodoSubject(string sid, string type, CancellationToken cancellationToken) { _logger.LogInformation($"[DOUBAN FRODO INFO] Getting the douban subject with sid \"{sid}\""); SubjectCache subjectCache = SubjectCache.Instance; if (subjectCache.Has(sid)) { _logger.LogInformation($"[DOUBAN FRODO INFO] Found cache."); return(subjectCache.subject); } String response = await _doubanAccessor.RequestFrodo($"{FrodoUtils.ItemApi}/{type}/{sid}", new Dictionary <string, string>(), cancellationToken); Response.Subject subject = _jsonSerializer.DeserializeFromString <Response.Subject>(response); subjectCache.subject = subject; return(subject); }
private Movie TransMovieInfo(Response.Subject data) { var movie = new Movie { Name = data.Title, OriginalTitle = data.Original_Title, CommunityRating = data.Rating.Average, Overview = data.Summary, ProductionYear = int.Parse(data.Year), HomePageUrl = data.Alt, ProductionLocations = data.Countries.ToArray() }; if (!String.IsNullOrEmpty(data.Pubdate)) { movie.PremiereDate = DateTime.Parse(data.Pubdate); } data.Trailer_Urls.ForEach(item => movie.AddTrailerUrl(item)); data.Genres.ForEach(movie.AddGenre); return(movie); }
private T TransMediaInfo <T>(Response.Subject data) where T : BaseItem, new() { var media = new T { Name = data.Title, OriginalTitle = data.Original_Title, CommunityRating = data.Rating.Average, Overview = data.Summary.Replace("\n", "</br>"), ProductionYear = int.Parse(data.Year), HomePageUrl = data.Alt, ProductionLocations = data.Countries.ToArray() }; if (!String.IsNullOrEmpty(data.Pubdate)) { media.PremiereDate = DateTime.Parse(data.Pubdate); } data.Trailer_Urls.ForEach(item => media.AddTrailerUrl(item)); data.Genres.ForEach(media.AddGenre); return(media); }