mirror of https://github.com/Jackett/Jackett
Merge branch 'master' of https://github.com/Jackett/Jackett
This commit is contained in:
commit
f96dca5653
|
@ -28,6 +28,11 @@ namespace JackettTest
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWebIndexer GetWebIndexer(string name)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InitIndexers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
|
@ -96,11 +96,25 @@ Global
|
|||
$2.SpacesBeforeBrackets = False
|
||||
$2.scope = text/x-csharp
|
||||
$2.IndentSwitchSection = True
|
||||
$2.NewLinesForBracesInProperties = True
|
||||
$2.NewLinesForBracesInAccessors = True
|
||||
$2.NewLinesForBracesInAnonymousMethods = True
|
||||
$2.NewLinesForBracesInControlBlocks = True
|
||||
$2.NewLinesForBracesInAnonymousTypes = True
|
||||
$2.NewLinesForBracesInObjectCollectionArrayInitializers = True
|
||||
$2.NewLinesForBracesInLambdaExpressionBody = True
|
||||
$2.NewLineForElse = True
|
||||
$2.NewLineForCatch = True
|
||||
$2.NewLineForFinally = True
|
||||
$2.NewLineForMembersInObjectInit = True
|
||||
$2.NewLineForMembersInAnonymousTypes = True
|
||||
$2.NewLineForClausesInQuery = True
|
||||
$2.SpacingAfterMethodDeclarationName = False
|
||||
$2.SpaceAfterMethodCallName = False
|
||||
$2.SpaceBeforeOpenSquareBracket = False
|
||||
$0.DotNetNamingPolicy = $3
|
||||
$3.DirectoryNamespaceAssociation = PrefixedHierarchical
|
||||
$0.StandardHeader = $4
|
||||
$0.TextStylePolicy = $3
|
||||
$3.FileWidth = 80
|
||||
$3.TabsToSpaces = True
|
||||
$3.scope = text/plain
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -39,24 +39,24 @@
|
|||
page: "search"
|
||||
q: "{{ .Query.Keywords}}"
|
||||
rows:
|
||||
selector: tr.tlistrow
|
||||
selector: tr.torrent-info
|
||||
fields:
|
||||
title:
|
||||
selector: td.tlistname a
|
||||
selector: td.tr-name a
|
||||
category:
|
||||
selector: td.tlisticon a
|
||||
selector: td.tr-cat div.nyaa-cat a
|
||||
attribute: href
|
||||
filters:
|
||||
- name: split
|
||||
args: [ "=", -1 ]
|
||||
details:
|
||||
selector: td.tlistname a
|
||||
selector: td.tr-name a
|
||||
attribute: href
|
||||
download:
|
||||
selector: a[title="Magnet Download"]
|
||||
selector: a[title="Magnet Link"]
|
||||
attribute: href
|
||||
size:
|
||||
selector: td.tlistsize
|
||||
selector: td.tr-size
|
||||
# seeders:
|
||||
# text: 0
|
||||
# seeders:
|
||||
|
|
|
@ -12,6 +12,7 @@ using Jackett.Utils.Clients;
|
|||
using AutoMapper;
|
||||
using Jackett.Models.IndexerConfig;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jackett.Indexers
|
||||
{
|
||||
|
@ -691,6 +692,8 @@ namespace Jackett.Indexers
|
|||
}
|
||||
|
||||
public override TorznabCapabilities TorznabCaps { get; protected set; }
|
||||
|
||||
[JsonConverter(typeof(EncodingJsonConverter))]
|
||||
public Encoding Encoding { get; protected set; }
|
||||
|
||||
private List<CategoryMapping> categoryMapping = new List<CategoryMapping>();
|
||||
|
|
|
@ -377,6 +377,7 @@
|
|||
<Compile Include="Indexers\Meta\ResultFilters.cs" />
|
||||
<Compile Include="Services\ImdbResolver.cs" />
|
||||
<Compile Include="Utils\Extensions.cs" />
|
||||
<Compile Include="Utils\JsonUtil.cs" />
|
||||
<Compile Include="Services\IndexerConfigurationService.cs" />
|
||||
<Compile Include="Models\IndexerDefinition.cs" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -18,68 +18,79 @@ namespace Jackett
|
|||
{
|
||||
public class JackettModule : Autofac.Module
|
||||
{
|
||||
protected override void Load (ContainerBuilder builder)
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
// Just register everything!
|
||||
var thisAssembly = typeof (JackettModule).Assembly;
|
||||
builder.RegisterAssemblyTypes (thisAssembly)
|
||||
.Except<IIndexer> ()
|
||||
.Except<IImdbResolver> ()
|
||||
.Except<OmdbResolver> ()
|
||||
.Except<IFallbackStrategyProvider> ()
|
||||
.Except<ImdbFallbackStrategyProvider> ()
|
||||
.Except<IFallbackStrategy> ()
|
||||
.Except<ImdbFallbackStrategy> ()
|
||||
.Except<IResultFilterProvider> ()
|
||||
.Except<ImdbTitleResultFilterProvider> ()
|
||||
.Except<IResultFilter> ()
|
||||
.Except<ImdbTitleResultFilterProvider> ()
|
||||
.Except<BaseMetaIndexer> ()
|
||||
.Except<AggregateIndexer> ()
|
||||
var thisAssembly = typeof(JackettModule).Assembly;
|
||||
builder.RegisterAssemblyTypes(thisAssembly)
|
||||
.Except<IIndexer>()
|
||||
.Except<IImdbResolver>()
|
||||
.Except<OmdbResolver>()
|
||||
.Except<IFallbackStrategyProvider>()
|
||||
.Except<ImdbFallbackStrategyProvider>()
|
||||
.Except<IFallbackStrategy>()
|
||||
.Except<ImdbFallbackStrategy>()
|
||||
.Except<IResultFilterProvider>()
|
||||
.Except<ImdbTitleResultFilterProvider>()
|
||||
.Except<IResultFilter>()
|
||||
.Except<ImdbTitleResultFilterProvider>()
|
||||
.Except<BaseMetaIndexer>()
|
||||
.Except<AggregateIndexer>()
|
||||
.Except<CardigannIndexer>()
|
||||
.AsImplementedInterfaces ().SingleInstance ();
|
||||
builder.RegisterApiControllers (thisAssembly).InstancePerRequest ();
|
||||
builder.RegisterType<HttpWebClient> ();
|
||||
.AsImplementedInterfaces().SingleInstance();
|
||||
builder.RegisterApiControllers(thisAssembly).InstancePerRequest();
|
||||
builder.RegisterType<HttpWebClient>();
|
||||
|
||||
// Register the best web client for the platform or the override
|
||||
switch (Startup.ClientOverride) {
|
||||
case "httpclient":
|
||||
builder.RegisterType<HttpWebClient> ().As<IWebClient> ();
|
||||
break;
|
||||
case "httpclient2":
|
||||
builder.RegisterType<HttpWebClient2> ().As<IWebClient> ();
|
||||
break;
|
||||
case "safecurl":
|
||||
builder.RegisterType<UnixSafeCurlWebClient> ().As<IWebClient> ();
|
||||
break;
|
||||
case "libcurl":
|
||||
builder.RegisterType<UnixLibCurlWebClient> ().As<IWebClient> ();
|
||||
break;
|
||||
case "automatic":
|
||||
default:
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix) {
|
||||
var usehttpclient = false;
|
||||
try {
|
||||
Type monotype = Type.GetType ("Mono.Runtime");
|
||||
if (monotype != null) {
|
||||
MethodInfo displayName = monotype.GetMethod ("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName != null) {
|
||||
var monoVersion = displayName.Invoke (null, null).ToString ();
|
||||
var monoVersionO = new Version (monoVersion.Split (' ') [0]);
|
||||
if ((monoVersionO.Major >= 4 && monoVersionO.Minor >= 8) || monoVersionO.Major >= 5) {
|
||||
// check if btls is supported
|
||||
var monoSecurity = Assembly.Load ("Mono.Security");
|
||||
Type monoTlsProviderFactory = monoSecurity.GetType ("Mono.Security.Interface.MonoTlsProviderFactory");
|
||||
if (monoTlsProviderFactory != null) {
|
||||
MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod ("IsProviderSupported");
|
||||
if (isProviderSupported != null) {
|
||||
var btlsSupported = (bool)isProviderSupported.Invoke (null, new string [] { "btls" });
|
||||
if (btlsSupported) {
|
||||
// initialize btls
|
||||
MethodInfo initialize = monoTlsProviderFactory.GetMethod ("Initialize", new [] { typeof (string) });
|
||||
if (initialize != null) {
|
||||
initialize.Invoke (null, new string [] { "btls" });
|
||||
usehttpclient = true;
|
||||
switch (Startup.ClientOverride)
|
||||
{
|
||||
case "httpclient":
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "httpclient2":
|
||||
builder.RegisterType<HttpWebClient2>().As<IWebClient>();
|
||||
break;
|
||||
case "safecurl":
|
||||
builder.RegisterType<UnixSafeCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "libcurl":
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
break;
|
||||
case "automatic":
|
||||
default:
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
var usehttpclient = false;
|
||||
try
|
||||
{
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null)
|
||||
{
|
||||
MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName != null)
|
||||
{
|
||||
var monoVersion = displayName.Invoke(null, null).ToString();
|
||||
var monoVersionO = new Version(monoVersion.Split(' ')[0]);
|
||||
if ((monoVersionO.Major >= 4 && monoVersionO.Minor >= 8) || monoVersionO.Major >= 5)
|
||||
{
|
||||
// check if btls is supported
|
||||
var monoSecurity = Assembly.Load("Mono.Security");
|
||||
Type monoTlsProviderFactory = monoSecurity.GetType("Mono.Security.Interface.MonoTlsProviderFactory");
|
||||
if (monoTlsProviderFactory != null)
|
||||
{
|
||||
MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod("IsProviderSupported");
|
||||
if (isProviderSupported != null)
|
||||
{
|
||||
var btlsSupported = (bool)isProviderSupported.Invoke(null, new string[] { "btls" });
|
||||
if (btlsSupported)
|
||||
{
|
||||
// initialize btls
|
||||
MethodInfo initialize = monoTlsProviderFactory.GetMethod("Initialize", new[] { typeof(string) });
|
||||
if (initialize != null)
|
||||
{
|
||||
initialize.Invoke(null, new string[] { "btls" });
|
||||
usehttpclient = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,45 +98,60 @@ namespace Jackett
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Console.Out.WriteLine ("Error while deciding which HttpWebClient to use: " + e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.Out.WriteLine("Error while deciding which HttpWebClient to use: " + e);
|
||||
}
|
||||
|
||||
if (usehttpclient)
|
||||
builder.RegisterType<HttpWebClient> ().As<IWebClient> ();
|
||||
if (usehttpclient)
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
else
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
}
|
||||
else
|
||||
builder.RegisterType<UnixLibCurlWebClient> ().As<IWebClient> ();
|
||||
} else {
|
||||
builder.RegisterType<HttpWebClient> ().As<IWebClient> ();
|
||||
}
|
||||
break;
|
||||
{
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Register indexers
|
||||
var indexerTypes = thisAssembly.GetTypes ().Where (p => typeof (IIndexer).IsAssignableFrom (p) && !p.IsInterface && !p.IsInNamespace ("Jackett.Indexers.Meta"));
|
||||
foreach (var indexer in indexerTypes) {
|
||||
builder.RegisterType (indexer).Named<IIndexer> (BaseIndexer.GetIndexerID (indexer));
|
||||
var allTypes = thisAssembly.GetTypes();
|
||||
var allIndexerTypes = allTypes.Where(p => typeof(IIndexer).IsAssignableFrom(p));
|
||||
var allInstantiatableIndexerTypes = allIndexerTypes.Where(p => !p.IsInterface && !p.IsAbstract);
|
||||
var allNonMetaInstantiatableIndexerTypes = allInstantiatableIndexerTypes.Where(p => !typeof(BaseMetaIndexer).IsAssignableFrom(p));
|
||||
var indexerTypes = allNonMetaInstantiatableIndexerTypes.Where(p => p.Name != "CardigannIndexer");
|
||||
foreach (var indexer in indexerTypes)
|
||||
{
|
||||
builder.RegisterType(indexer).Named<IIndexer>(BaseIndexer.GetIndexerID(indexer));
|
||||
}
|
||||
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientStringResult> ().ForMember (x => x.Content, opt => opt.Ignore ()).AfterMap ((be, str) => {
|
||||
str.Content = Encoding.UTF8.GetString (be.Content);
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientStringResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) =>
|
||||
{
|
||||
str.Content = Encoding.UTF8.GetString(be.Content);
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientByteResult> ().ForMember (x => x.Content, opt => opt.Ignore ()).AfterMap ((str, be) => {
|
||||
if (!string.IsNullOrEmpty (str.Content)) {
|
||||
be.Content = Encoding.UTF8.GetBytes (str.Content);
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientByteResult>().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((str, be) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str.Content))
|
||||
{
|
||||
be.Content = Encoding.UTF8.GetBytes(str.Content);
|
||||
}
|
||||
});
|
||||
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientStringResult> ();
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientByteResult> ();
|
||||
Mapper.CreateMap<ReleaseInfo, ReleaseInfo> ();
|
||||
Mapper.CreateMap<WebClientStringResult, WebClientStringResult>();
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientByteResult>();
|
||||
Mapper.CreateMap<ReleaseInfo, ReleaseInfo>();
|
||||
|
||||
Mapper.CreateMap<ReleaseInfo, TrackerCacheResult> ().AfterMap ((r, t) => {
|
||||
if (r.Category != null) {
|
||||
var CategoryDesc = string.Join (", ", r.Category.Select (x => TorznabCatType.GetCatDesc (x)).Where (x => !string.IsNullOrEmpty (x)));
|
||||
Mapper.CreateMap<ReleaseInfo, TrackerCacheResult>().AfterMap((r, t) =>
|
||||
{
|
||||
if (r.Category != null)
|
||||
{
|
||||
var CategoryDesc = string.Join(", ", r.Category.Select(x => TorznabCatType.GetCatDesc(x)).Where(x => !string.IsNullOrEmpty(x)));
|
||||
t.CategoryDesc = CategoryDesc;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
t.CategoryDesc = "";
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jackett.Utils
|
||||
{
|
||||
public class EncodingJsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var obj = value as Encoding;
|
||||
writer.WriteValue(obj.WebName);
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue