mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Merge branch 'master' of https://github.com/Jackett/Jackett
This commit is contained in:
@@ -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>
|
||||
|
@@ -42,7 +42,8 @@ namespace Jackett
|
||||
builder.RegisterType<HttpWebClient>();
|
||||
|
||||
// Register the best web client for the platform or the override
|
||||
switch (Startup.ClientOverride) {
|
||||
switch (Startup.ClientOverride)
|
||||
{
|
||||
case "httpclient":
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
break;
|
||||
@@ -57,27 +58,36 @@ namespace Jackett
|
||||
break;
|
||||
case "automatic":
|
||||
default:
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix) {
|
||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
{
|
||||
var usehttpclient = false;
|
||||
try {
|
||||
try
|
||||
{
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null) {
|
||||
if (monotype != null)
|
||||
{
|
||||
MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (displayName != null) {
|
||||
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) {
|
||||
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) {
|
||||
if (monoTlsProviderFactory != null)
|
||||
{
|
||||
MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod("IsProviderSupported");
|
||||
if (isProviderSupported != null) {
|
||||
if (isProviderSupported != null)
|
||||
{
|
||||
var btlsSupported = (bool)isProviderSupported.Invoke(null, new string[] { "btls" });
|
||||
if (btlsSupported) {
|
||||
if (btlsSupported)
|
||||
{
|
||||
// initialize btls
|
||||
MethodInfo initialize = monoTlsProviderFactory.GetMethod("Initialize", new[] { typeof(string) });
|
||||
if (initialize != null) {
|
||||
if (initialize != null)
|
||||
{
|
||||
initialize.Invoke(null, new string[] { "btls" });
|
||||
usehttpclient = true;
|
||||
}
|
||||
@@ -87,7 +97,9 @@ namespace Jackett
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.Out.WriteLine("Error while deciding which HttpWebClient to use: " + e);
|
||||
}
|
||||
|
||||
@@ -95,24 +107,34 @@ namespace Jackett
|
||||
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||
else
|
||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
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) {
|
||||
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) => {
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -121,11 +143,15 @@ namespace Jackett
|
||||
Mapper.CreateMap<WebClientByteResult, WebClientByteResult>();
|
||||
Mapper.CreateMap<ReleaseInfo, ReleaseInfo>();
|
||||
|
||||
Mapper.CreateMap<ReleaseInfo, TrackerCacheResult> ().AfterMap ((r, t) => {
|
||||
if (r.Category != null) {
|
||||
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 = "";
|
||||
}
|
||||
});
|
||||
|
30
src/Jackett/Utils/JsonUtil.cs
Normal file
30
src/Jackett/Utils/JsonUtil.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user