public static Task<TvShowUpdate> GetUpdate(int id, DateTime? lastUpdate = null, Language language = Language.English) { return Task.Run(() => { var client = new TMDbClient(ApiKey); var episodes = new List<TvShowEpisodeInfo>(); var updateDate = DateTime.Now; var show = client.GetTvShow(id, language: GetLanguage(language)); if (show == null) return null; foreach (var seasonTmp in show.Seasons) { if (seasonTmp.SeasonNumber == 0) continue; var season = client.GetTvSeason(show.Id, seasonTmp.SeasonNumber); if (season == null) continue; foreach (var episode in season.Episodes) { var ad = episode.AirDate; DateTime? airDate; if (ad.Year < 1896) airDate = null; else airDate = new DateTime(ad.Year, ad.Month, ad.Day, 20, 0, 0, DateTimeKind.Utc); episodes.Add(new TvShowEpisodeInfo(season.SeasonNumber, episode.EpisodeNumber, episode.Name, airDate, episode.Overview)); } } return new TvShowUpdate(updateDate, show.InProduction, show.Status, episodes); }); }
public static List<MovieDB_Movie_Result> SearchWithTVShowID(int id, bool isTrakt) { List<MovieDB_Movie_Result> results = new List<MovieDB_Movie_Result>(); try { TMDbClient client = new TMDbClient(apiKey); TvShow result = client.GetTvShow(id, TvShowMethods.Images, null); if (result != null) { logger.Info("Got TMDB results for id: {0} | show name: {1}", id, result.Name); MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result(); Movie movie = client.GetMovie(result.Id); ImagesWithId imgs = client.GetMovieImages(result.Id); searchResult.Populate(movie, imgs); results.Add(searchResult); SaveMovieToDatabase(searchResult, true, isTrakt); } } catch (Exception ex) { logger.Error("Error in MovieDB Search: " + ex.Message); } return results; }
static public bool DownloadSeriesDetails(VideoTags videoTags, bool prioritizeMatchDate = false) { // The new v3 database is accessed via the TMDbLib API's try { TMDbClient client = new TMDbClient(MCEBUDDY_TMDB_APIKey); List<TvShowBase> showSearch = new List<TvShowBase>(); // TODO: Add support for multiple language searches if (String.IsNullOrWhiteSpace(videoTags.tmdbId)) // If dont' have a specific movieId specified, look up the show details { if (videoTags.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) // Release date narrow down { // The information is stored on the server using the network timezone // So we assume that the show being converted was recorded locally and is converted locally so the timezones match DateTime dt = videoTags.OriginalBroadcastDateTime.ToLocalTime(); showSearch = client.SearchTvShow(videoTags.Title.Trim().ToLower(), 0).Results; } else // Title Check showSearch = client.SearchTvShow(videoTags.Title.Trim().ToLower(), 0).Results; } else // Specific ID { TvShow showMatch = client.GetTvShow(int.Parse(videoTags.tmdbId)); // We have a specific show to work with // First match by Episode name and then by Original broadcast date (by default prioritize match date is false) if (!MatchSeriesInformation(client, videoTags, showMatch, prioritizeMatchDate)) return MatchSeriesInformation(client, videoTags, showMatch, !prioritizeMatchDate); else return true; } foreach (TvShowBase showResult in showSearch) // Cycle through all possible combinations { TvShow show = client.GetTvShow(showResult.Id); string title = videoTags.Title; // Get and match Show name (check both titles and aka values) if (String.Compare(show.Name.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters if (String.Compare(show.OriginalName.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters continue; // No match in name // If we got here, then we found a match // First match by Episode name and then by Original broadcast date (by default prioritize match date is false) if (!MatchSeriesInformation(client, videoTags, show, prioritizeMatchDate)) { if (MatchSeriesInformation(client, videoTags, show, !prioritizeMatchDate)) return true; // Else we continue looping through the returned series looking for a match if nothing matches } else return true; } return false; } catch { return false; } }