Skip to content

Commit

Permalink
New: Seed Settings Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Qstick committed May 11, 2022
1 parent af50a1d commit e90a796
Show file tree
Hide file tree
Showing 29 changed files with 288 additions and 24 deletions.
2 changes: 1 addition & 1 deletion frontend/src/Indexer/Edit/EditIndexerModalContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function EditIndexerModalContent(props) {
</FormGroup>

<FormGroup>
<FormLabel>{translate('AppProfile')}</FormLabel>
<FormLabel>{translate('SyncProfile')}</FormLabel>

<FormInputGroup
type={inputTypes.APP_PROFILE_SELECT}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Indexer/Editor/IndexerEditorFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class IndexerEditorFooter extends Component {

<div className={styles.inputContainer}>
<IndexerEditorFooterLabel
label={translate('AppProfile')}
label={translate('SyncProfile')}
isSaving={isSaving && appProfileId !== NO_CHANGE}
/>

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Indexer/Index/Menus/IndexerIndexSortMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function IndexerIndexSortMenu(props) {
sortDirection={sortDirection}
onPress={onSortSelect}
>
{translate('AppProfile')}
{translate('SyncProfile')}
</SortMenuItem>

<SortMenuItem
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Settings/Profiles/App/AppProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AppProfiles extends Component {
} = this.props;

return (
<FieldSet legend={translate('AppProfiles')}>
<FieldSet legend={translate('SyncProfiles')}>
<PageSectionContent
errorMessage={translate('UnableToLoadAppProfiles')}
{...otherProps}c={true}
Expand Down
19 changes: 17 additions & 2 deletions frontend/src/Settings/Profiles/App/EditAppProfileModalContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ class EditAppProfileModalContent extends Component {
name,
enableRss,
enableInteractiveSearch,
enableAutomaticSearch
enableAutomaticSearch,
minimumSeeders
} = item;

return (
<ModalContent onModalClose={onModalClose}>

<ModalHeader>
{id ? translate('EditAppProfile') : translate('AddAppProfile')}
{id ? translate('EditSyncProfile') : translate('AddSyncProfile')}
</ModalHeader>

<ModalBody>
Expand Down Expand Up @@ -123,6 +124,20 @@ class EditAppProfileModalContent extends Component {
onChange={onInputChange}
/>
</FormGroup>

<FormGroup>
<FormLabel>
{translate('MinimumSeeders')}
</FormLabel>

<FormInputGroup
type={inputTypes.NUMBER}
name="minimumSeeders"
{...minimumSeeders}
helpText={translate('MinimumSeedersHelpText')}
onChange={onInputChange}
/>
</FormGroup>
</Form>
}
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Store/Actions/indexerIndexActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const defaultState = {
},
{
name: 'appProfileId',
label: translate('AppProfile'),
label: translate('SyncProfile'),
isSortable: true,
isVisible: true
},
Expand Down Expand Up @@ -152,7 +152,7 @@ export const defaultState = {
},
{
name: 'appProfileId',
label: translate('AppProfile'),
label: translate('SyncProfile'),
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.APP_PROFILE
},
Expand Down
6 changes: 6 additions & 0 deletions src/NzbDrone.Common/Cloud/ProwlarrCloudRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace NzbDrone.Common.Cloud
public interface IProwlarrCloudRequestBuilder
{
IHttpRequestBuilderFactory Services { get; }
IHttpRequestBuilderFactory Releases { get; }
}

public class ProwlarrCloudRequestBuilder : IProwlarrCloudRequestBuilder
Expand All @@ -13,8 +14,13 @@ public ProwlarrCloudRequestBuilder()
{
Services = new HttpRequestBuilder("https://prowlarr.servarr.com/v1/")
.CreateFactory();

Releases = new HttpRequestBuilder("https://releases.servarr.com/v1/")
.CreateFactory();
}

public IHttpRequestBuilderFactory Services { get; private set; }

public IHttpRequestBuilderFactory Releases { get; private set; }
}
}
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Applications/Lidarr/Lidarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ private LidarrIndexer BuildLidarrIndexer(IndexerDefinition indexer, DownloadProt
lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey;
lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()));

if (indexer.Protocol == DownloadProtocol.Torrent)
{
lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = indexer.AppProfile.Value.MinimumSeeders;
lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio;
lidarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;
}

return lidarrIndexer;
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/NzbDrone.Core/Applications/Lidarr/LidarrIndexer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -31,14 +32,26 @@ public bool Equals(LidarrIndexer other)
var apiKey = (string)Fields.FirstOrDefault(x => x.Name == "apiKey").Value == (string)other.Fields.FirstOrDefault(x => x.Name == "apiKey").Value;
var cats = JToken.DeepEquals((JArray)Fields.FirstOrDefault(x => x.Name == "categories").Value, (JArray)other.Fields.FirstOrDefault(x => x.Name == "categories").Value);

var minimumSeeders = Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var otherMinimumSeeders = other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var minimumSeedersCompare = minimumSeeders == otherMinimumSeeders;

var seedTime = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var otherSeedTime = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var seedTimeCompare = seedTime == otherSeedTime;

var seedRatio = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var otherSeedRatio = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var seedRatioCompare = seedRatio == otherSeedRatio;

return other.EnableRss == EnableRss &&
other.EnableAutomaticSearch == EnableAutomaticSearch &&
other.EnableInteractiveSearch == EnableInteractiveSearch &&
other.Name == Name &&
other.Implementation == Implementation &&
other.Priority == Priority &&
other.Id == Id &&
apiKey && apiPath && baseUrl && cats;
apiKey && apiPath && baseUrl && cats && minimumSeedersCompare && seedRatioCompare && seedTimeCompare;
}
}
}
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Applications/Radarr/Radarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ private RadarrIndexer BuildRadarrIndexer(IndexerDefinition indexer, DownloadProt
radarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey;
radarrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()));

