mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-05-09 05:22:09 +02:00
Fixed: (TorrentDay) Add freeleech only setting
This commit is contained in:
parent
a0d11e7e33
commit
edf9473e9a
2 changed files with 44 additions and 25 deletions
|
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(026)]
|
||||
public class torrentday_cookiesettings_to_torrentdaysettings : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Update.Table("Indexers").Set(new { ConfigContract = "TorrentDaySettings" }).Where(new { Implementation = "TorrentDay" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using FluentValidation;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
|
@ -13,15 +12,13 @@
|
|||
using NzbDrone.Core.Messaging.Events;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Validation;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.Definitions
|
||||
{
|
||||
public class TorrentDay : TorrentIndexerBase<CookieTorrentBaseSettings>
|
||||
public class TorrentDay : TorrentIndexerBase<TorrentDaySettings>
|
||||
{
|
||||
public override string Name => "TorrentDay";
|
||||
|
||||
public override string[] IndexerUrls => new string[]
|
||||
public override string[] IndexerUrls => new[]
|
||||
{
|
||||
"https://torrentday.cool/",
|
||||
"https://tday.love/",
|
||||
|
|
@ -46,7 +43,7 @@ public TorrentDay(IIndexerHttpClient httpClient, IEventAggregator eventAggregato
|
|||
|
||||
public override IIndexerRequestGenerator GetRequestGenerator()
|
||||
{
|
||||
return new TorrentDayRequestGenerator() { Settings = Settings, Capabilities = Capabilities };
|
||||
return new TorrentDayRequestGenerator { Settings = Settings, Capabilities = Capabilities };
|
||||
}
|
||||
|
||||
public override IParseIndexerResponse GetParser()
|
||||
|
|
@ -64,21 +61,21 @@ private IndexerCapabilities SetCapabilities()
|
|||
var caps = new IndexerCapabilities
|
||||
{
|
||||
TvSearchParams = new List<TvSearchParam>
|
||||
{
|
||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
|
||||
},
|
||||
{
|
||||
TvSearchParam.Q, TvSearchParam.Season, TvSearchParam.Ep, TvSearchParam.ImdbId
|
||||
},
|
||||
MovieSearchParams = new List<MovieSearchParam>
|
||||
{
|
||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||
},
|
||||
{
|
||||
MovieSearchParam.Q, MovieSearchParam.ImdbId
|
||||
},
|
||||
MusicSearchParams = new List<MusicSearchParam>
|
||||
{
|
||||
MusicSearchParam.Q
|
||||
},
|
||||
{
|
||||
MusicSearchParam.Q
|
||||
},
|
||||
BookSearchParams = new List<BookSearchParam>
|
||||
{
|
||||
BookSearchParam.Q
|
||||
}
|
||||
{
|
||||
BookSearchParam.Q
|
||||
}
|
||||
};
|
||||
|
||||
caps.Categories.AddCategoryMapping(29, NewznabStandardCategory.TVAnime, "Anime");
|
||||
|
|
@ -135,13 +132,9 @@ private IndexerCapabilities SetCapabilities()
|
|||
|
||||
public class TorrentDayRequestGenerator : IIndexerRequestGenerator
|
||||
{
|
||||
public CookieTorrentBaseSettings Settings { get; set; }
|
||||
public TorrentDaySettings Settings { get; set; }
|
||||
public IndexerCapabilities Capabilities { get; set; }
|
||||
|
||||
public TorrentDayRequestGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
private IEnumerable<IndexerRequest> GetPagedRequests(string term, int[] categories, string imdbId = null)
|
||||
{
|
||||
var searchUrl = Settings.BaseUrl + "t.json";
|
||||
|
|
@ -154,6 +147,12 @@ private IEnumerable<IndexerRequest> GetPagedRequests(string term, int[] categori
|
|||
|
||||
var catStr = string.Join(";", cats);
|
||||
searchUrl = searchUrl + "?" + catStr;
|
||||
|
||||
if (Settings.FreeLeechOnly)
|
||||
{
|
||||
searchUrl += ";free";
|
||||
}
|
||||
|
||||
searchUrl += ";q=";
|
||||
|
||||
if (imdbId.IsNotNullOrWhiteSpace())
|
||||
|
|
@ -219,10 +218,10 @@ public IndexerPageableRequestChain GetSearchRequests(BasicSearchCriteria searchC
|
|||
|
||||
public class TorrentDayParser : IParseIndexerResponse
|
||||
{
|
||||
private readonly CookieTorrentBaseSettings _settings;
|
||||
private readonly TorrentDaySettings _settings;
|
||||
private readonly IndexerCapabilitiesCategories _categories;
|
||||
|
||||
public TorrentDayParser(CookieTorrentBaseSettings settings, IndexerCapabilitiesCategories categories)
|
||||
public TorrentDayParser(TorrentDaySettings settings, IndexerCapabilitiesCategories categories)
|
||||
{
|
||||
_settings = settings;
|
||||
_categories = categories;
|
||||
|
|
@ -275,4 +274,10 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
|
||||
public Action<IDictionary<string, string>, DateTime?> CookiesUpdater { get; set; }
|
||||
}
|
||||
|
||||
public class TorrentDaySettings : CookieTorrentBaseSettings
|
||||
{
|
||||
[FieldDefinition(3, Label = "FreeLeech Only", Type = FieldType.Checkbox, HelpText = "Search Freeleech torrents only")]
|
||||
public bool FreeLeechOnly { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue