public void Test_TraktShowIds_HasAnyId() { var showIds = new TraktShowIds { Trakt = 1 }; showIds.HasAnyId.Should().BeTrue(); showIds = new TraktShowIds { Slug = "slug" }; showIds.HasAnyId.Should().BeTrue(); showIds = new TraktShowIds { Tvdb = 1 }; showIds.HasAnyId.Should().BeTrue(); showIds = new TraktShowIds { Imdb = "imdb" }; showIds.HasAnyId.Should().BeTrue(); showIds = new TraktShowIds { Tmdb = 1 }; showIds.HasAnyId.Should().BeTrue(); showIds = new TraktShowIds { TvRage = 1 }; showIds.HasAnyId.Should().BeTrue(); }
public void Test_TraktShowIds_Default_Constructor() { var showIds = new TraktShowIds(); showIds.Trakt.Should().Be(0); showIds.Slug.Should().BeNullOrEmpty(); showIds.Tvdb.Should().BeNull(); showIds.Imdb.Should().BeNullOrEmpty(); showIds.Tmdb.Should().BeNull(); showIds.TvRage.Should().BeNull(); showIds.HasAnyId.Should().BeFalse(); }
static void WriteShowMinimal(TraktShow show) { if (show != null) { Console.WriteLine($"Title: {show.Title}"); Console.WriteLine($"Year: {show.Year ?? 0}"); TraktShowIds ids = show.Ids; if (ids != null) { Console.WriteLine($"Trakt-Id: {ids.Trakt}"); Console.WriteLine($"Slug: {ids.Slug}"); Console.WriteLine($"ImDB-Id: {ids.Imdb}"); Console.WriteLine($"TmDB-Id: {ids.Tmdb ?? 0}"); Console.WriteLine($"TVDB-Id: {ids.Tvdb ?? 0}"); Console.WriteLine($"TVRage-Id: {ids.TvRage ?? 0}"); } } }
public override async Task <ITraktShowIds> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default) { CheckJsonTextReader(jsonReader); if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject) { ITraktShowIds traktShowIds = new TraktShowIds(); while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName) { var propertyName = jsonReader.Value.ToString(); switch (propertyName) { case JsonProperties.PROPERTY_NAME_TRAKT: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowIds.Trakt = value.Second; } break; } case JsonProperties.PROPERTY_NAME_SLUG: traktShowIds.Slug = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TVDB: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowIds.Tvdb = value.Second; } break; } case JsonProperties.PROPERTY_NAME_IMDB: traktShowIds.Imdb = await jsonReader.ReadAsStringAsync(cancellationToken); break; case JsonProperties.PROPERTY_NAME_TMDB: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowIds.Tmdb = value.Second; } break; } case JsonProperties.PROPERTY_NAME_TVRAGE: { var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken); if (value.First) { traktShowIds.TvRage = value.Second; } break; } default: await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken); break; } } return(traktShowIds); } return(await Task.FromResult(default(ITraktShowIds))); }
static void WriteShowFullWithImages(TraktShow show) { if (show != null) { Console.WriteLine($"Title: {show.Title}"); Console.WriteLine($"Year: {show.Year ?? 0}"); TraktShowIds ids = show.Ids; if (ids != null) { Console.WriteLine($"Trakt-Id: {ids.Trakt}"); Console.WriteLine($"Slug: {ids.Slug}"); Console.WriteLine($"ImDB-Id: {ids.Imdb}"); Console.WriteLine($"TmDB-Id: {ids.Tmdb ?? 0}"); Console.WriteLine($"TVDB-Id: {ids.Tvdb ?? 0}"); Console.WriteLine($"TVRage-Id: {ids.TvRage ?? 0}"); } Console.WriteLine($"Overview: {show.Overview}"); if (show.FirstAired.HasValue) { Console.WriteLine($"First Aired (UTC): {show.FirstAired.Value}"); } TraktShowAirs airs = show.Airs; if (airs != null) { Console.WriteLine($"Airs on: {airs.Day}"); Console.WriteLine($"Airs at: {airs.Time}"); Console.WriteLine($"Airs in: {airs.TimeZoneId}"); } Console.WriteLine($"Runtime: {show.Runtime ?? 0} Minutes"); if (show.Genres != null) { Console.WriteLine($"Genres: {string.Join(", ", show.Genres)}"); } Console.WriteLine($"Certification: {show.Certification}"); Console.WriteLine($"Network: {show.Network}"); Console.WriteLine($"Aired Episodes: {show.AiredEpisodes ?? 0}"); if (show.Status != null) { Console.WriteLine($"Status: {show.Status.DisplayName}"); } Console.WriteLine($"Rating: {show.Rating ?? 0.0f}"); Console.WriteLine($"Votes: {show.Votes ?? 0}"); Console.WriteLine($"Country Code: {show.CountryCode}"); Console.WriteLine($"Language Code: {show.LanguageCode}"); if (show.UpdatedAt.HasValue) { Console.WriteLine($"Updated At (UTC): {show.UpdatedAt.Value}"); } if (show.AvailableTranslationLanguageCodes != null) { Console.WriteLine($"Available Translation Languages: {string.Join(", ", show.AvailableTranslationLanguageCodes)}"); } Console.WriteLine($"Trailer: {show.Trailer}"); Console.WriteLine($"Homepage: {show.Homepage}"); TraktShowImages images = show.Images; if (images != null) { TraktImageSet fanart = images.FanArt; if (fanart != null) { Console.WriteLine($"Fanart Full: {fanart.Full}"); Console.WriteLine($"Fanart Medium: {fanart.Medium}"); Console.WriteLine($"Fanart Thumb: {fanart.Thumb}"); } TraktImageSet poster = images.Poster; if (poster != null) { Console.WriteLine($"Poster Full: {poster.Full}"); Console.WriteLine($"Poster Medium: {poster.Medium}"); Console.WriteLine($"Poster Thumb: {poster.Thumb}"); } if (images.Banner != null) { Console.WriteLine($"Banner: {images.Banner.Full}"); } if (images.Logo != null) { Console.WriteLine($"Logo: {images.Logo.Full}"); } if (images.ClearArt != null) { Console.WriteLine($"Clearart: {images.ClearArt.Full}"); } if (images.Thumb != null) { Console.WriteLine($"Thumb: {images.Thumb.Full}"); } } } }
public void Test_TraktShowIds_GetBestId() { var showIds = new TraktShowIds(); var bestId = showIds.GetBestId(); bestId.Should().NotBeNull().And.BeEmpty(); showIds = new TraktShowIds { Trakt = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { Slug = "slug" }; bestId = showIds.GetBestId(); bestId.Should().Be("slug"); showIds = new TraktShowIds { Tvdb = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { Imdb = "imdb" }; bestId = showIds.GetBestId(); bestId.Should().Be("imdb"); showIds = new TraktShowIds { Tmdb = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { Trakt = 1, Slug = "slug", Tvdb = 1, Imdb = "imdb", Tmdb = 1, TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { Slug = "slug", Tvdb = 1, Imdb = "imdb", Tmdb = 1, TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("slug"); showIds = new TraktShowIds { Tvdb = 1, Imdb = "imdb", Tmdb = 1, TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); showIds = new TraktShowIds { Imdb = "imdb", Tmdb = 1, TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("imdb"); showIds = new TraktShowIds { Tmdb = 1, TvRage = 1 }; bestId = showIds.GetBestId(); bestId.Should().Be("1"); }