if (indexer.Protocol == DownloadProtocol.Torrent)
{
radarrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = indexer.AppProfile.Value.MinimumSeeders;
radarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio;
radarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;
}

return radarrIndexer;
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/NzbDrone.Core/Applications/Radarr/RadarrIndexer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -31,14 +32,26 @@ public bool Equals(RadarrIndexer other)
var apiKey = (string)Fields.FirstOrDefault(x => x.Name == "apiKey").Value == (string)other.Fields.FirstOrDefault(x => x.Name == "apiKey").Value;
var cats = JToken.DeepEquals((JArray)Fields.FirstOrDefault(x => x.Name == "categories").Value, (JArray)other.Fields.FirstOrDefault(x => x.Name == "categories").Value);

var minimumSeeders = Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var otherMinimumSeeders = other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var minimumSeedersCompare = minimumSeeders == otherMinimumSeeders;

var seedTime = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var otherSeedTime = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var seedTimeCompare = seedTime == otherSeedTime;

var seedRatio = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var otherSeedRatio = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var seedRatioCompare = seedRatio == otherSeedRatio;

return other.EnableRss == EnableRss &&
other.EnableAutomaticSearch == EnableAutomaticSearch &&
other.EnableInteractiveSearch == EnableInteractiveSearch &&
other.Name == Name &&
other.Implementation == Implementation &&
other.Priority == Priority &&
other.Id == Id &&
apiKey && apiPath && baseUrl && cats;
apiKey && apiPath && baseUrl && cats && minimumSeedersCompare && seedRatioCompare && seedTimeCompare;
}
}
}
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Applications/Readarr/Readarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ private ReadarrIndexer BuildReadarrIndexer(IndexerDefinition indexer, DownloadPr
readarrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey;
readarrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()));

if (indexer.Protocol == DownloadProtocol.Torrent)
{
readarrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = indexer.AppProfile.Value.MinimumSeeders;
readarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio;
readarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;
}

