New: Add tag support to indexers

(cherry picked from commit c3d54b312ef18b837d54605ea78f1a263fd6900b)
pull/6671/head
6cUbi57z 4 years ago committed by Robin Dadswell
parent 4e1aa5b946
commit 64045b0810

@ -43,6 +43,7 @@ function EditIndexerModalContent(props) {
enableInteractiveSearch, enableInteractiveSearch,
supportsRss, supportsRss,
supportsSearch, supportsSearch,
tags,
fields, fields,
priority priority
} = item; } = item;
@ -135,6 +136,7 @@ function EditIndexerModalContent(props) {
); );
}) })
} }
<FormGroup <FormGroup
advancedSettings={advancedSettings} advancedSettings={advancedSettings}
isAdvanced={true} isAdvanced={true}
@ -151,6 +153,18 @@ function EditIndexerModalContent(props) {
onChange={onInputChange} onChange={onInputChange}
/> />
</FormGroup> </FormGroup>
<FormGroup>
<FormLabel>Tags</FormLabel>
<FormInputGroup
type={inputTypes.TAG}
name="tags"
helpText={translate('IndexerTagHelpText')}
{...tags}
onChange={onInputChange}
/>
</FormGroup>
</Form> </Form>
} }
</ModalBody> </ModalBody>

