public async Task Movie_Has_Custom_Url_When_Specified_In_Settings()
        {
            SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings
            {
                Enable  = true,
                Servers = new List <JellyfinServers>
                {
                    new JellyfinServers
                    {
                        ServerHostname = "http://test.com/",
                        ServerId       = "8"
                    }
                }
            });
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new JellyfinContent
            {
                ProviderId = "123",
                JellyfinId = 1.ToString(),
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.That(search.JellyfinUrl, Is.EqualTo("http://test.com/web/index.html#!/details?id=1&serverId=8"));
        }
Exemplo n.º 2
0
        public async Task CallMovieServiceOnce_OnGet()
        {
            // Arrange
            var movieServiceMock = new Mock <IMovieService>();
            var genreServiceMock = new Mock <IGenreService>();

            string searchTerm = "hello";

            movieServiceMock
            .Setup(g => g.SearchAsync(searchTerm))
            .ReturnsAsync(new List <MovieViewModel>());

            var sut = new MovieController(movieServiceMock.Object, genreServiceMock.Object);

            var searchModel = new SearchMovieViewModel()
            {
                SearchName = searchTerm
            };

            // Act
            await sut.Search(searchModel);

            // Assert
            movieServiceMock.Verify(g => g.SearchAsync(searchTerm), Times.Once);
        }
Exemplo n.º 3
0
        private async Task CheckForSubscription(SearchMovieViewModel viewModel)
        {
            // Check if this user requested it
            var user = await GetUser();

            if (user == null)
            {
                return;
            }
            var request = await RequestService.MovieRequestService.GetAll()
                          .AnyAsync(x => x.RequestedUserId.Equals(user.Id) && x.TheMovieDbId == viewModel.Id);

            if (request || viewModel.Available)
            {
                viewModel.ShowSubscribe = false;
            }
            else
            {
                viewModel.ShowSubscribe = true;
                var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => s.UserId == user.Id &&
                                                                                     s.RequestId == viewModel.RequestId && s.RequestType == RequestType.Movie);

                viewModel.Subscribed = sub != null;
            }
        }
Exemplo n.º 4
0
        public async Task Movie_Uses_Default_Url_When()
        {
            SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new EmbySettings
            {
                Enable  = true,
                Servers = new List <EmbyServers>
                {
                    new EmbyServers
                    {
                        ServerHostname = string.Empty,
                        ServerId       = "8"
                    }
                }
            });
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new EmbyContent
            {
                ProviderId = "123",
                EmbyId     = 1.ToString()
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/web/index.html#!/item?id=1&serverId=8"));
        }
