public async void Tmdb_SearchName_AListWithContent() { var tmdb = new TmdbOnlineDataCollector(); var result = await tmdb.SearchName("Marvel"); Assert.IsNotEmpty(result); }
public async void Tmdb_GetShowInfo_ASearchResult() { var tmdb = new TmdbOnlineDataCollector(); var first = await tmdb.SearchName("Marvel"); var result = await tmdb.GetShowInfo(first.First().TmdbId); Assert.IsNotNull(result.NumberOfSeasons); }
private void UpdateShowTitlesAndImages() { var removeList = new List<Show>(); var lockObj = new object(); var doneNumber = 0; var totalProcentPrShow = (100 / TvSeries.Count); ProgressProcent = 0; EnableProgress = false; var tasks = TvSeries.Select(show => Task.Factory.StartNew(() => { if (show.Title.Length >= 2) { var collector = new TmdbOnlineDataCollector(); var list = collector.SearchName(show.Title).Result; if (list != null && list.Any()) { var obj = list.First(); if (!TvSeries.Exists(listShow => CheckName(listShow.Title, obj.Title) && listShow != show)) { show.Title = obj.Title; show.TmdbId = obj.TmdbId; show.ImageUri = new Uri(obj.Url); AsyncLogger.Log(Tag, String.Format("Updated {0}, Image: {1}, TMDB Id: {2}", obj.Title, obj.Url, obj.TmdbId)); } else { AsyncLogger.Log(Tag, String.Format("Removed {0} : Duplicate on the list", show.Title)); removeList.Add(show); } } else { AsyncLogger.Log(Tag, String.Format("Removed {0} : Not found by the online API", show.Title)); removeList.Add(show); } } else { AsyncLogger.Log(Tag, String.Format("Removed {0} : Title is 1 char long", show.Title)); removeList.Add(show); } lock (lockObj) { doneNumber++; ProgressText = "Loading " + show.Title + " for online data"; ProgressProcent = doneNumber*totalProcentPrShow; } })).ToList(); Task.WaitAll(tasks.ToArray()); foreach (var show in removeList) { TvSeries.Remove(show); } }
public async Task UpdateAElementOnTheList(String id) { if (TvSeries.Exists(show => show.TmdbId == id && ((DateTime.Now.TimeOfDay - show.LastUpdated.TimeOfDay) >= TimeSpan.FromHours(1) || show.LastUpdated.Date != DateTime.Today))) { var collector = new TmdbOnlineDataCollector(); var showInfo = await collector.GetShowInfo(id); var seasonInfo = await collector.GetSeasonInfo(id, showInfo.NumberOfSeasons); foreach (var tvSerie in TvSeries.Where(show => show.TmdbId == id)) { foreach (var searchSeasonResult in seasonInfo) { if (!tvSerie.Seasons.Exists(season => season.Number == searchSeasonResult.Number)) { var season = new Season(searchSeasonResult.Number) {AirDate = searchSeasonResult.AirDate}; foreach (var searchEpisode in searchSeasonResult.Episodes) { season.Episodes.Add(new Episode(searchEpisode.Number) { Title = searchEpisode.Title, AirDate = searchEpisode.AirDate }); } tvSerie.Seasons.Add(season); } else { foreach (var searchSeasonResultEpisode in searchSeasonResult.Episodes) { if (!tvSerie.Seasons.Find(season => season.Number == searchSeasonResult.Number) .Episodes.Exists(episode => episode.Number == searchSeasonResultEpisode.Number)) { var episode = new Episode(searchSeasonResultEpisode.Number) { Title = searchSeasonResultEpisode.Title, AirDate = searchSeasonResult.AirDate }; tvSerie.Seasons.Find(season => season.Number == searchSeasonResult.Number).Episodes.Add(episode); } else { var refEpisode = tvSerie.Seasons.Find( season => season.Number == searchSeasonResult.Number) .Episodes.Find(episode => episode.Number == searchSeasonResultEpisode.Number); refEpisode.Title = searchSeasonResultEpisode.Title; refEpisode.AirDate = searchSeasonResultEpisode.AirDate; } } } } } TvSeries.Find(show => show.TmdbId == id).LastUpdated = DateTime.Now; await Save(); } }