@ -4,6 +4,7 @@ import Card from 'Components/Card';
import Label from 'Components/Label'; import Label from 'Components/Label';
import IconButton from 'Components/Link/IconButton'; import IconButton from 'Components/Link/IconButton';
import ConfirmModal from 'Components/Modal/ConfirmModal'; import ConfirmModal from 'Components/Modal/ConfirmModal';
import TagList from 'Components/TagList';
import { icons, kinds } from 'Helpers/Props'; import { icons, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import EditIndexerModalConnector from './EditIndexerModalConnector'; import EditIndexerModalConnector from './EditIndexerModalConnector';
@ -68,6 +69,8 @@ class Indexer extends Component {
enableRss, enableRss,
enableAutomaticSearch, enableAutomaticSearch,
enableInteractiveSearch, enableInteractiveSearch,
tags,
tagList,
supportsRss, supportsRss,
supportsSearch, supportsSearch,
priority, priority,
@ -133,6 +136,11 @@ class Indexer extends Component {
} }
</div> </div>
<TagList
tags={tags}
tagList={tagList}
/>
<EditIndexerModalConnector <EditIndexerModalConnector
id={id} id={id}
isOpen={this.state.isEditIndexerModalOpen} isOpen={this.state.isEditIndexerModalOpen}
@ -160,6 +168,8 @@ Indexer.propTypes = {
enableRss: PropTypes.bool.isRequired, enableRss: PropTypes.bool.isRequired,
enableAutomaticSearch: PropTypes.bool.isRequired, enableAutomaticSearch: PropTypes.bool.isRequired,
enableInteractiveSearch: PropTypes.bool.isRequired, enableInteractiveSearch: PropTypes.bool.isRequired,
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
supportsRss: PropTypes.bool.isRequired, supportsRss: PropTypes.bool.isRequired,
supportsSearch: PropTypes.bool.isRequired, supportsSearch: PropTypes.bool.isRequired,
onCloneIndexerPress: PropTypes.func.isRequired, onCloneIndexerPress: PropTypes.func.isRequired,

@ -54,6 +54,7 @@ class Indexers extends Component {
render() { render() {
const { const {
items, items,
tagList,
dispatchCloneIndexer, dispatchCloneIndexer,
onConfirmDeleteIndexer, onConfirmDeleteIndexer,
...otherProps ...otherProps
@ -79,6 +80,7 @@ class Indexers extends Component {
<Indexer <Indexer
key={item.id} key={item.id}
{...item} {...item}
tagList={tagList}
showPriority={showPriority} showPriority={showPriority}
onCloneIndexerPress={this.onCloneIndexerPress} onCloneIndexerPress={this.onCloneIndexerPress}
onConfirmDeleteIndexer={onConfirmDeleteIndexer} onConfirmDeleteIndexer={onConfirmDeleteIndexer}
@ -119,6 +121,7 @@ Indexers.propTypes = {
isFetching: PropTypes.bool.isRequired, isFetching: PropTypes.bool.isRequired,
error: PropTypes.object, error: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
dispatchCloneIndexer: PropTypes.func.isRequired, dispatchCloneIndexer: PropTypes.func.isRequired,
onConfirmDeleteIndexer: PropTypes.func.isRequired onConfirmDeleteIndexer: PropTypes.func.isRequired
}; };

@ -4,13 +4,20 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { cloneIndexer, deleteIndexer, fetchIndexers } from 'Store/Actions/settingsActions'; import { cloneIndexer, deleteIndexer, fetchIndexers } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
import sortByName from 'Utilities/Array/sortByName'; import sortByName from 'Utilities/Array/sortByName';
import Indexers from './Indexers'; import Indexers from './Indexers';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createSortedSectionSelector('settings.indexers', sortByName), createSortedSectionSelector('settings.indexers', sortByName),
(indexers) => indexers createTagsSelector(),
(indexers, tagList) => {
return {
...indexers,
tagList
};
}
); );
} }

@ -22,6 +22,7 @@ function TagDetailsModalContent(props) {
notifications, notifications,
restrictions, restrictions,
importLists, importLists,
indexers,
onModalClose, onModalClose,
onDeleteTagPress onDeleteTagPress
} = props; } = props;
@ -41,7 +42,7 @@ function TagDetailsModalContent(props) {
} }
{ {
!!movies.length && movies.length ?
<FieldSet legend={translate('Movies')}> <FieldSet legend={translate('Movies')}>
{ {
movies.map((item) => { movies.map((item) => {
@ -52,11 +53,12 @@ function TagDetailsModalContent(props) {
); );
}) })
} }
</FieldSet> </FieldSet> :
null
} }
{ {
!!delayProfiles.length && delayProfiles.length ?
<FieldSet legend={translate('DelayProfile')}> <FieldSet legend={translate('DelayProfile')}>
{ {
delayProfiles.map((item) => { delayProfiles.map((item) => {
@ -81,11 +83,12 @@ function TagDetailsModalContent(props) {
); );
}) })
} }
</FieldSet> </FieldSet> :
null
} }
{ {
!!notifications.length && notifications.length ?
<FieldSet legend={translate('Connections')}> <FieldSet legend={translate('Connections')}>
{ {
notifications.map((item) => { notifications.map((item) => {
@ -96,11 +99,12 @@ function TagDetailsModalContent(props) {
); );
}) })
} }
</FieldSet> </FieldSet> :
null
} }
{ {
!!restrictions.length && restrictions.length ?
<FieldSet legend={translate('Restrictions')}> <FieldSet legend={translate('Restrictions')}>
{ {
restrictions.map((item) => { restrictions.map((item) => {
@ -142,7 +146,24 @@ function TagDetailsModalContent(props) {
); );
}) })
} }
</FieldSet> </FieldSet> :
null
}
{
indexers.length ?
<FieldSet legend="Indexers">
{
indexers.map((item) => {
return (
<div key={item.id}>
{item.name}
</div>
);
})
}
</FieldSet> :
null
} }
{ {
@ -192,6 +213,7 @@ TagDetailsModalContent.propTypes = {
notifications: PropTypes.arrayOf(PropTypes.object).isRequired, notifications: PropTypes.arrayOf(PropTypes.object).isRequired,
restrictions: PropTypes.arrayOf(PropTypes.object).isRequired, restrictions: PropTypes.arrayOf(PropTypes.object).isRequired,
importLists: PropTypes.arrayOf(PropTypes.object).isRequired, importLists: PropTypes.arrayOf(PropTypes.object).isRequired,
indexers: PropTypes.arrayOf(PropTypes.object).isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
onDeleteTagPress: PropTypes.func.isRequired onDeleteTagPress: PropTypes.func.isRequired
}; };

@ -69,6 +69,14 @@ function createMatchingImportListsSelector() {
); );
} }
function createMatchingIndexersSelector() {
return createSelector(
(state, { indexerIds }) => indexerIds,
(state) => state.settings.indexers.items,
findMatchingItems
);
}
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
createMatchingMoviesSelector(), createMatchingMoviesSelector(),
@ -76,13 +84,15 @@ function createMapStateToProps() {
createMatchingNotificationsSelector(), createMatchingNotificationsSelector(),
createMatchingRestrictionsSelector(), createMatchingRestrictionsSelector(),
createMatchingImportListsSelector(), createMatchingImportListsSelector(),
(movies, delayProfiles, notifications, restrictions, importLists) => { createMatchingIndexersSelector(),
(movies, delayProfiles, notifications, restrictions, importLists, indexers) => {
return { return {
movies, movies,
delayProfiles, delayProfiles,
notifications, notifications,
restrictions, restrictions,
importLists importLists,
indexers
}; };
} }
); );