Exemplo n.º 5
0
        public ActionResult SearchResultsMovies(SearchMovieViewModel smvm)
        {
            VarGlobal.SearchMovieName  = smvm.Name;
            VarGlobal.SearchMovieGenre = smvm.Genre;

            return(View(new SearchResultsMovieViewModel()));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        /// <param name="movieService">Instance of MovieService</param>
        /// <param name="userService">Instance of UserService</param>
        /// <param name="applicationService">Instance of ApplicationService</param>
        /// <param name="genreService">The genre service</param>
        public MoviePageViewModel(IMovieService movieService,
                                  IUserService userService, IApplicationService applicationService, IGenreService genreService)
        {
            _movieService      = movieService;
            _userService       = userService;
            ApplicationService = applicationService;
            GenreViewModel     = new GenreViewModel(userService, genreService);
            RegisterMessages();
            RegisterCommands();

            Search = new SearchMovieViewModel();

            DispatcherHelper.CheckBeginInvokeOnUI(async() =>
            {
                Tabs.Add(new PopularMovieTabViewModel(ApplicationService, _movieService, _userService));
                Tabs.Add(new GreatestMovieTabViewModel(ApplicationService, _movieService, _userService));
                Tabs.Add(new RecentMovieTabViewModel(ApplicationService, _movieService, _userService));
                Tabs.Add(new FavoritesMovieTabViewModel(ApplicationService, _movieService, _userService));
                Tabs.Add(new SeenMovieTabViewModel(ApplicationService, _movieService, _userService));
                SelectedTab = Tabs.First();
                SelectedMoviesIndexMenuTab = 0;
                await GenreViewModel.LoadGenresAsync().ConfigureAwait(false);
                await Tabs.ToList().ParallelForEachAsync(async tab =>
                {
                    await tab.LoadMoviesAsync().ConfigureAwait(false);
                }).ConfigureAwait(false);
            });
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        /// <param name="movieService">Instance of MovieService</param>
        /// <param name="movieHistoryService">Instance of MovieHistoryService</param>
        /// <param name="applicationService">Instance of ApplicationService</param>
        public MoviePageViewModel(IMovieService movieService,
                                  IMovieHistoryService movieHistoryService, IApplicationService applicationService)
        {
            _movieService        = movieService;
            _movieHistoryService = movieHistoryService;
            ApplicationService   = applicationService;
            GenresMovie          = new GenresMovieViewModel(_movieService);
            RegisterMessages();
            RegisterCommands();

            Search = new SearchMovieViewModel();

            DispatcherHelper.CheckBeginInvokeOnUI(async() =>
            {
                Tabs.Add(new PopularMovieTabViewModel(ApplicationService, _movieService, _movieHistoryService));
                Tabs.Add(new GreatestMovieTabViewModel(ApplicationService, _movieService, _movieHistoryService));
                Tabs.Add(new RecentMovieTabViewModel(ApplicationService, _movieService, _movieHistoryService));
                Tabs.Add(new FavoritesMovieTabViewModel(ApplicationService, _movieService, _movieHistoryService));
                Tabs.Add(new SeenMovieTabViewModel(ApplicationService, _movieService, _movieHistoryService));
                SelectedTab = Tabs.First();
                SelectedMoviesIndexMenuTab = 0;
                var loadMoviesTask         = Tabs.ParallelForEachAsync(async tab =>
                {
                    await tab.LoadMoviesAsync();
                });

                var loadGenreTask = GenresMovie.LoadGenresAsync();

                await Task.WhenAll(new List <Task>
                {
                    loadMoviesTask,
                    loadGenreTask
                });
            });
        }
        public async Task Movie_Uses_Default_Url_When()
        {
            SettingsMock.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new JellyfinSettings
            {
                Enable  = true,
                Servers = new List <JellyfinServers>
                {
                    new JellyfinServers
                    {
                        Ip             = "8080",
                        Port           = 9090,
                        ServerHostname = string.Empty,
                        ServerId       = "8"
                    }
                }
            });
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new JellyfinContent
            {
                ProviderId = "123",
                JellyfinId = 1.ToString()
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
        }
Exemplo n.º 9
0
        private async Task <SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie)
        {
            if (viewMovie.ImdbId.IsNullOrEmpty())
            {
                var showInfo = await Cache.GetOrAddAsync("GetMovieInformationWIthImdbId" + viewMovie.Id,
                                                         () => MovieApi.GetMovieInformation(viewMovie.Id), DateTimeOffset.Now.AddHours(12));

                viewMovie.Id     = showInfo.Id; // TheMovieDbId
                viewMovie.ImdbId = showInfo.ImdbId;
            }

            var user = await GetUser();

            var digitalReleaseDate = viewMovie.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == user.StreamingCountry);

            if (digitalReleaseDate == null)
            {
                digitalReleaseDate = viewMovie.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
            }
            viewMovie.DigitalReleaseDate = digitalReleaseDate?.ReleaseDate?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;


            viewMovie.TheMovieDbId = viewMovie.Id.ToString();

            await RunSearchRules(viewMovie);

            // This requires the rules to be run first to populate the RequestId property
            await CheckForSubscription(viewMovie);

            return(viewMovie);
        }
