public async Task <TvShowRequestBuilder> GetShowInfo(int id) { ShowInfo = await TvApi.ShowLookupByTheTvDbId(id); Results = await MovieDbApi.SearchTv(ShowInfo.name); foreach (TvSearchResult result in Results) { if (result.Name.Equals(ShowInfo.name, StringComparison.InvariantCultureIgnoreCase)) { TheMovieDbRecord = result; var showIds = await MovieDbApi.GetTvExternals(result.Id); ShowInfo.externals.imdb = showIds.imdb_id; BackdropPath = result.BackdropPath; break; } } DateTime.TryParse(ShowInfo.premiered, out var dt); FirstAir = dt; // For some reason the poster path is always http PosterPath = ShowInfo.image?.medium.ToHttpsUrl(); return(this); }
public async Task <TvShowRequestBuilder> GetShowInfo(int id) { ShowInfo = await TvApi.ShowLookupByTheTvDbId(id); Results = await MovieDbApi.SearchTv(ShowInfo.name); foreach (TvSearchResult result in Results) { if (result.Name == ShowInfo.name) { var showIds = await MovieDbApi.GetTvExternals(result.Id); ShowInfo.externals.imdb = showIds.imdb_id; BackdropPath = result.BackdropPath; break; } } DateTime.TryParse(ShowInfo.premiered, out var dt); FirstAir = dt; // For some reason the poster path is always http PosterPath = ShowInfo.image?.medium.Replace("http:", "https:"); return(this); }
public async Task <TvShowRequestBuilder> GetShowInfo(int id) { ShowInfo = await TvApi.ShowLookupByTheTvDbId(id); DateTime.TryParse(ShowInfo.premiered, out DateTime dt); FirstAir = dt; // For some reason the poster path is always http PosterPath = ShowInfo.image?.medium.Replace("http:", "https:"); return(this); }
private void GenerateTvHtml(IEnumerable <PlexRecentlyAddedModel> recenetlyAddedTv, StringBuilder sb) { var tv = recenetlyAddedTv?.ToList() ?? new List <PlexRecentlyAddedModel>(); if (!tv.Any()) { return; } var orderedTv = tv.OrderByDescending(x => x.Content.AddedAt).ToList(); // TV sb.Append("<h1>New Episodes:</h1><br /><br />"); sb.Append( "<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">"); foreach (var t in orderedTv) { var relatedEpisodes = t.EpisodeMetadata ?? new List <PlexEpisodeMetadata>(); try { var info = TvApi.ShowLookupByTheTvDbId(int.Parse(PlexHelper.GetProviderIdFromPlexGuid(t.Metadata.Directory.Guid))); var banner = info.image?.original; if (!string.IsNullOrEmpty(banner)) { banner = banner.Replace("http", "https"); // Always use the Https banners } AddImageInsideTable(sb, banner); sb.Append("<tr>"); sb.Append( "<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">"); var title = $"{t.Content.Title} {t.Content.ReleaseYear}"; Href(sb, $"https://www.imdb.com/title/{info.externals.imdb}/"); Header(sb, 3, title); EndTag(sb, "a"); // Group by the ParentIndex (season number) var results = relatedEpisodes.GroupBy(p => p.Video.FirstOrDefault()?.ParentIndex, (key, g) => new { ParentIndexNumber = key, IndexNumber = g.ToList() } ); // Group the episodes foreach (var epInformation in results.OrderBy(x => x.ParentIndexNumber)) { var orderedEpisodes = epInformation.IndexNumber.OrderBy(x => Convert.ToInt32(x.Video.FirstOrDefault().Index)).ToList(); var epSb = new StringBuilder(); for (var i = 0; i < orderedEpisodes.Count; i++) { var ep = orderedEpisodes[i]; if (i <= orderedEpisodes.Count - 1) { epSb.Append($"{ep.Video.FirstOrDefault().Index},"); } else { epSb.Append($"{ep.Video.FirstOrDefault().Index}"); } } AddParagraph(sb, $"Season: {epInformation.ParentIndexNumber}, Episode: {epSb}"); } if (info.genres.Any()) { AddParagraph(sb, $"Genre: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}"); } AddParagraph(sb, string.IsNullOrEmpty(t.Metadata.Directory.Summary) ? t.Metadata.Directory.Summary : info.summary); } catch (Exception e) { Log.Error(e); } finally { EndLoopHtml(sb); } } sb.Append("</table><br /><br />"); }
private void GenerateTvHtml(IEnumerable <EmbyRecentlyAddedModel> recenetlyAddedTv, StringBuilder sb) { var tv = recenetlyAddedTv?.ToList() ?? new List <EmbyRecentlyAddedModel>(); if (!tv.Any()) { return; } var orderedTv = tv.OrderByDescending(x => x.EmbyContent.AddedAt).ToList(); // TV sb.Append("<h1>New Episodes:</h1><br /><br />"); sb.Append( "<table border=\"0\" cellpadding=\"0\" align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">"); foreach (var t in orderedTv) { var seriesItem = t.EmbyInformation.SeriesInformation; var relatedEpisodes = t.EpisodeInformation; try { var info = TvApi.ShowLookupByTheTvDbId(int.Parse(seriesItem.ProviderIds.Tvdb)); var banner = info.image?.original; if (!string.IsNullOrEmpty(banner)) { banner = banner.Replace("http", "https"); // Always use the Https banners } AddImageInsideTable(sb, banner); sb.Append("<tr>"); sb.Append( "<td align=\"center\" style=\"font-family: sans-serif; font-size: 14px; vertical-align: top;\" valign=\"top\">"); var title = $"{seriesItem.Name} {seriesItem.PremiereDate.Year}"; Href(sb, $"https://www.imdb.com/title/{info.externals.imdb}/"); Header(sb, 3, title); EndTag(sb, "a"); var results = relatedEpisodes.GroupBy(p => p.ParentIndexNumber, (key, g) => new { ParentIndexNumber = key, IndexNumber = g.ToList() } ); // Group the episodes foreach (var embyEpisodeInformation in results.OrderBy(x => x.ParentIndexNumber)) { var epSb = new StringBuilder(); for (var i = 0; i < embyEpisodeInformation.IndexNumber.Count; i++) { var ep = embyEpisodeInformation.IndexNumber[i]; if (i < embyEpisodeInformation.IndexNumber.Count) { epSb.Append($"{ep.IndexNumber},"); } else { epSb.Append(ep); } } AddParagraph(sb, $"Season: {embyEpisodeInformation.ParentIndexNumber}, Episode: {epSb}"); } if (info.genres.Any()) { AddParagraph(sb, $"Genre: {string.Join(", ", info.genres.Select(x => x.ToString()).ToArray())}"); } AddParagraph(sb, string.IsNullOrEmpty(seriesItem.Overview) ? info.summary : seriesItem.Overview); } catch (Exception e) { Log.Error(e); } finally { EndLoopHtml(sb); } } sb.Append("</table><br /><br />"); }