@ -57,7 +57,8 @@ class Tag extends Component {
notificationIds, notificationIds,
restrictionIds, restrictionIds,
importListIds, importListIds,
movieIds movieIds,
indexerIds
} = this.props; } = this.props;
const { const {
@ -70,7 +71,8 @@ class Tag extends Component {
notificationIds.length || notificationIds.length ||
restrictionIds.length || restrictionIds.length ||
importListIds.length || importListIds.length ||
movieIds.length movieIds.length ||
indexerIds.length
); );
return ( return (
@ -120,6 +122,14 @@ class Tag extends Component {
{importListIds.length} list{importListIds.length > 1 && 's'} {importListIds.length} list{importListIds.length > 1 && 's'}
</div> </div>
} }
{
indexerIds.length ?
<div>
{indexerIds.length} indexer{indexerIds.length > 1 && 's'}
</div> :
null
}
</div> </div>
} }
@ -138,6 +148,7 @@ class Tag extends Component {
notificationIds={notificationIds} notificationIds={notificationIds}
restrictionIds={restrictionIds} restrictionIds={restrictionIds}
importListIds={importListIds} importListIds={importListIds}
indexerIds={indexerIds}
isOpen={isDetailsModalOpen} isOpen={isDetailsModalOpen}
onModalClose={this.onDetailsModalClose} onModalClose={this.onDetailsModalClose}
onDeleteTagPress={this.onDeleteTagPress} onDeleteTagPress={this.onDeleteTagPress}
@ -165,6 +176,7 @@ Tag.propTypes = {
restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired, restrictionIds: PropTypes.arrayOf(PropTypes.number).isRequired,
importListIds: PropTypes.arrayOf(PropTypes.number).isRequired, importListIds: PropTypes.arrayOf(PropTypes.number).isRequired,
movieIds: PropTypes.arrayOf(PropTypes.number).isRequired, movieIds: PropTypes.arrayOf(PropTypes.number).isRequired,
indexerIds: PropTypes.arrayOf(PropTypes.number).isRequired,
onConfirmDeleteTag: PropTypes.func.isRequired onConfirmDeleteTag: PropTypes.func.isRequired
}; };
@ -173,7 +185,8 @@ Tag.defaultProps = {
notificationIds: [], notificationIds: [],
restrictionIds: [], restrictionIds: [],
importListIds: [], importListIds: [],
movieIds: [] movieIds: [],
indexerIds: []
}; };
export default Tag; export default Tag;

@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { fetchDelayProfiles, fetchImportLists, fetchNotifications, fetchRestrictions } from 'Store/Actions/settingsActions'; import { fetchDelayProfiles, fetchImportLists, fetchIndexers, fetchNotifications, fetchRestrictions } from 'Store/Actions/settingsActions';
import { fetchTagDetails } from 'Store/Actions/tagActions'; import { fetchTagDetails } from 'Store/Actions/tagActions';
import Tags from './Tags'; import Tags from './Tags';
@ -29,7 +29,8 @@ const mapDispatchToProps = {
dispatchFetchDelayProfiles: fetchDelayProfiles, dispatchFetchDelayProfiles: fetchDelayProfiles,
dispatchFetchNotifications: fetchNotifications, dispatchFetchNotifications: fetchNotifications,
dispatchFetchRestrictions: fetchRestrictions, dispatchFetchRestrictions: fetchRestrictions,
dispatchFetchImportLists: fetchImportLists dispatchFetchImportLists: fetchImportLists,
dispatchFetchIndexers: fetchIndexers
}; };
class MetadatasConnector extends Component { class MetadatasConnector extends Component {
@ -43,7 +44,8 @@ class MetadatasConnector extends Component {
dispatchFetchDelayProfiles, dispatchFetchDelayProfiles,
dispatchFetchNotifications, dispatchFetchNotifications,
dispatchFetchRestrictions, dispatchFetchRestrictions,
dispatchFetchImportLists dispatchFetchImportLists,
dispatchFetchIndexers
} = this.props; } = this.props;
dispatchFetchTagDetails(); dispatchFetchTagDetails();
@ -51,6 +53,7 @@ class MetadatasConnector extends Component {
dispatchFetchNotifications(); dispatchFetchNotifications();
dispatchFetchRestrictions(); dispatchFetchRestrictions();
dispatchFetchImportLists(); dispatchFetchImportLists();
dispatchFetchIndexers();
} }
// //
@ -70,7 +73,8 @@ MetadatasConnector.propTypes = {
dispatchFetchDelayProfiles: PropTypes.func.isRequired, dispatchFetchDelayProfiles: PropTypes.func.isRequired,
dispatchFetchNotifications: PropTypes.func.isRequired, dispatchFetchNotifications: PropTypes.func.isRequired,
dispatchFetchRestrictions: PropTypes.func.isRequired, dispatchFetchRestrictions: PropTypes.func.isRequired,
dispatchFetchImportLists: PropTypes.func.isRequired dispatchFetchImportLists: PropTypes.func.isRequired,
dispatchFetchIndexers: PropTypes.func.isRequired
}; };
export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector); export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector);

