Пример #1
0
        public void getPopularTest()
        {
            SearchMovie popular    = new SearchMovie();
            var         getPopular = popular.getMoviesPopular();

            Assert.IsNotNull(getPopular);
        }
Пример #2
0
        public void getNowPlayingTest()
        {
            SearchMovie nowPlaying    = new SearchMovie();
            var         getNowPlaying = nowPlaying.getMoviesNowPlaying();

            Assert.IsNotNull(getNowPlaying);
        }
Пример #3
0
        public void getTopRatedTest()
        {
            SearchMovie topRated    = new SearchMovie();
            var         getTopRated = topRated.getMoviesTopRated();

            Assert.IsNotNull(getTopRated);
        }
Пример #4
0
        public async Task TestDiscoverMoviesLanguageAsync()
        {
            SearchContainer <SearchMovie> query = await TMDbClient.DiscoverMoviesAsync()
                                                  .WhereOriginalLanguageIs("en-US")
                                                  .WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01))
                                                  .Query();

            SearchContainer <SearchMovie> queryDanish = await TMDbClient.DiscoverMoviesAsync()
                                                        .WhereLanguageIs("da-DK")
                                                        .WhereOriginalLanguageIs("en-US")
                                                        .WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01))
                                                        .Query();

            // Should be the same identities, but different titles
            Assert.Equal(query.TotalResults, queryDanish.TotalResults);

            for (int i = 0; i < query.Results.Count; i++)
            {
                SearchMovie a = query.Results[i];
                SearchMovie b = queryDanish.Results[i];

                Assert.Equal(a.Id, b.Id);
                Assert.NotEqual(a.Title, b.Title);
            }
        }
Пример #5
0
        public void getSearchMovieTest(string MovieName)
        {
            SearchMovie search    = new SearchMovie();
            var         getMovies = search.getMoviesByTitle(MovieName);

            Assert.IsNotNull(getMovies);
        }
Пример #6
0
        /// <summary>
        /// Nadchodzące
        /// </summary>
        /// <returns>Nadchodzące</returns>
        public searchMoviesAsync getUpcoming()
        {
            SearchMovie upcoming  = new SearchMovie();
            var         getTvShow = upcoming.getMoviesUpcoming();

            return(getTvShow);
        }
Пример #7
0
        public IActionResult Index(
            string currentFilter,
            string searchParam,
            int?pageNumber)
        {
            if (searchParam != null)
            {
                pageNumber = 1;
            }
            else
            {
                searchParam = currentFilter;
            }

            ViewData["CurrentFilter"] = searchParam;

            // validation
            if (string.IsNullOrEmpty(searchParam) || string.IsNullOrWhiteSpace(searchParam))
            {
                return(View(null));
            }

            var         moviesInstance = new BLManager();
            SearchMovie movies         = moviesInstance.FindMovies(searchParam, pageNumber ?? 1);

            ViewData["TotalResults"] = movies.TotalResults;

            return(View(PaginatedList <SearchDetails> .Create(movies.Search.AsQueryable(), pageNumber ?? 1, pageSize, int.Parse(movies.TotalResults))));
        }
Пример #8
0
        /// <summary>
        /// Top
        /// </summary>
        /// <returns>Zwrocenie top</returns>
        public searchMoviesAsync getTopRated()
        {
            SearchMovie topRated    = new SearchMovie();
            var         getTopRated = topRated.getMoviesTopRated();

            return(getTopRated);
        }
Пример #9
0
        /// <summary>
        /// Popularne
        /// </summary>
        /// <returns>Popularne</returns>
        public searchMoviesAsync getPopular()
        {
            SearchMovie popular    = new SearchMovie();
            var         getPopular = popular.getMoviesPopular();

            return(getPopular);
        }
Пример #10
0
        /// <summary>
        /// Teraz grane
        /// </summary>
        /// <returns>Zwrócenie teraz granych</returns>
        public searchMoviesAsync getNowPlaying()
        {
            SearchMovie nowPlaying    = new SearchMovie();
            var         getNowPlaying = nowPlaying.getMoviesNowPlaying();

            return(getNowPlaying);
        }
Пример #11
0
        /// <summary>
        /// Wyszukiwanie filmu
        /// </summary>
        /// <param name="MovieName">Tytuł filmu</param>
        /// <returns>Zwrócenie danych z zapytania</returns>
        public searchMoviesAsync getSearchMovie(string MovieName)
        {
            SearchMovie search    = new SearchMovie();
            var         getMovies = search.getMoviesByTitle(MovieName);

            return(getMovies);
        }
