diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs
index aba22a1f2..e6c58a658 100644
--- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs
+++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsApi.cs
@@ -20,7 +20,7 @@ namespace NzbDrone.Core.Indexers.HDBits
public int[] Medium { get; set; }
- public int[] Origin { get; set; }
+ public int Origin { get; set; }
[JsonProperty(PropertyName = "imdb")]
public ImdbInfo ImdbInfo { get; set; }
diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs
new file mode 100644
index 000000000..74c866309
--- /dev/null
+++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsInfo.cs
@@ -0,0 +1,13 @@
+using NzbDrone.Core.Parser.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NzbDrone.Core.Indexers.HDBits
+{
+ public class HDBitsInfo : TorrentInfo
+ {
+ public bool? Internal { get; set; }
+ }
+}
diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs
index 0a183ff77..ebf9b4e2d 100644
--- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs
+++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsParser.cs
@@ -5,6 +5,7 @@ using Newtonsoft.Json.Linq;
using NzbDrone.Common.Http;
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser.Model;
+using System.Linq;
namespace NzbDrone.Core.Indexers.HDBits
{
@@ -50,7 +51,7 @@ namespace NzbDrone.Core.Indexers.HDBits
foreach (var result in queryResults)
{
var id = result.Id;
- torrentInfos.Add(new TorrentInfo()
+ torrentInfos.Add(new HDBitsInfo()
{
Guid = string.Format("HDBits-{0}", id),
Title = result.Name,
@@ -60,11 +61,25 @@ namespace NzbDrone.Core.Indexers.HDBits
InfoUrl = GetInfoUrl(id),
Seeders = result.Seeders,
Peers = result.Leechers + result.Seeders,
- PublishDate = result.Added.ToUniversalTime()
+ PublishDate = result.Added.ToUniversalTime(),
+ Internal = (result.TypeOrigin == 1 ? true : false)
});
}
- return torrentInfos.ToArray();
+ // order by internal
+ if (_settings.PreferInternal)
+ {
+ return
+ torrentInfos.OrderByDescending(o => o.PublishDate)
+ .ThenBy(o => ((dynamic)o).Internal ? 0 : 1)
+ .ToArray();
+ }
+
+ // order by date
+ return
+ torrentInfos
+ .OrderByDescending(o => o.PublishDate)
+ .ToArray();
}
private string GetDownloadUrl(string torrentId)
diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs
index cd1ff7ccb..555652a39 100644
--- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs
+++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsRequestGenerator.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using NzbDrone.Common.Http;
using NzbDrone.Common.Serializer;
@@ -13,37 +13,10 @@ namespace NzbDrone.Core.Indexers.HDBits
public virtual IndexerPageableRequestChain GetRecentRequests()
{
var pageableRequests = new IndexerPageableRequestChain();
-
pageableRequests.Add(GetRequest(new TorrentQuery()));
-
return pageableRequests;
}
- public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria)
- {
- return new IndexerPageableRequestChain();
- }
-
- public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
- {
- return new IndexerPageableRequestChain();
- }
-
- public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
- {
- return new IndexerPageableRequestChain();
- }
-
- public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria)
- {
- return new IndexerPageableRequestChain();
- }
-
- public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
- {
- return new IndexerPageableRequestChain();
- }
-
public virtual IndexerPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria)
{
var pageableRequests = new IndexerPageableRequestChain();
@@ -86,9 +59,40 @@ namespace NzbDrone.Core.Indexers.HDBits
query.Username = Settings.Username;
query.Passkey = Settings.ApiKey;
+ // Require Internal only if came from RSS sync
+ if (Settings.RequireInternal && query.ImdbInfo == null)
+ {
+ query.Origin = 1;
+ }
+
request.SetContent(query.ToJson());
yield return new IndexerRequest(request);
}
+
+ public virtual IndexerPageableRequestChain GetSearchRequests(AnimeEpisodeSearchCriteria searchCriteria)
+ {
+ return new IndexerPageableRequestChain();
+ }
+
+ public virtual IndexerPageableRequestChain GetSearchRequests(SpecialEpisodeSearchCriteria searchCriteria)
+ {
+ return new IndexerPageableRequestChain();
+ }
+
+ public virtual IndexerPageableRequestChain GetSearchRequests(DailyEpisodeSearchCriteria searchCriteria)
+ {
+ return new IndexerPageableRequestChain();
+ }
+
+ public virtual IndexerPageableRequestChain GetSearchRequests(SeasonSearchCriteria searchCriteria)
+ {
+ return new IndexerPageableRequestChain();
+ }
+
+ public virtual IndexerPageableRequestChain GetSearchRequests(SingleEpisodeSearchCriteria searchCriteria)
+ {
+ return new IndexerPageableRequestChain();
+ }
}
}
\ No newline at end of file
diff --git a/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs b/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs
index 933a134d2..62bea2a68 100644
--- a/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs
+++ b/src/NzbDrone.Core/Indexers/HDBits/HDBitsSettings.cs
@@ -32,6 +32,12 @@ namespace NzbDrone.Core.Indexers.HDBits
[FieldDefinition(2, Label = "API URL", Advanced = true, HelpText = "Do not change this unless you know what you're doing. Since your API key will be sent to that host.")]
public string BaseUrl { get; set; }
+ [FieldDefinition(3, Label = "Prefer Internal", Type = FieldType.Checkbox, HelpText = "Favors Internal releases over all other releases.")]
+ public bool PreferInternal { get; set; }
+
+ [FieldDefinition(4, Label = "Require Internal", Type = FieldType.Checkbox, HelpText = "Require Internal releases for release to be accepted.")]
+ public bool RequireInternal { get; set; }
+
public NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj
index f48652612..a2befbe20 100644
--- a/src/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/src/NzbDrone.Core/NzbDrone.Core.csproj
@@ -129,6 +129,7 @@
+