@ -0,0 +1,102 @@
using System.Collections.Generic;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.DecisionEngine.Specifications.RssSync;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.DecisionEngineTests.RssSync
{
[TestFixture]
public class IndexerTagSpecificationFixture : CoreTest<IndexerTagSpecification>
{
private IndexerTagSpecification _specification;
private RemoteMovie _parseResultMulti;
private IndexerDefinition _fakeIndexerDefinition;
private Movie _fakeMovie;
private ReleaseInfo _fakeRelease;
[SetUp]
public void Setup()
{
_fakeIndexerDefinition = new IndexerDefinition
{
Tags = new HashSet<int>()
};
Mocker
.GetMock<IIndexerRepository>()
.Setup(m => m.Get(It.IsAny<int>()))
.Returns(_fakeIndexerDefinition);
_specification = Mocker.Resolve<IndexerTagSpecification>();
_fakeMovie = Builder<Movie>.CreateNew()
.With(c => c.Monitored = true)
.With(c => c.Tags = new HashSet<int>())
.Build();
_fakeRelease = new ReleaseInfo
{
IndexerId = 1
};
_parseResultMulti = new RemoteMovie
{
Movie = _fakeMovie,
Release = _fakeRelease
};
}
[Test]
public void indexer_and_movie_without_tags_should_return_true()
{
_fakeIndexerDefinition.Tags = new HashSet<int>();
_fakeMovie.Tags = new HashSet<int>();
_specification.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeTrue();
}
[Test]
public void indexer_with_tags_movie_without_tags_should_return_false()
{
_fakeIndexerDefinition.Tags = new HashSet<int> { 123 };
_fakeMovie.Tags = new HashSet<int>();
_specification.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeFalse();
}
[Test]
public void indexer_without_tags_movie_with_tags_should_return_true()
{
_fakeIndexerDefinition.Tags = new HashSet<int>();
_fakeMovie.Tags = new HashSet<int> { 123 };
_specification.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeTrue();
}
[Test]
public void indexer_with_tags_movie_with_matching_tags_should_return_true()
{
_fakeIndexerDefinition.Tags = new HashSet<int> { 123, 456 };
_fakeMovie.Tags = new HashSet<int> { 123, 789 };
_specification.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeTrue();
}
[Test]
public void indexer_with_tags_movie_with_different_tags_should_return_false()
{
_fakeIndexerDefinition.Tags = new HashSet<int> { 456 };
_fakeMovie.Tags = new HashSet<int> { 123, 789 };
_specification.IsSatisfiedBy(_parseResultMulti, new MovieSearchCriteria()).Accepted.Should().BeFalse();
}
}
}

@ -0,0 +1,14 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(198)]
public class add_indexer_tags : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("Indexers").AddColumn("Tags").AsString().Nullable();
}
}
}