Пример #12
0
        private static string FormatMovie(SearchMovie movie)
        {
            var formattedMessage = new StringBuilder();

            formattedMessage.AppendFormat("<b>{0}", movie.Title);
            if (movie.ReleaseDate != null)
            {
                formattedMessage.AppendFormat(" ({0})</b>", movie.ReleaseDate.Value.Year);
            }
            else
            {
                formattedMessage.Append("</b>");
            }

            var genres = movie.GenreIds?.Select(TheMovieDb.GetGenre);

            if (genres != null)
            {
                formattedMessage.AppendFormat("\n{0}", string.Join(", ", genres.ToArray()));
            }

            if (movie.VoteCount > 0)
            {
                formattedMessage.Append($"\n★ {movie.VoteAverage}  - {movie.VoteCount} votes");
            }

            formattedMessage.Append(GetImage(movie));
            formattedMessage.AppendFormat("\n\n{0}", movie.Overview);

            return(formattedMessage.ToString());
        }
Пример #13
0
        public void getUpcomingTest()
        {
            SearchMovie upcoming  = new SearchMovie();
            var         getTvShow = upcoming.getMoviesUpcoming();

            Assert.IsNotNull(getTvShow);
        }
Пример #14
0
        /// <inheritdoc />
        public override List <BasicInfo> GetResponse(List <string> entities, bool outputResults)
        {
            if (!TmdbServiceConfiguration.HasValue)
            {
                TmdbServiceConfiguration.SetServiceConfigurationIfNeed(
                    GetServiceConfiguration(outputResults)
                    );
            }

            // Use HashSet to avoid duplicated data which can produce errors in further work.
            var searchResults = new HashSet <BasicInfo>();

            foreach (string movie in entities)
            {
                SearchContainer <SearchMovie> response = _tmdbClient.SearchMovieAsync(movie).Result;
                if (response.Results.IsNullOrEmpty())
                {
                    _logger.Warn($"{movie} wasn't processed.");
                    GlobalMessageHandler.OutputMessage($"{movie} wasn't processed.");
                    continue;
                }

                // Get first search result from response and ignore all the rest.
                SearchMovie searchResult = response.Results.First();
                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage($"Got {searchResult.Title} from {Tag}");
                }

                TmdbMovieInfo extractedInfo = _dataMapper.Transform(searchResult);
                searchResults.Add(extractedInfo);
            }
            return(searchResults.ToList());
        }
Пример #15
0
 public PopularItem(SearchMovie m)
 {
     Id              = m.Id;
     MediaType       = m.MediaType;
     Poster          = Utils.ModelUtils.GetSmallImageUri(m.PosterPath);
     PopularItemName = m.Title;
 }
Пример #16
0
        public void TestSearchMovie()
        {
            TestHelpers.SearchPages(i => _config.Client.SearchMovie("007", i).Result);

            // Search pr. Year
            // 1962: First James Bond movie, "Dr. No"
            SearchContainer <SearchMovie> result = _config.Client.SearchMovie("007", year: 1962).Result;

            Assert.IsTrue(result.Results.Any());
            SearchMovie item = result.Results.SingleOrDefault(s => s.Id == 646);

            Assert.IsNotNull(item);
            Assert.AreEqual(646, item.Id);
            Assert.AreEqual(false, item.Adult);
            Assert.AreEqual("/bplDiT5JhaXf9S5arO8g5QsFtDi.jpg", item.BackdropPath);
            Assert.AreEqual("en", item.OriginalLanguage);
            Assert.AreEqual("Dr. No", item.OriginalTitle);
            Assert.AreEqual("When Strangways, the British SIS Station Chief in Jamaica goes missing, MI6 send James Bond - Agent 007 to investigate. His investigation leads him to the mysterious Crab Key; the secret base of Dr No who he suspects is trying to sabotage the American space program using a radio beam. With the assistance of local fisherman Quarrel, who had been helping Strangways, Bond sneaks onto Crab Key where he meets the beautiful Honey Ryder. Can the three of them defeat an army of henchmen and a \"fire breathing dragon\" in order to stop Dr No, save the space program and get revenge for Strangways? Dr. No is the first film of legendary James Bond series starring Sean Connery in the role of Fleming's British super agent.", item.Overview);
            Assert.AreEqual(false, item.Video);
            Assert.AreEqual("/gRdfLVVf6FheOw6mw6wOsKhZG1l.jpg", item.PosterPath);
            Assert.AreEqual(new DateTime(1962, 10, 5), item.ReleaseDate);
            Assert.AreEqual("Dr. No", item.Title);
            Assert.IsTrue(item.Popularity > 0);
            Assert.IsTrue(item.VoteAverage > 0);
            Assert.IsTrue(item.VoteCount > 0);

            Assert.IsNotNull(item.GenreIds);
            Assert.IsTrue(item.GenreIds.Contains(12));
            Assert.IsTrue(item.GenreIds.Contains(28));
            Assert.IsTrue(item.GenreIds.Contains(53));
        }