return readarrIndexer;
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/NzbDrone.Core/Applications/Readarr/ReadarrIndexer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -31,14 +32,26 @@ public bool Equals(ReadarrIndexer other)
var apiKey = (string)Fields.FirstOrDefault(x => x.Name == "apiKey").Value == (string)other.Fields.FirstOrDefault(x => x.Name == "apiKey").Value;
var cats = JToken.DeepEquals((JArray)Fields.FirstOrDefault(x => x.Name == "categories").Value, (JArray)other.Fields.FirstOrDefault(x => x.Name == "categories").Value);

var minimumSeeders = Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var otherMinimumSeeders = other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var minimumSeedersCompare = minimumSeeders == otherMinimumSeeders;

var seedTime = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var otherSeedTime = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var seedTimeCompare = seedTime == otherSeedTime;

var seedRatio = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var otherSeedRatio = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var seedRatioCompare = seedRatio == otherSeedRatio;

return other.EnableRss == EnableRss &&
other.EnableAutomaticSearch == EnableAutomaticSearch &&
other.EnableInteractiveSearch == EnableInteractiveSearch &&
other.Name == Name &&
other.Implementation == Implementation &&
other.Priority == Priority &&
other.Id == Id &&
apiKey && apiPath && baseUrl && cats;
apiKey && apiPath && baseUrl && cats && minimumSeedersCompare && seedRatioCompare && seedTimeCompare;
}
}
}
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ private SonarrIndexer BuildSonarrIndexer(IndexerDefinition indexer, DownloadProt
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()));
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "animeCategories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.AnimeSyncCategories.ToArray()));

if (indexer.Protocol == DownloadProtocol.Torrent)
{
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = indexer.AppProfile.Value.MinimumSeeders;
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio;
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;
}

return sonarrIndexer;
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/NzbDrone.Core/Applications/Sonarr/SonarrIndexer.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -32,14 +33,26 @@ public bool Equals(SonarrIndexer other)
var cats = JToken.DeepEquals((JArray)Fields.FirstOrDefault(x => x.Name == "categories").Value, (JArray)other.Fields.FirstOrDefault(x => x.Name == "categories").Value);
var animeCats = JToken.DeepEquals((JArray)Fields.FirstOrDefault(x => x.Name == "animeCategories").Value, (JArray)other.Fields.FirstOrDefault(x => x.Name == "animeCategories").Value);

var minimumSeeders = Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var otherMinimumSeeders = other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value);
var minimumSeedersCompare = minimumSeeders == otherMinimumSeeders;

var seedTime = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var otherSeedTime = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime")?.Value == null ? null : (int?)Convert.ToInt32(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value);
var seedTimeCompare = seedTime == otherSeedTime;

var seedRatio = Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var otherSeedRatio = other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio")?.Value == null ? null : (double?)Convert.ToDouble(other.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value);
var seedRatioCompare = seedRatio == otherSeedRatio;

return other.EnableRss == EnableRss &&
other.EnableAutomaticSearch == EnableAutomaticSearch &&
other.EnableInteractiveSearch == EnableInteractiveSearch &&
other.Name == Name &&
other.Implementation == Implementation &&
other.Priority == Priority &&
other.Id == Id &&
apiKey && apiPath && baseUrl && cats && animeCats;
apiKey && apiPath && baseUrl && cats && animeCats && minimumSeedersCompare && seedRatioCompare && seedTimeCompare;
}
}
}
7 changes: 7 additions & 0 deletions src/NzbDrone.Core/Applications/Whisparr/Whisparr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ private WhisparrIndexer BuildWhisparrIndexer(IndexerDefinition indexer, Download
whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "apiKey").Value = _configFileProvider.ApiKey;
whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "categories").Value = JArray.FromObject(indexer.Capabilities.Categories.SupportedCategories(Settings.SyncCategories.ToArray()));

if (indexer.Protocol == DownloadProtocol.Torrent)
{
whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = indexer.AppProfile.Value.MinimumSeeders;
whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedRatio").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedRatio;
whisparrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;
}

return whisparrIndexer;
}
}
Expand Down

0 comments on commit e90a796

Please sign in to comment.