1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 01:42:35 +01:00

Fixed: Excluded movies on search results

This commit is contained in:
Bogdan 2024-08-16 01:18:28 +03:00
parent 9ad6b3a611
commit 9442f1fb04
7 changed files with 20 additions and 34 deletions

View File

@ -6,7 +6,6 @@ import { clearAddMovie, lookupMovie } from 'Store/Actions/addMovieActions';
import { clearMovieFiles, fetchMovieFiles } from 'Store/Actions/movieFileActions'; import { clearMovieFiles, fetchMovieFiles } from 'Store/Actions/movieFileActions';
import { clearQueueDetails, fetchQueueDetails } from 'Store/Actions/queueActions'; import { clearQueueDetails, fetchQueueDetails } from 'Store/Actions/queueActions';
import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; import { fetchRootFolders } from 'Store/Actions/rootFolderActions';
import { fetchImportListExclusions } from 'Store/Actions/Settings/importListExclusions';
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems';
import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds';
@ -36,7 +35,6 @@ const mapDispatchToProps = {
lookupMovie, lookupMovie,
clearAddMovie, clearAddMovie,
fetchRootFolders, fetchRootFolders,
fetchImportListExclusions,
fetchQueueDetails, fetchQueueDetails,
clearQueueDetails, clearQueueDetails,
fetchMovieFiles, fetchMovieFiles,
@ -56,7 +54,6 @@ class AddNewMovieConnector extends Component {
componentDidMount() { componentDidMount() {
this.props.fetchRootFolders(); this.props.fetchRootFolders();
this.props.fetchImportListExclusions();
this.props.fetchQueueDetails(); this.props.fetchQueueDetails();
} }
@ -131,7 +128,6 @@ AddNewMovieConnector.propTypes = {
lookupMovie: PropTypes.func.isRequired, lookupMovie: PropTypes.func.isRequired,
clearAddMovie: PropTypes.func.isRequired, clearAddMovie: PropTypes.func.isRequired,
fetchRootFolders: PropTypes.func.isRequired, fetchRootFolders: PropTypes.func.isRequired,
fetchImportListExclusions: PropTypes.func.isRequired,
fetchQueueDetails: PropTypes.func.isRequired, fetchQueueDetails: PropTypes.func.isRequired,
clearQueueDetails: PropTypes.func.isRequired, clearQueueDetails: PropTypes.func.isRequired,
fetchMovieFiles: PropTypes.func.isRequired, fetchMovieFiles: PropTypes.func.isRequired,

View File

@ -71,7 +71,7 @@ class AddNewMovieSearchResult extends Component {
images, images,
existingMovieId, existingMovieId,
isExistingMovie, isExistingMovie,
isExclusionMovie, isExcluded,
isSmallScreen, isSmallScreen,
colorImpairedMode, colorImpairedMode,
id, id,
@ -167,7 +167,7 @@ class AddNewMovieSearchResult extends Component {
} }
{ {
isExclusionMovie && isExcluded &&
<Icon <Icon
className={styles.exclusionIcon} className={styles.exclusionIcon}
name={icons.DANGER} name={icons.DANGER}
@ -335,7 +335,7 @@ AddNewMovieSearchResult.propTypes = {
images: PropTypes.arrayOf(PropTypes.object).isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired,
existingMovieId: PropTypes.number, existingMovieId: PropTypes.number,
isExistingMovie: PropTypes.bool.isRequired, isExistingMovie: PropTypes.bool.isRequired,
isExclusionMovie: PropTypes.bool.isRequired, isExcluded: PropTypes.bool,
isSmallScreen: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired,
id: PropTypes.number, id: PropTypes.number,
monitored: PropTypes.bool.isRequired, monitored: PropTypes.bool.isRequired,
@ -349,7 +349,8 @@ AddNewMovieSearchResult.propTypes = {
}; };
AddNewMovieSearchResult.defaultProps = { AddNewMovieSearchResult.defaultProps = {
genres: [] genres: [],
isExcluded: false
}; };
export default AddNewMovieSearchResult; export default AddNewMovieSearchResult;

View File

@ -1,27 +1,24 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import createExclusionMovieSelector from 'Store/Selectors/createExclusionMovieSelector';
import createExistingMovieSelector from 'Store/Selectors/createExistingMovieSelector'; import createExistingMovieSelector from 'Store/Selectors/createExistingMovieSelector';
import AddNewMovieSearchResult from './AddNewMovieSearchResult'; import AddNewMovieSearchResult from './AddNewMovieSearchResult';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createExistingMovieSelector(), createExistingMovieSelector(),
createExclusionMovieSelector(),
createDimensionsSelector(), createDimensionsSelector(),
(state) => state.queue.details.items, (state) => state.queue.details.items,
(state) => state.movieFiles.items, (state) => state.movieFiles.items,
(state, { internalId }) => internalId, (state, { internalId }) => internalId,
(state) => state.settings.ui.item.movieRuntimeFormat, (state) => state.settings.ui.item.movieRuntimeFormat,
(isExistingMovie, isExclusionMovie, dimensions, queueItems, movieFiles, internalId, movieRuntimeFormat) => { (isExistingMovie, dimensions, queueItems, movieFiles, internalId, movieRuntimeFormat) => {
const queueItem = queueItems.find((item) => internalId > 0 && item.movieId === internalId); const queueItem = queueItems.find((item) => internalId > 0 && item.movieId === internalId);
const movieFile = movieFiles.find((item) => internalId > 0 && item.movieId === internalId); const movieFile = movieFiles.find((item) => internalId > 0 && item.movieId === internalId);
return { return {
existingMovieId: internalId, existingMovieId: internalId,
isExistingMovie, isExistingMovie,
isExclusionMovie,
isSmallScreen: dimensions.isSmallScreen, isSmallScreen: dimensions.isSmallScreen,
queueItem, queueItem,
movieFile, movieFile,

View File

@ -7,7 +7,6 @@ import withScrollPosition from 'Components/withScrollPosition';
import { executeCommand } from 'Store/Actions/commandActions'; import { executeCommand } from 'Store/Actions/commandActions';
import { addImportListExclusions, addMovies, clearAddMovie, fetchDiscoverMovies, setListMovieFilter, setListMovieSort, setListMovieTableOption, setListMovieView } from 'Store/Actions/discoverMovieActions'; import { addImportListExclusions, addMovies, clearAddMovie, fetchDiscoverMovies, setListMovieFilter, setListMovieSort, setListMovieTableOption, setListMovieView } from 'Store/Actions/discoverMovieActions';
import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; import { fetchRootFolders } from 'Store/Actions/rootFolderActions';
import { fetchImportListExclusions } from 'Store/Actions/Settings/importListExclusions';
import scrollPositions from 'Store/scrollPositions'; import scrollPositions from 'Store/scrollPositions';
import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
@ -43,10 +42,6 @@ function createMapDispatchToProps(dispatch, props) {
dispatch(fetchRootFolders()); dispatch(fetchRootFolders());
}, },
dispatchFetchImportListExclusions() {
dispatch(fetchImportListExclusions());
},
dispatchClearListMovie() { dispatchClearListMovie() {
dispatch(clearAddMovie()); dispatch(clearAddMovie());
}, },
@ -96,7 +91,6 @@ class DiscoverMovieConnector extends Component {
componentDidMount() { componentDidMount() {
registerPagePopulator(this.repopulate); registerPagePopulator(this.repopulate);
this.props.dispatchFetchRootFolders(); this.props.dispatchFetchRootFolders();
this.props.dispatchFetchImportListExclusions();
this.props.dispatchFetchListMovies(); this.props.dispatchFetchListMovies();
} }
@ -144,7 +138,6 @@ class DiscoverMovieConnector extends Component {
DiscoverMovieConnector.propTypes = { DiscoverMovieConnector.propTypes = {
isSmallScreen: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired,
view: PropTypes.string.isRequired, view: PropTypes.string.isRequired,
dispatchFetchImportListExclusions: PropTypes.func.isRequired,
dispatchFetchRootFolders: PropTypes.func.isRequired, dispatchFetchRootFolders: PropTypes.func.isRequired,
dispatchFetchListMovies: PropTypes.func.isRequired, dispatchFetchListMovies: PropTypes.func.isRequired,
dispatchClearListMovie: PropTypes.func.isRequired, dispatchClearListMovie: PropTypes.func.isRequired,

View File

@ -1,14 +0,0 @@
import _ from 'lodash';
import { createSelector } from 'reselect';
function createExclusionMovieSelector() {
return createSelector(
(state, { tmdbId }) => tmdbId,
(state) => state.settings.importListExclusions,
(tmdbId, importListExclusions) => {
return _.some(importListExclusions.items, { tmdbId });
}
);
}
export default createExclusionMovieSelector;

View File

@ -3,6 +3,7 @@
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.ImportLists.ImportExclusions;
using NzbDrone.Core.Languages; using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource; using NzbDrone.Core.MetadataSource;
@ -22,13 +23,15 @@ public class MovieLookupController : RestController<MovieResource>
private readonly INamingConfigService _namingService; private readonly INamingConfigService _namingService;
private readonly IMapCoversToLocal _coverMapper; private readonly IMapCoversToLocal _coverMapper;
private readonly IConfigService _configService; private readonly IConfigService _configService;
private readonly IImportListExclusionService _importListExclusionService;
public MovieLookupController(ISearchForNewMovie searchProxy, public MovieLookupController(ISearchForNewMovie searchProxy,
IProvideMovieInfo movieInfo, IProvideMovieInfo movieInfo,
IBuildFileNames fileNameBuilder, IBuildFileNames fileNameBuilder,
INamingConfigService namingService, INamingConfigService namingService,
IMapCoversToLocal coverMapper, IMapCoversToLocal coverMapper,
IConfigService configService) IConfigService configService,
IImportListExclusionService importListExclusionService)
{ {
_movieInfo = movieInfo; _movieInfo = movieInfo;
_searchProxy = searchProxy; _searchProxy = searchProxy;
@ -36,6 +39,7 @@ public MovieLookupController(ISearchForNewMovie searchProxy,
_namingService = namingService; _namingService = namingService;
_coverMapper = coverMapper; _coverMapper = coverMapper;
_configService = configService; _configService = configService;
_importListExclusionService = importListExclusionService;
} }
[NonAction] [NonAction]
@ -82,6 +86,8 @@ private IEnumerable<MovieResource> MapToResource(IEnumerable<Movie> movies)
var availDelay = _configService.AvailabilityDelay; var availDelay = _configService.AvailabilityDelay;
var namingConfig = _namingService.GetConfig(); var namingConfig = _namingService.GetConfig();
var listExclusions = _importListExclusionService.All();
foreach (var currentMovie in movies) foreach (var currentMovie in movies)
{ {
var translation = currentMovie.MovieMetadata.Value.Translations.FirstOrDefault(t => t.Language == movieInfoLanguage); var translation = currentMovie.MovieMetadata.Value.Translations.FirstOrDefault(t => t.Language == movieInfoLanguage);
@ -97,6 +103,8 @@ private IEnumerable<MovieResource> MapToResource(IEnumerable<Movie> movies)
resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie, namingConfig); resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie, namingConfig);
resource.IsExcluded = listExclusions.Any(e => e.TmdbId == resource.TmdbId);
yield return resource; yield return resource;
} }
} }

View File

@ -88,6 +88,11 @@ public MovieResource()
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[SwaggerIgnore] [SwaggerIgnore]
public bool Grabbed { get; set; } public bool Grabbed { get; set; }
// Hiding this so people don't think its usable (only used for searches)
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[SwaggerIgnore]
public bool IsExcluded { get; set; }
} }
public static class MovieResourceMapper public static class MovieResourceMapper