Exemplo n.º 10
0
        public IActionResult Search(SearchMovieViewModel vm)
        {
            // TODO - Show what filters have been applied.
            // List<Film> films = new List<Film>();

            // Gets films matching the search value and filter (if selected).
            List <Film> films = _filmServices.GetAllCompleteFilms()
                                .WhereIf(!string.IsNullOrEmpty(vm.MediaFilter), f => f.Media.Name == vm.MediaFilter)
                                .WhereIf(!string.IsNullOrEmpty(vm.SearchValue), f => f.Name.ToLower().Contains(vm.SearchValue.ToLower()))
                                .WhereIf(!string.IsNullOrEmpty(vm.AudioFilter), f => f.Audio.Name == vm.AudioFilter)
                                .WhereIf(!string.IsNullOrEmpty(vm.GenreFilter), f => f.FilmGenres.Any(fg => fg.Genre != null && fg.Genre.Name == vm.GenreFilter))
                                .ToList();

            // Filter out films that should not be visible to the User based on privacy level
            films = _filmServices.GetAllVisible(films, User);

            // sort the collection of films by selected value (title ascending is default)
            vm.Films = _filmServices.SortBy(films, vm.SortPriority);

            // TODO - Check if Genres needs the full Genre models or just the Ids
            vm.Genres       = _context.Genres.ToList();
            vm.MediaFormats = _context.MediaFormats.ToList();
            vm.AudioFormats = _context.AudioFormats.ToList();

            // TODO - Add pagination for the results.  See WebSearch.
            return(View(vm));
        }
Exemplo n.º 11
0
        public async Task ReturnCorrectViewModel_OnGet()
        {
            // Arrange
            var movieServiceMock = new Mock <IMovieService>();
            var genreServiceMock = new Mock <IGenreService>();

            string searchTerm = "hello";

            movieServiceMock
            .Setup(g => g.SearchAsync(searchTerm))
            .ReturnsAsync(new List <MovieViewModel>());

            var sut = new MovieController(movieServiceMock.Object, genreServiceMock.Object);

            var searchModel = new SearchMovieViewModel()
            {
                SearchName = searchTerm
            };

            // Act
            var result = await sut.Search(searchModel) as ViewResult;

            // Assert
            Assert.IsInstanceOfType(result.Model, typeof(SearchMovieViewModel));
        }
Exemplo n.º 12
0
        public async Task Movie_ShouldBe_NotAvailable_WhenNotFoundInJellyfin()
        {
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).Returns(Task.FromResult(default(JellyfinContent)));
            var search = new SearchMovieViewModel();
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.False(search.Available);
        }
Exemplo n.º 13
0
        public async Task ShouldBe_NotAvailable_WhenNotFoundInPlex()
        {
            ContextMock.Setup(x => x.Get(It.IsAny<string>())).Returns(Task.FromResult(default(PlexServerContent)));
            var search = new SearchMovieViewModel();
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.Null(search.PlexUrl);
            Assert.False(search.Available);
        }
        public async Task <IActionResult> Search(SearchMovieViewModel model)
        {
            if (string.IsNullOrEmpty(model.SearchName))
            {
                return(this.View());
            }

            var movies = await this.movieService.SearchAsync(model.SearchName);

            model.Movies = movies;
            return(this.View(model));
        }
Exemplo n.º 15
0
        public ActionResult ComingSoon()
        {
            ViewBag.viewheadline  = "Coming Soon on DVD/Blu-ray";
            ViewBag.comingSoon    = "active-menu";
            ViewBag.dropDownState = "Movies";

            var repo      = new MovieGalleryRepository();
            var movieRepo = repo.MoviesComingSoon();
            var viewModel = new SearchMovieViewModel <MovieSearchItems>(repo, movieRepo.MovieItems, movieRepo.page, movieRepo.total_pages, movieRepo.total_results);

            return(View("~/Views/MovieGallery/Index.cshtml", viewModel));
        }