@ -73,8 +73,7 @@ namespace NzbDrone.Core.Datastore
.Ignore(i => i.Enable) .Ignore(i => i.Enable)
.Ignore(i => i.Protocol) .Ignore(i => i.Protocol)
.Ignore(i => i.SupportsRss) .Ignore(i => i.SupportsRss)
.Ignore(i => i.SupportsSearch) .Ignore(i => i.SupportsSearch);
.Ignore(d => d.Tags);
Mapper.Entity<ImportListDefinition>("ImportLists").RegisterModel() Mapper.Entity<ImportListDefinition>("ImportLists").RegisterModel()
.Ignore(x => x.ImplementationName) .Ignore(x => x.ImplementationName)

@ -0,0 +1,39 @@
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{
public class IndexerTagSpecification : IDecisionEngineSpecification
{
private readonly Logger _logger;
private readonly IIndexerRepository _indexerRepository;
public IndexerTagSpecification(Logger logger, IIndexerRepository indexerRepository)
{
_logger = logger;
_indexerRepository = indexerRepository;
}
public SpecificationPriority Priority => SpecificationPriority.Default;
public RejectionType Type => RejectionType.Permanent;
public virtual Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
{
// If indexer has tags, check that at least one of them is present on the series
var indexerTags = _indexerRepository.Get(subject.Release.IndexerId).Tags;
if (indexerTags.Any() && indexerTags.Intersect(subject.Movie.Tags).Empty())
{
_logger.Debug("Indexer {0} has tags. None of these are present on movie {1}. Rejecting", subject.Release.Indexer, subject.Movie);
return Decision.Reject("Movie tags do not match any of the indexer tags");
}
return Decision.Accept();
}
}
}

@ -102,6 +102,9 @@ namespace NzbDrone.Core.IndexerSearch
_indexerFactory.InteractiveSearchEnabled() : _indexerFactory.InteractiveSearchEnabled() :
_indexerFactory.AutomaticSearchEnabled(); _indexerFactory.AutomaticSearchEnabled();
// Filter indexers to untagged indexers and indexers with intersecting tags
indexers = indexers.Where(i => i.Definition.Tags.Empty() || i.Definition.Tags.Intersect(criteriaBase.Movie.Tags).Any()).ToList();
var reports = new List<ReleaseInfo>(); var reports = new List<ReleaseInfo>();
_logger.ProgressInfo("Searching indexers for {0}. {1} active indexers", criteriaBase, indexers.Count); _logger.ProgressInfo("Searching indexers for {0}. {1} active indexers", criteriaBase, indexers.Count);

@ -433,6 +433,7 @@
"IndexersSettingsSummary": "Indexers and release restrictions", "IndexersSettingsSummary": "Indexers and release restrictions",
"IndexerStatusCheckAllClientMessage": "All indexers are unavailable due to failures", "IndexerStatusCheckAllClientMessage": "All indexers are unavailable due to failures",
"IndexerStatusCheckSingleClientMessage": "Indexers unavailable due to failures: {0}", "IndexerStatusCheckSingleClientMessage": "Indexers unavailable due to failures: {0}",
"IndexerTagHelpText": "Only use this indexer for series with at least one matching tag. Leave blank to use with all movies.",
"Info": "Info", "Info": "Info",
"InstallLatest": "Install Latest", "InstallLatest": "Install Latest",
"InteractiveImport": "Interactive Import", "InteractiveImport": "Interactive Import",