Пример #17
0
        public void TestAccountGetFavoriteMovies()
        {
            // Ignore missing json
            IgnoreMissingJson("results[array] / media_type");

            Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
            TestHelpers.SearchPages(i => Config.Client.AccountGetFavoriteMoviesAsync(i).Result);
            SearchMovie movie = Config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];

            // Requires that you have marked at least one movie as favorite else this test will fail
            Assert.True(movie.Id > 0);
            Assert.NotNull(movie.Title);
            Assert.NotNull(movie.PosterPath);
            Assert.NotNull(movie.BackdropPath);
            Assert.NotNull(movie.OriginalTitle);
            Assert.NotNull(movie.Overview);
            Assert.NotNull(movie.OriginalLanguage);
            Assert.NotNull(movie.ReleaseDate);
            Assert.True(movie.VoteCount > 0);
            Assert.True(movie.VoteAverage > 0);
            Assert.True(movie.Popularity > 0);

            Assert.NotNull(movie.GenreIds);
            Assert.True(movie.GenreIds.Any());
        }
Пример #18
0
        public void TaggedImageConverter_Movie()
        {
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.Converters.Add(new TaggedImageConverter());

            SearchMovie originalMedia = new SearchMovie {
                OriginalTitle = "Hello world"
            };

            TaggedImage original = new TaggedImage();

            original.MediaType = MediaType.Movie;
            original.Media     = originalMedia;

            string      json   = JsonConvert.SerializeObject(original, settings);
            TaggedImage result = JsonConvert.DeserializeObject <TaggedImage>(json, settings);

            Assert.NotNull(result);
            Assert.NotNull(result.Media);
            Assert.IsType <SearchMovie>(result.Media);
            Assert.Equal(original.MediaType, result.MediaType);
            Assert.Equal(original.MediaType, result.Media.MediaType);

            SearchMovie resultMedia = (SearchMovie)result.Media;

            Assert.Equal(originalMedia.OriginalTitle, resultMedia.OriginalTitle);
        }
Пример #19
0
        public void TestSearchMovie()
        {
            TestHelpers.SearchPages(i => Config.Client.SearchMovieAsync("007", i).Result);

            // Search pr. Year
            // 1962: First James Bond movie, "Dr. No"
            SearchContainer <SearchMovie> result = Config.Client.SearchMovieAsync("007", year: 1962).Result;

            Assert.True(result.Results.Any());
            SearchMovie item = result.Results.SingleOrDefault(s => s.Id == 646);

            Assert.NotNull(item);
            Assert.Equal(646, item.Id);
            Assert.Equal(false, item.Adult);
            Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
            Assert.Equal("en", item.OriginalLanguage);
            Assert.Equal("Dr. No", item.OriginalTitle);
            Assert.Equal("In the film that launched the James Bond saga, Agent 007 (Sean Connery) battles mysterious Dr. No, a scientific genius bent on destroying the U.S. space program. As the countdown to disaster begins, Bond must go to Jamaica, where he encounters beautiful Honey Ryder (Ursula Andress), to confront a megalomaniacal villain in his massive island headquarters.", item.Overview);
            Assert.Equal(false, item.Video);
            Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
            Assert.Equal(new DateTime(1962, 10, 4), item.ReleaseDate);
            Assert.Equal("Dr. No", item.Title);
            Assert.True(item.Popularity > 0);
            Assert.True(item.VoteAverage > 0);
            Assert.True(item.VoteCount > 0);

            Assert.NotNull(item.GenreIds);
            Assert.True(item.GenreIds.Contains(12));
            Assert.True(item.GenreIds.Contains(28));
            Assert.True(item.GenreIds.Contains(53));
        }
        private async Task <Entities.Movie> SearchMovie(FileInfo file, IEnumerable <TMDbLib.Objects.General.Genre> movieGenres, Action <Entities.Movie, FileInfo> callback, Action <int, string> progressReportCallback)
        {
            SearchContainer <SearchMovie> searchResult = await _tmdbClient.SearchMovieAsync(Path.GetFileNameWithoutExtension(file.Name), includeAdult : true);

            IncrementRequestCount();
            AddProgress(1, $"Retrieving info for '{Path.GetFileNameWithoutExtension(file.Name)}'");

            SearchMovie foundMovie = searchResult.Results.FirstOrDefault();

            if (foundMovie == null)
            {
                return(null);
            }

            Entities.Movie movie = new Entities.Movie(foundMovie);

            movie.ItemGenres = movieGenres
                               .Where(g => foundMovie.GenreIds.Contains(g.Id))
                               .Select(g => new ItemGenre {
                Item  = movie,
                Genre = new Entities.Genre(g)
            }).ToList();

            callback(movie, file);

            return(movie);
        }
