public TVShow OMDbData(TVShow tvShow, bool refresh = false) { OMDbClient omdb = new OMDbClient(true); try { Item omdbResult = omdb.GetItemByID(tvShow.IMDbId).Result; if (omdbResult.imdbID != null) { tvShow.Rated = omdbResult.Rated; tvShow.Awards = omdbResult.Awards; tvShow.Country = omdbResult.Country; tvShow.Language = omdbResult.Language; if (omdbResult.Metascore != "N/A") { tvShow.Metascore = Int32.Parse(omdbResult.Metascore); } if (omdbResult.tomatoFresh != "N/A") { tvShow.TomatoFresh = Int32.Parse(omdbResult.tomatoFresh); } if (omdbResult.tomatoRotten != "N/A") { tvShow.TomatoRotten = Int32.Parse(omdbResult.tomatoRotten); } if (omdbResult.tomatoRating != "N/A") { tvShow.TomatoRating = Decimal.Parse(omdbResult.tomatoRating); } if (omdbResult.tomatoReviews != "N/A") { tvShow.TomatoReviews = Int32.Parse(omdbResult.tomatoReviews); } if (omdbResult.tomatoUserMeter != "N/A") { tvShow.TomatoUserMeter = Int32.Parse(omdbResult.tomatoUserMeter); } if (omdbResult.tomatoUserRating != "N/A") { tvShow.TomatoUserRating = Decimal.Parse(omdbResult.tomatoUserRating); } if (omdbResult.tomatoUserReviews != "N/A") { tvShow.TomatoUserReviews = Int32.Parse(omdbResult.tomatoUserReviews); } if (refresh) { baza.updateTVShow(tvShow); } } } catch { } return(tvShow); }
public async Task <List <BLL.TVShow> > IMDB_shows() { var IMDB = new TMDbClient("2c54085e8a7f520650d65cb78a48555a"); List <BLL.TVShow> rez = new List <BLL.TVShow>(); for (int j = 67376; j < 107376; j += 100) { for (int i = j; i < j + 100; i++) { TMDbLib.Objects.TvShows.TvShow pom = new TMDbLib.Objects.TvShows.TvShow(); try { pom = await IMDB.GetTvShowAsync(i, TMDbLib.Objects.TvShows.TvShowMethods.Credits | TMDbLib.Objects.TvShows.TvShowMethods.Similar | TMDbLib.Objects.TvShows.TvShowMethods.Videos | TMDbLib.Objects.TvShows.TvShowMethods.ContentRatings | TMDbLib.Objects.TvShows.TvShowMethods.ExternalIds); if (pom.ExternalIds != null && pom.ExternalIds.ImdbId != null && pom.ExternalIds.ImdbId.Length > 0) { var newTVShow = new BLL.TVShow { Id = pom.Id, IMDbId = pom.ExternalIds.ImdbId, Name = pom.Name, NumberOfEpisodes = pom.NumberOfEpisodes, Credits = pom.Credits, Genres = pom.Genres, NumberOfSeasons = pom.NumberOfSeasons, Overview = pom.Overview, ContentRatings = pom.ContentRatings, PosterPath = pom.PosterPath, Similar = pom.Similar, Videos = pom.Videos, VoteAverage = pom.VoteAverage }; newTVShow = showRepo.OMDbData(newTVShow); rez.Add(newTVShow); } } catch { if (rez != null && rez.Count > 0) { baza.saveTVShows(rez); rez = new List <BLL.TVShow>(); } } } if (rez != null && rez.Count > 0) { baza.saveTVShows(rez); rez = new List <BLL.TVShow>(); } } return(rez); }
public void updateTVShow(TVShow updatedTVShow) { var db = MongoInstance.GetDatabase; IMongoCollection <TVShow> collection = db.GetCollection <TVShow>("shows"); collection.ReplaceOne(p => p.IMDbId == updatedTVShow.IMDbId, updatedTVShow, new UpdateOptions { IsUpsert = true }); }