public async Task GetUpcomingMoviesAsync() { if (!GetMoreResults) { return; } if (IsBusy) { return; } if (Connectivity.NetworkAccess != NetworkAccess.Internet) { await DisplayAlert(AppResources.ErrorNoConnection); return; } IsBusy = true; try { if (!Genres.Any()) { await GetGenresAsync(); } var moviesData = await movieService.GetUpcomingMoviesDataAsync(CurrentPageNumber, CultureInfo.CurrentCulture.Name); if (moviesData != null) { TotalPages = moviesData.TotalPages; for (int i = 0; i < moviesData.Movies.Length; i++) { moviesData.Movies[i].GenreNames = genreService.GetGenreNames(moviesData.Movies[i].GenreIds, Genres); Movies.Add(moviesData.Movies[i]); } } else { TotalPages = 0; } CurrentPageNumber++; GetMoreResults = TotalPages > 0 && CurrentPageNumber < TotalPages; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); await DisplayAlert(AppResources.ErrorSearchingMovies); } finally { IsBusy = false; } }
public bool IsReleaseTypeOf(string type, bool doCheckTitles = false) { if (string.IsNullOrEmpty(type)) { return(false); } try { if (doCheckTitles) { if (Artist != null && !string.IsNullOrEmpty(Artist.Name)) { if (Artist.Name.IndexOf(type, 0, StringComparison.OrdinalIgnoreCase) > -1) { return(true); } } if (!string.IsNullOrEmpty(Title)) { if (Title.IndexOf(type, 0, StringComparison.OrdinalIgnoreCase) > -1) { return(true); } } if (AlternateNames != null) { if (AlternateNames.IsValueInDelimitedList(type)) { return(true); } } } if (Tags != null) { if (Tags.IsValueInDelimitedList(type)) { return(true); } } if (Genres != null) { if (Genres.Any(x => x.Genre.Name.ToLower().Equals(type))) { return(true); } } } catch { } return(false); }
public void SortMovies() { var fdt = new DateTime(int.Parse(From.Text), DateTime.Now.Month, DateTime.Now.Day); var tdt = new DateTime(int.Parse(To.Text), DateTime.Now.Month, DateTime.Now.Day); var sort = ViewModel.Movies.Where(x => x.Title.ToLowerInvariant().Contains(Search.Text.ToLowerInvariant())); if (From.Text.Length == 4 || To.Text.Length == 4) { sort = sort.Where(x => x.ReleaseDate != null && (new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year > fdt.Year && new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year < tdt.Year)); } var acv = new AdvancedCollectionView(new ObservableCollection <Movie>(sort)); var content = ((ComboBoxItem)Sort.SelectedItem)?.Content; if (content != null && content.ToString().Contains("Ascending")) { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Ascending)); } else if (content != null && content.ToString().Contains("Descending")) { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Descending)); } else { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Ascending)); } var abx = new List <Movie>(acv.ToList().OfType <Movie>()); if (!Genres.Any()) { AdaptiveGridViewMovies.ItemsSource = abx; return; } foreach (var i in abx.ToList()) { if (!i.Genres.Any(x => Genres.Any(y => y == x.Name))) { abx.Remove(i); } } AdaptiveGridViewMovies.ItemsSource = abx; }
public void SortMovies() { var sort = ViewModel.Movies.Where(x => x.Title.ToLowerInvariant().Contains(Search.Text.ToLowerInvariant())); if (From.Text.Length == 4 || To.Text.Length == 4) { var fdt = new DateTime(int.Parse(From.Text), DateTime.Now.Month, DateTime.Now.Day); var tdt = new DateTime(int.Parse(To.Text), DateTime.Now.Month, DateTime.Now.Day); sort = sort.Where(x => x.ReleaseDate != null && (new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year > fdt.Year && new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year < tdt.Year)); } var content = ((ComboBoxItem)Sort.SelectedItem)?.Content; if (content != null && content.ToString().Contains("Ascending")) { sort = sort.OrderBy(i => i.Title); } else if (content != null && content.ToString().Contains("Descending")) { sort = sort.OrderByDescending(i => i.Title); } else { sort = sort.OrderBy(i => i.Title); } var abx = new List <Movie>(sort.ToList()); if (!Genres.Any()) { ItemsControlMovies.ItemsSource = abx; return; } foreach (var i in abx.ToList()) { if (!i.Genres.Any(x => Genres.Any(y => y == x.Name))) { abx.Remove(i); } } ItemsControlMovies.ItemsSource = abx; }
public string DbgString() { StringBuilder s = new StringBuilder(); s.AppendFormat("Title: {0}\n", Title); if ((AltTitles != null) && AltTitles.Any()) { for (int x = 0; x < AltTitles.Count; x++) { s.AppendFormat("AltTitle{0}:\n{1}\n", x + 1, AltTitles.ElementAt(x)); } } if ((Accessories != null) && Accessories.Any()) { for (int x = 0; x < Accessories.Count; x++) { s.AppendFormat("Accessory{0}:\n{1}\n", x + 1, Accessories.ElementAt(x).AccessoryName); } } if ((DLCs != null) && DLCs.Any()) { for (int x = 0; x < DLCs.Count; x++) { s.AppendFormat("DLC{0}: {1}\n", x + 1, DLCs.ElementAt(x)); } } if ((Genres != null) && Genres.Any()) { for (int x = 0; x < Genres.Count; x++) { s.AppendFormat("Genre{0}: {1}\n", x + 1, Genres.ElementAt(x)); } } s.AppendFormat("Release Decade: {0}\n", ReleaseDecade); s.AppendFormat("Release Year: {0}\n", ReleaseYear); s.AppendFormat("Release Date: {0}\n", ReleaseDate); return(s.ToString()); }
public Dictionary <string, Tuple <string, string> > Diff(AudioTag other) { var output = new Dictionary <string, Tuple <string, string> >(); if (!IsValid || !other.IsValid) { return(output); } if (Title != other.Title) { output.Add("Title", Tuple.Create(Title, other.Title)); } if ((Performers != null && Performers.Any()) ^ (other.Performers != null && other.Performers.Any()) || ( other.Performers != null && other.Performers.Any() && Performers != null && Performers.Any() && !Performers.SequenceEqual(other.Performers))) { var oldValue = Performers != null && Performers.Any() ? string.Join(" / ", Performers) : null; var newValue = other.Performers != null && other.Performers.Any() ? string.Join(" / ", other.Performers) : null; output.Add("Artist", Tuple.Create(oldValue, newValue)); } if (Album != other.Album && other.Album != null) { output.Add("Album", Tuple.Create(Album, other.Album)); } if ((AlbumArtists != null && AlbumArtists.Any()) ^ (other.AlbumArtists != null && other.AlbumArtists.Any()) || ( other.AlbumArtists != null && other.AlbumArtists.Any() && AlbumArtists != null && AlbumArtists.Any() && !AlbumArtists.SequenceEqual(other.AlbumArtists))) { var oldValue = AlbumArtists != null && AlbumArtists.Any() ? string.Join(" / ", AlbumArtists) : null; var newValue = other.AlbumArtists != null && other.AlbumArtists.Any() ? string.Join(" / ", other.AlbumArtists) : null; output.Add("Album Artist", Tuple.Create(oldValue, newValue)); } if (Track != other.Track) { output.Add("Track", Tuple.Create(Track.ToString(), other.Track.ToString())); } if (TrackCount != other.TrackCount) { output.Add("Track Count", Tuple.Create(TrackCount.ToString(), other.TrackCount.ToString())); } if (Disc != other.Disc) { output.Add("Disc", Tuple.Create(Disc.ToString(), other.Disc.ToString())); } if (DiscCount != other.DiscCount) { output.Add("Disc Count", Tuple.Create(DiscCount.ToString(), other.DiscCount.ToString())); } if (Media != other.Media) { output.Add("Media Format", Tuple.Create(Media, other.Media)); } if (Date != other.Date) { var oldValue = Date.HasValue ? Date.Value.ToString("yyyy-MM-dd") : null; var newValue = other.Date.HasValue ? other.Date.Value.ToString("yyyy-MM-dd") : null; output.Add("Date", Tuple.Create(oldValue, newValue)); } if (OriginalReleaseDate != other.OriginalReleaseDate) { // Id3v2.3 tags can only store the year, not the full date if (OriginalReleaseDate.HasValue && OriginalReleaseDate.Value.Month == 1 && OriginalReleaseDate.Value.Day == 1) { if (OriginalReleaseDate.Value.Year != other.OriginalReleaseDate.Value.Year) { output.Add("Original Year", Tuple.Create(OriginalReleaseDate.Value.Year.ToString(), other.OriginalReleaseDate.Value.Year.ToString())); } } else { var oldValue = OriginalReleaseDate.HasValue ? OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null; var newValue = other.OriginalReleaseDate.HasValue ? other.OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null; output.Add("Original Release Date", Tuple.Create(oldValue, newValue)); } } if (Publisher != other.Publisher) { output.Add("Label", Tuple.Create(Publisher, other.Publisher)); } if ((Genres != null && Genres.Any()) ^ (other.Genres != null && other.Genres.Any()) || ( other.Genres != null && other.Genres.Any() && Genres != null && Genres.Any() && !Genres.SequenceEqual(other.Genres))) { var oldValue = Genres != null && Genres.Any() ? string.Join(" / ", Genres) : null; var newValue = other.Genres != null && other.Genres.Any() ? string.Join(" / ", other.Genres) : null; output.Add("Genres", Tuple.Create(oldValue, newValue)); } if (ImageSize != other.ImageSize) { output.Add("Image Size", Tuple.Create(ImageSize.ToString(), other.ImageSize.ToString())); } return(output); }
// ReSharper disable once FunctionComplexityOverflow public void Merge([NotNull] CachedMovieInfo o) { if (o.IsSearchResultOnly && !IsSearchResultOnly) { return; } if (o.TvdbCode != TvdbCode && o.TvMazeCode != TvMazeCode) { return; // that's not us! } if (o.TvMazeCode != -1 && TvMazeCode != o.TvMazeCode) { TvMazeCode = o.TvMazeCode; } if (o.TvdbCode != -1 && TvdbCode != o.TvdbCode) { TvdbCode = o.TvdbCode; } if (o.TmdbCode != -1 && TmdbCode != o.TmdbCode) { TmdbCode = o.TmdbCode; } if (o.SrvLastUpdated != 0 && o.SrvLastUpdated < SrvLastUpdated) { return; // older!? } if (!o.IsSearchResultOnly) { IsSearchResultOnly = false; } bool currentLanguageNotSet = LanguageId == -1; string bestLanguageCode = TargetLanguageCode ?? TVSettings.Instance.PreferredLanguageCode; Language optimaLanguage = LocalCache.Instance.GetLanguageFromCode(bestLanguageCode); bool newLanguageOptimal = !(optimaLanguage is null) && o.LanguageId == optimaLanguage.Id; bool useNewDataOverOld = currentLanguageNotSet || newLanguageOptimal; SrvLastUpdated = o.SrvLastUpdated; // take the best bits of "o" // "o" is always newer/better than us, if there is a choice Name = ChooseBetter(Name, useNewDataOverOld, o.Name); Imdb = ChooseBetter(Imdb, useNewDataOverOld, o.Imdb); WebUrl = ChooseBetter(WebUrl, useNewDataOverOld, o.WebUrl); OfficialUrl = ChooseBetter(OfficialUrl, useNewDataOverOld, o.OfficialUrl); ShowLanguage = ChooseBetter(ShowLanguage, useNewDataOverOld, o.ShowLanguage); Type = ChooseBetter(Type, useNewDataOverOld, o.Type); Overview = ChooseBetter(Overview, useNewDataOverOld, o.Overview); PosterUrl = ChooseBetter(PosterUrl, useNewDataOverOld, o.PosterUrl); FanartUrl = ChooseBetter(FanartUrl, useNewDataOverOld, o.FanartUrl); TrailerUrl = ChooseBetter(TrailerUrl, useNewDataOverOld, o.TrailerUrl); Network = ChooseBetter(Network, useNewDataOverOld, o.Network); Runtime = ChooseBetter(Runtime, useNewDataOverOld, o.Runtime); SeriesId = ChooseBetter(SeriesId, useNewDataOverOld, o.SeriesId); Status = ChooseBetterStatus(Status, useNewDataOverOld, o.Status); ContentRating = ChooseBetter(ContentRating, useNewDataOverOld, o.ContentRating); Slug = ChooseBetter(Slug, useNewDataOverOld, o.Slug); CollectionName = ChooseBetter(CollectionName, useNewDataOverOld, o.CollectionName); TwitterId = ChooseBetter(TwitterId, useNewDataOverOld, o.TwitterId); InstagramId = ChooseBetter(InstagramId, useNewDataOverOld, o.InstagramId); FacebookId = ChooseBetter(FacebookId, useNewDataOverOld, o.FacebookId); TagLine = ChooseBetter(TagLine, useNewDataOverOld, o.TagLine); if (useNewDataOverOld && o.CollectionId.HasValue) { CollectionId = o.CollectionId; } if (o.FirstAired.HasValue && (useNewDataOverOld || !FirstAired.HasValue)) { FirstAired = o.FirstAired; } if (useNewDataOverOld && o.SiteRating > 0) { SiteRating = o.SiteRating; } if (useNewDataOverOld && o.SiteRatingVotes > 0) { SiteRatingVotes = o.SiteRatingVotes; } bool useNewAliases = o.Aliases.Any() && useNewDataOverOld; if (!Aliases.Any() || useNewAliases) { Aliases = o.Aliases; } bool useNewGenres = o.Genres.Any() && useNewDataOverOld; if (!Genres.Any() || useNewGenres) { Genres = o.Genres; } if (useNewDataOverOld) { LanguageId = o.LanguageId; } Dirty = o.Dirty; IsSearchResultOnly = o.IsSearchResultOnly; }
private bool CanAddGenre() { return(!String.IsNullOrWhiteSpace(NewGenreName) && SelectedItem.IsValid() && !Genres.Any(genre => genre.Name == NewGenreName)); }
// ReSharper disable once FunctionComplexityOverflow public void Merge([NotNull] CachedSeriesInfo o) { if (o.TvdbCode != TvdbCode && o.TvMazeCode != TvMazeCode) { return; // that's not us! } if (o.TvMazeCode != -1 && TvMazeCode != o.TvMazeCode) { TvMazeCode = o.TvMazeCode; } if (o.TmdbCode != -1 && TmdbCode != o.TmdbCode) { TmdbCode = o.TmdbCode; } if (o.TvdbCode != -1 && TvdbCode != o.TvdbCode) { TvdbCode = o.TvdbCode; } if (o.SrvLastUpdated != 0 && o.SrvLastUpdated < SrvLastUpdated) { return; // older!? } if (!o.IsSearchResultOnly) { IsSearchResultOnly = false; } bool currentLanguageNotSet = LanguageId == -1; string bestLanguageCode = TargetLanguageCode ?? TVSettings.Instance.PreferredLanguageCode; Language optimaLanguage = LocalCache.Instance.GetLanguageFromCode(bestLanguageCode); bool newLanguageOptimal = !(optimaLanguage is null) && o.LanguageId == optimaLanguage.Id; bool useNewDataOverOld = currentLanguageNotSet || newLanguageOptimal; SrvLastUpdated = o.SrvLastUpdated; // take the best bits of "o" // "o" is always newer/better than us, if there is a choice Name = ChooseBetter(Name, useNewDataOverOld, o.Name); AirsDay = ChooseBetter(AirsDay, useNewDataOverOld, o.AirsDay); Imdb = ChooseBetter(Imdb, useNewDataOverOld, o.Imdb); WebUrl = ChooseBetter(WebUrl, useNewDataOverOld, o.WebUrl); OfficialUrl = ChooseBetter(OfficialUrl, useNewDataOverOld, o.OfficialUrl); ShowLanguage = ChooseBetter(ShowLanguage, useNewDataOverOld, o.ShowLanguage); Type = ChooseBetter(Type, useNewDataOverOld, o.Type); Overview = ChooseBetter(Overview, useNewDataOverOld, o.Overview); BannerString = ChooseBetter(BannerString, useNewDataOverOld, o.BannerString); PosterUrl = ChooseBetter(PosterUrl, useNewDataOverOld, o.PosterUrl); Network = ChooseBetter(Network, useNewDataOverOld, o.Network); Runtime = ChooseBetter(Runtime, useNewDataOverOld, o.Runtime); SeriesId = ChooseBetter(SeriesId, useNewDataOverOld, o.SeriesId); Status = ChooseBetterStatus(Status, useNewDataOverOld, o.Status); ContentRating = ChooseBetter(ContentRating, useNewDataOverOld, o.ContentRating); Slug = ChooseBetter(Slug, useNewDataOverOld, o.Slug); if (o.FirstAired.HasValue && (useNewDataOverOld || !FirstAired.HasValue)) { FirstAired = o.FirstAired; } if (useNewDataOverOld && o.SiteRating > 0) { SiteRating = o.SiteRating; } if (useNewDataOverOld && o.Popularity > 0) { Popularity = o.Popularity; } if (useNewDataOverOld && o.SiteRatingVotes > 0) { SiteRatingVotes = o.SiteRatingVotes; } bool useNewAliases = o.Aliases.Any() && useNewDataOverOld; if (!Aliases.Any() || useNewAliases) { Aliases = o.Aliases; } bool useNewGenres = o.Genres.Any() && useNewDataOverOld; if (!Genres.Any() || useNewGenres) { Genres = o.Genres; } bool useNewSeasons = o.seasons.Any() && useNewDataOverOld; if (!seasons.Any() || useNewSeasons) { seasons = o.seasons; } if (o.AirsTime != null) { AirsTime = o.AirsTime; } if (o.sourceEpisodes.Count != 0) { sourceEpisodes = o.sourceEpisodes; } banners.MergeBanners(o.banners); BannersLoaded = o.BannersLoaded; if (useNewDataOverOld) { LanguageId = o.LanguageId; } Dirty = o.Dirty; }