Пример #21
0
        private bool forceSearch(string i_FullFileName, FileInfo i_CurrentItem, SearchContainer <SearchMovie> i_Results)
        {
            bool found = false;

            for (int j = i_FullFileName.Length - 1; j >= 0; j--)
            {
                if (char.IsSeparator(i_FullFileName[j]))
                {
                    i_FullFileName = i_FullFileName.Substring(0, j);
                    i_Results      = m_Client.SearchMovieAsync(i_FullFileName).Result;

                    if (i_Results.TotalResults > 0)
                    {
                        SearchMovie result = i_Results.Results[0];

                        if (result.MediaType == MediaType.Movie)
                        {
                            foundAMovie(result.Id, i_CurrentItem);
                        }
                        found = true;
                        break;
                    }
                }
            }

            return(found);
        }
Пример #22
0
        public void GetVideoData(List <FileInfo> i_NewFilesFound)
        {
            try
            {
                for (int i = 0; i < i_NewFilesFound.Count; i++)
                {
                    string fullFileName = i_NewFilesFound[i].ToString();
                    SearchContainer <SearchMovie> results = m_Client.SearchMovieAsync(fullFileName).Result;

                    if (results.TotalResults > 0)
                    {
                        SearchMovie result = results.Results[0];

                        if (result.MediaType == MediaType.Movie)
                        {
                            foundAMovie(result.Id, i_NewFilesFound[i]);
                        }
                    }

                    else
                    {
                        if (!forceSearch(fullFileName, i_NewFilesFound[i], results))
                        {
                            i_NewFilesFound[i].FileName += " : NOT FOUND!!! try changing the file name";
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        public async Task <IHttpActionResult> GetAllMovies([FromUri] SearchMovie modelSearchMovie)
        {
            var result = await _movieListService.GetAllMoviesAsync(modelSearchMovie);

            MovieListVM movieListVM = Mapper.Map <MovieListVM>(result);

            return(Ok(movieListVM));
        }
Пример #24
0
        /// <summary>
        /// Finds the movies.
        /// </summary>
        /// <param name="searchRequest">The search request.</param>
        public SearchMovie FindMovies(string searchRequest, int pageNumber)
        {
            var instance = new MovieBoxApiService();
            ApiMoviesResponse response = instance.GetMovies(searchRequest, pageNumber);
            SearchMovie       result   = MapMovieApiEntities(response);

            return(result);
        }
Пример #25
0
 public MovieModel(SearchMovie _movie)
 {
     TMDBID      = _movie.Id;
     ImgSource   = "https://image.tmdb.org/t/p/w500/" + _movie.PosterPath;
     Title       = _movie.Title;
     ReleaseDate = _movie.ReleaseDate.Value.ToLongDateString();
     //Genre = _movie.GenreIds
     Information = _movie.Overview;
 }
Пример #26
0
 public SearchItem(SearchMovie movie)
 {
     MediaType   = MediaType.Movie;
     Id          = movie.Id;
     ResultName  = movie.OriginalTitle;
     ReleaseDate = movie.ReleaseDate.HasValue ? movie.ReleaseDate.Value : DateTime.Now;
     Overview    = movie.Overview;
     Rating      = movie.VoteAverage;
     ImageUri    = ModelUtils.GetImageUri(movie?.PosterPath);
 }
Пример #27
0
 public LetsWatchItem(SearchMovie m, bool rated = false, bool favorite = false, bool watchlist = false)
 {
     Id        = m.Id;
     MediaType = m.MediaType;
     Poster    = Utils.ModelUtils.GetSmallImageUri(m.PosterPath);
     Name      = m.Title;
     Rated     = rated;
     Favorite  = favorite;
     Watchlist = watchlist;
 }
Пример #28
0
        private MovieContainer GetContainer(SearchMovie item)
        {
            MovieContainer container = Movies.FindById(item.Id);

            if (container == null)
            {
                container = new MovieContainer(item);
            }

            return(container);
        }
 private void AddRatedItemToCollection(SearchMovie sm)
 {
     if (LetsWatchItems.ContainsKey(sm.Id))
     {
         LetsWatchItems[sm.Id].Item.Rated = true;
     }
     else
     {
         LetsWatchItems.Add(sm.Id, new LetsWatchItemViewModel(new LetsWatchItem(sm, rated: true)));
     }
 }
 private void AddFavoriteItemToCollection(SearchMovie sm)
 {
     if (LetsWatchItems.ContainsKey(sm.Id))
     {
         LetsWatchItems[sm.Id].Item.Favorite = true;
     }
     else
     {
         LetsWatchItems.Add(sm.Id, new LetsWatchItemViewModel(new LetsWatchItem(sm, favorite: true)));
     }
 }