Exemplo n.º 16
0
        public ActionResult Index()
        {
            ViewBag.viewheadline  = "DVD/Blu-ray News";
            ViewBag.currentNews   = "active-menu";
            ViewBag.dropDownState = "Movies";

            var repo      = new MovieGalleryRepository();
            var movieRepo = repo.GetRecentReleasedMovies();
            var viewModel = new SearchMovieViewModel <MovieSearchItems>(repo, movieRepo.MovieItems, movieRepo.page, movieRepo.total_pages, movieRepo.total_results);

            return(View("~/Views/MovieGallery/Index.cshtml", viewModel));
        }
Exemplo n.º 17
0
        public async Task Movie_ShouldBe_Available_WhenFoundInEmby()
        {
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new EmbyContent
            {
                ProviderId = "123"
            });
            var search = new SearchMovieViewModel();
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.True(search.Available);
        }
Exemplo n.º 18
0
        public async Task Movie_Uses_Default_Url_When()
        {
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new JellyfinContent
            {
                TheMovieDbId = "123",
                JellyfinId   = 1.ToString()
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
        }
Exemplo n.º 19
0
        private async Task <SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie, bool lookupExtraInfo = false)
        {
            if (lookupExtraInfo)
            {
                var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);

                viewMovie.Id     = showInfo.Id; // TheMovieDbId
                viewMovie.ImdbId = showInfo.ImdbId;
            }

            viewMovie.TheMovieDbId = viewMovie.Id.ToString();

            await RunSearchRules(viewMovie);

            return(viewMovie);
        }