@ -12,12 +12,13 @@ namespace NzbDrone.Core.Tags
public List<int> RestrictionIds { get; set; } public List<int> RestrictionIds { get; set; }
public List<int> ImportListIds { get; set; } public List<int> ImportListIds { get; set; }
public List<int> DelayProfileIds { get; set; } public List<int> DelayProfileIds { get; set; }
public List<int> IndexerIds { get; set; }
public bool InUse public bool InUse
{ {
get get
{ {
return MovieIds.Any() || NotificationIds.Any() || RestrictionIds.Any() || DelayProfileIds.Any(); return MovieIds.Any() || NotificationIds.Any() || RestrictionIds.Any() || DelayProfileIds.Any() || ImportListIds.Any() || IndexerIds.Any();
} }
} }
} }

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.ImportLists; using NzbDrone.Core.ImportLists;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies; using NzbDrone.Core.Movies;
using NzbDrone.Core.Notifications; using NzbDrone.Core.Notifications;
@ -32,6 +33,7 @@ namespace NzbDrone.Core.Tags
private readonly INotificationFactory _notificationFactory; private readonly INotificationFactory _notificationFactory;
private readonly IRestrictionService _restrictionService; private readonly IRestrictionService _restrictionService;
private readonly IMovieService _movieService; private readonly IMovieService _movieService;
private readonly IIndexerFactory _indexerService;
public TagService(ITagRepository repo, public TagService(ITagRepository repo,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
@ -39,7 +41,8 @@ namespace NzbDrone.Core.Tags
IImportListFactory importListFactory, IImportListFactory importListFactory,
INotificationFactory notificationFactory, INotificationFactory notificationFactory,
IRestrictionService restrictionService, IRestrictionService restrictionService,
IMovieService movieService) IMovieService movieService,
IIndexerFactory indexerService)
{ {
_repo = repo; _repo = repo;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
@ -48,6 +51,7 @@ namespace NzbDrone.Core.Tags
_notificationFactory = notificationFactory; _notificationFactory = notificationFactory;
_restrictionService = restrictionService; _restrictionService = restrictionService;
_movieService = movieService; _movieService = movieService;
_indexerService = indexerService;
} }
public Tag GetTag(int tagId) public Tag GetTag(int tagId)
@ -80,6 +84,7 @@ namespace NzbDrone.Core.Tags
var notifications = _notificationFactory.AllForTag(tagId); var notifications = _notificationFactory.AllForTag(tagId);
var restrictions = _restrictionService.AllForTag(tagId); var restrictions = _restrictionService.AllForTag(tagId);
var movies = _movieService.AllMovieTags().Where(x => x.Value.Contains(tagId)).Select(x => x.Key).ToList(); var movies = _movieService.AllMovieTags().Where(x => x.Value.Contains(tagId)).Select(x => x.Key).ToList();
var indexers = _indexerService.AllForTag(tagId);
return new TagDetails return new TagDetails
{ {
@ -89,7 +94,8 @@ namespace NzbDrone.Core.Tags
ImportListIds = importLists.Select(c => c.Id).ToList(), ImportListIds = importLists.Select(c => c.Id).ToList(),
NotificationIds = notifications.Select(c => c.Id).ToList(), NotificationIds = notifications.Select(c => c.Id).ToList(),
RestrictionIds = restrictions.Select(c => c.Id).ToList(), RestrictionIds = restrictions.Select(c => c.Id).ToList(),
MovieIds = movies MovieIds = movies,
IndexerIds = indexers.Select(c => c.Id).ToList()
}; };
} }
@ -101,6 +107,7 @@ namespace NzbDrone.Core.Tags
var notifications = _notificationFactory.All(); var notifications = _notificationFactory.All();
var restrictions = _restrictionService.All(); var restrictions = _restrictionService.All();
var movies = _movieService.AllMovieTags(); var movies = _movieService.AllMovieTags();
var indexers = _indexerService.All();
var details = new List<TagDetails>(); var details = new List<TagDetails>();
@ -114,7 +121,8 @@ namespace NzbDrone.Core.Tags
ImportListIds = importLists.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), ImportListIds = importLists.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), NotificationIds = notifications.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(), RestrictionIds = restrictions.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList(),
MovieIds = movies.Where(c => c.Value.Contains(tag.Id)).Select(c => c.Key).ToList() MovieIds = movies.Where(c => c.Value.Contains(tag.Id)).Select(c => c.Key).ToList(),
IndexerIds = indexers.Where(c => c.Tags.Contains(tag.Id)).Select(c => c.Id).ToList()
}); });
} }

@ -13,6 +13,7 @@ namespace Radarr.Api.V3.Tags
public List<int> RestrictionIds { get; set; } public List<int> RestrictionIds { get; set; }
public List<int> ImportListIds { get; set; } public List<int> ImportListIds { get; set; }
public List<int> MovieIds { get; set; } public List<int> MovieIds { get; set; }
public List<int> IndexerIds { get; set; }
} }
public static class TagDetailsResourceMapper public static class TagDetailsResourceMapper
@ -32,7 +33,8 @@ namespace Radarr.Api.V3.Tags
NotificationIds = model.NotificationIds, NotificationIds = model.NotificationIds,
RestrictionIds = model.RestrictionIds, RestrictionIds = model.RestrictionIds,
ImportListIds = model.ImportListIds, ImportListIds = model.ImportListIds,
MovieIds = model.MovieIds MovieIds = model.MovieIds,
IndexerIds = model.IndexerIds
}; };
} }

Loading…
Cancel
Save