Skip to content

Commit

Permalink
fix: remove newznab references (#21)
Browse files Browse the repository at this point in the history
* Remove references to newznab

* Remove newznab

* Remove fields that aren't used anyway
  • Loading branch information
Thundernerd authored May 12, 2024
1 parent 099e5eb commit eba484e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 25 deletions.
26 changes: 5 additions & 21 deletions src/NzbDrone.Core/Applications/Sonarr/Sonarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override ValidationResult Test()
{
Id = 0,
Name = "Test",
Protocol = DownloadProtocol.Usenet,
Protocol = DownloadProtocol.Torrent,
Capabilities = new IndexerCapabilities()
};

Expand All @@ -51,7 +51,7 @@ public override ValidationResult Test()

try
{
failures.AddIfNotNull(_sonarrV3Proxy.TestConnection(BuildSonarrIndexer(testIndexer, testIndexer.Capabilities, DownloadProtocol.Usenet), Settings));
failures.AddIfNotNull(_sonarrV3Proxy.TestConnection(BuildSonarrIndexer(testIndexer, testIndexer.Capabilities, DownloadProtocol.Torrent), Settings));
}
catch (HttpException ex)
{
Expand Down Expand Up @@ -96,7 +96,7 @@ public override ValidationResult Test()
public override List<AppIndexerMap> GetIndexerMappings()
{
var indexers = _sonarrV3Proxy.GetIndexers(Settings)
.Where(i => i.Implementation is "Newznab" or "Torznab");
.Where(i => i.Implementation is "Torznab");

var mappings = new List<AppIndexerMap>();

Expand Down Expand Up @@ -237,10 +237,7 @@ private SonarrIndexer BuildSonarrIndexer(IndexerDefinition indexer, IndexerCapab
syncFields.AddRange(new List<string> { "additionalParameters" });
}

var newznab = schemas.First(i => i.Implementation == "Newznab");
var torznab = schemas.First(i => i.Implementation == "Torznab");

var schema = protocol == DownloadProtocol.Usenet ? newznab : torznab;
var schema = schemas.First(i => i.Implementation == "Torznab");

var sonarrIndexer = new SonarrIndexer
{
Expand All @@ -250,7 +247,7 @@ private SonarrIndexer BuildSonarrIndexer(IndexerDefinition indexer, IndexerCapab
EnableAutomaticSearch = indexer.Enable && indexer.AppProfile.Value.EnableAutomaticSearch,
EnableInteractiveSearch = indexer.Enable && indexer.AppProfile.Value.EnableInteractiveSearch,
Priority = indexer.Priority,
Implementation = indexer.Protocol == DownloadProtocol.Usenet ? "Newznab" : "Torznab",
Implementation = "Torznab",
ConfigContract = schema.ConfigContract,
Fields = new List<SonarrField>(),
Tags = new HashSet<int>()
Expand All @@ -269,19 +266,6 @@ private SonarrIndexer BuildSonarrIndexer(IndexerDefinition indexer, IndexerCapab
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "animeStandardFormatSearch").Value = Settings.SyncAnimeStandardFormatSearch;
}

if (indexer.Protocol == DownloadProtocol.Torrent)
{
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "minimumSeeders").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.AppMinimumSeeders ?? 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;
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "seedCriteria.seasonPackSeedTime").Value = ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.PackSeedTime ?? ((ITorrentIndexerSettings)indexer.Settings).TorrentBaseSettings.SeedTime;

if (sonarrIndexer.Fields.Any(x => x.Name == "rejectBlocklistedTorrentHashesWhileGrabbing"))
{
sonarrIndexer.Fields.FirstOrDefault(x => x.Name == "rejectBlocklistedTorrentHashesWhileGrabbing").Value = Settings.SyncRejectBlocklistedTorrentHashesWhileGrabbing;
}
}

return sonarrIndexer;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/NzbDrone.Core/IndexerSearch/ReleaseSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ private async Task<IList<ReleaseInfo>> Dispatch(Func<IIndexer, Task<IndexerPagea
if (criteriaBase.IndexerIds is { Count: > 0 })
{
indexers = indexers.Where(i => criteriaBase.IndexerIds.Contains(i.Definition.Id) ||
(criteriaBase.IndexerIds.Contains(-1) && i.Protocol == DownloadProtocol.Usenet) ||
(criteriaBase.IndexerIds.Contains(-2) && i.Protocol == DownloadProtocol.Torrent))
.ToList();

Expand Down
1 change: 0 additions & 1 deletion src/NzbDrone.Core/Indexers/DownloadProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public enum DownloadProtocol
{
Unknown = 0,
Usenet = 1,
Torrent = 2
}
}
3 changes: 2 additions & 1 deletion src/Prowlarr.Api.V1/Indexers/NewznabController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public async Task<IActionResult> GetNewznabResponse(int id, [FromQuery] NewznabR
}
};

return CreateResponse(results.ToXml(DownloadProtocol.Usenet));
// Sourcerarr: This is a hack, lol
return CreateResponse(results.ToXml(DownloadProtocol.Torrent));
}
}

Expand Down
1 change: 0 additions & 1 deletion src/Prowlarr.Api.V1/Search/ReleaseResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public string FileName
var extension = Protocol switch
{
DownloadProtocol.Torrent => ".torrent",
DownloadProtocol.Usenet => ".nzb",
_ => string.Empty
};

Expand Down

0 comments on commit eba484e

Please sign in to comment.