Exemplo n.º 20
0
        public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin()
        {
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new JellyfinContent
            {
                TheMovieDbId = "123",
                Quality      = "1080"
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.True(search.Available);
        }
Exemplo n.º 21
0
        public IActionResult Search(string query)
        {
            List <Film> films = _context.Films
                                .Include(f => f.User)
                                .Where(f => f.Name.ToLower().Contains(query.ToLower()))
                                .Where(f => _filmServices.IsFilmViewable(f, User))
                                .ToList();

            var vm = new SearchMovieViewModel(films);

            vm.Genres       = _context.Genres.ToList();
            vm.MediaFormats = _context.MediaFormats.ToList();
            vm.AudioFormats = _context.AudioFormats.ToList();

            return(View(vm));
        }
Exemplo n.º 22
0
        public async Task Should_ReturnApproved_WhenMovieIsInCouchPotato()
        {
            var list = new CouchPotatoCache
            {
                TheMovieDbId = 123
            };

            ContextMock.Setup(x => x.FirstOrDefaultAsync(It.IsAny <Expression <Func <CouchPotatoCache, bool> > >())).ReturnsAsync(list);

            var request = new SearchMovieViewModel {
                Id = 123
            };
            var result = await Rule.Execute(request);

            Assert.True(result.Success);
            Assert.True(request.Approved);
        }
Exemplo n.º 23
0
        public async Task Should_ReturnNotApproved_WhenMovieIsNotInRadarr()
        {
            var list = DbHelper.GetQueryableMockDbSet(new RadarrCache
            {
                TheMovieDbId = 000012,
            });

            ContextMock.Setup(x => x.GetAll()).Returns(list);

            var request = new SearchMovieViewModel {
                Id = 123
            };
            var result = await Rule.Execute(request);

            Assert.True(result.Success);
            Assert.False(request.Approved);
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Search(SearchMovieViewModel model)
        {
            var jsonResult = await this.client.SearchMovie(model.SearchString);

            try
            {
                var apiMoviesFound = this.jsonProvider.ExtractFoundMoviesFromSearchMovieJsonResult(jsonResult);
                model.ApiMovies = apiMoviesFound.Select(m => new MovieViewModel(m));

                var dbMoviesFound = this.movieService.SearchMovie(model.SearchString);
                model.DbMovies = dbMoviesFound.Select(m => new MovieViewModel(m));;
            }
            catch (InvalidOperationException)
            {
            }

            return(View(model));
        }
Exemplo n.º 25
0
        public async Task ShouldBe_Available_WhenFoundInPlex()
        {
            ContextMock.Setup(x => x.Get(It.IsAny<string>())).ReturnsAsync(new PlexServerContent
            {
                Url = "TestUrl",
                ImdbId = "132"
            });

            var search = new SearchMovieViewModel
            {
                ImdbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.AreEqual("TestUrl", search.PlexUrl);
            Assert.True(search.Available);
        }
Exemplo n.º 26
0
        public async Task Movie_ShouldBe_Available_WhenFoundInJellyfin_4K()
        {
            FeatureMock.Setup(x => x.FeatureEnabled(FeatureNames.Movie4KRequests)).ReturnsAsync(true);
            ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny <string>())).ReturnsAsync(new JellyfinContent
            {
                TheMovieDbId = "123",
                Has4K        = true
            });
            var search = new SearchMovieViewModel()
            {
                TheMovieDbId = "123",
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.False(search.Available);
            Assert.True(search.Available4K);
        }
Exemplo n.º 27
0
        private async Task <SearchMovieViewModel> ProcessSingleMovie(SearchMovieViewModel viewMovie, bool lookupExtraInfo = false)
        {
            if (lookupExtraInfo)
            {
                var showInfo = await MovieApi.GetMovieInformation(viewMovie.Id);

                viewMovie.Id     = showInfo.Id; // TheMovieDbId
                viewMovie.ImdbId = showInfo.ImdbId;
                var usDates = viewMovie.ReleaseDates?.Results?.FirstOrDefault(x => x.IsoCode == "US");
                viewMovie.DigitalReleaseDate = usDates?.ReleaseDate?.FirstOrDefault(x => x.Type == ReleaseDateType.Digital)?.ReleaseDate;
            }

            viewMovie.TheMovieDbId = viewMovie.Id.ToString();

            await RunSearchRules(viewMovie);

            return(viewMovie);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        /// <param name="movieService">Instance of MovieService</param>
        /// <param name="userService">Instance of UserService</param>
        /// <param name="applicationService">Instance of ApplicationService</param>
        /// <param name="genreService">The genre service</param>
        public MoviePageViewModel(IMovieService movieService,
                                  IUserService userService, IApplicationService applicationService, IGenreService genreService)
        {
            MovieService       = movieService;
            UserService        = userService;
            ApplicationService = applicationService;
            GenreViewModel     = new GenreViewModel(userService, genreService);
            RegisterMessages();
            RegisterCommands();

            Search = new SearchMovieViewModel();
            Tabs.Add(new PopularMovieTabViewModel(ApplicationService, MovieService, UserService));
            Tabs.Add(new GreatestMovieTabViewModel(ApplicationService, MovieService, UserService));
            Tabs.Add(new RecentMovieTabViewModel(ApplicationService, MovieService, UserService));
            Tabs.Add(new FavoritesMovieTabViewModel(ApplicationService, MovieService, UserService));
            Tabs.Add(new SeenMovieTabViewModel(ApplicationService, MovieService, UserService));
            SelectedTab = Tabs.First();
            SelectedMoviesIndexMenuTab = 0;
        }
Exemplo n.º 29
0
        public async Task ShouldBe_NotRequested_WhenNewMovie()
        {
            var list = new MovieRequests
            {
                TheMovieDbId = 123,
                Approved     = true
            };

            MovieMock.Setup(x => x.GetRequestAsync(123)).ReturnsAsync(list);
            var search = new SearchMovieViewModel
            {
                Id = 999,
            };
            var result = await Rule.Execute(search);

            Assert.True(result.Success);
            Assert.False(search.Approved);
            Assert.False(search.Requested);
        }
Exemplo n.º 30
0
        public async Task Should_ReturnApproved_WhenMovieIsInRadarr()
        {
            var list = new List <RadarrCache>()
            {
                new RadarrCache
                {
                    TheMovieDbId = 123
                }
            }.AsQueryable();

            ContextMock.Setup(x => x.GetAll()).Returns(list);

            var request = new SearchMovieViewModel {
                Id = 123
            };
            var result = await Rule.Execute(request);

            Assert.True(result.Success);
            Assert.True(request.Approved);
        }