Implement filelist and disable browser caching

This commit is contained in:
KZ 2015-08-11 23:10:15 +01:00
parent e007d321f6
commit c8dff6da72
13 changed files with 271 additions and 26 deletions

View File

@ -24,6 +24,7 @@ Download in the [Releases page](https://github.com/zone117x/Jackett/releases)
* [BIT-HDTV](https://www.bit-hdtv.com)
* [BitMeTV](http://www.bitmetv.org/)
* [Demonoid](http://www.demonoid.pw/)
* [FileList](http://filelist.ro/)
* [FrenchTorrentDb](http://www.frenchtorrentdb.com/)
* [Freshon](https://freshon.tv/)
* [HD-Space](https://hd-space.org/)

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http.Filters;
namespace Jackett
{
public class JackettAPINoCacheAttribute : System.Web.Http.Filters.ActionFilterAttribute
{
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
{
actionExecutedContext.Response.Headers.CacheControl = new System.Net.Http.Headers.CacheControlHeaderValue()
{
NoStore = true,
Private = true
};
base.OnActionExecuted(actionExecutedContext);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -28,6 +28,7 @@ namespace Jackett.Controllers
{
[RoutePrefix("admin")]
[JackettAuthorized]
[JackettAPINoCache]
public class AdminController : ApiController
{
private IConfigurationService config;

View File

@ -16,6 +16,7 @@ using System.Web.Http;
namespace Jackett.Controllers
{
[AllowAnonymous]
[JackettAPINoCache]
public class BlackholeController : ApiController
{
private Logger logger;

View File

@ -14,6 +14,7 @@ using System.Web.Http;
namespace Jackett.Controllers
{
[AllowAnonymous]
[JackettAPINoCache]
public class DownloadController : ApiController
{
private Logger logger;

View File

@ -19,6 +19,7 @@ using System.Web.Http;
namespace Jackett.Controllers
{
[AllowAnonymous]
[JackettAPINoCache]
public class PotatoController : ApiController
{
private IIndexerManagerService indexerService;

View File

@ -16,6 +16,7 @@ using System.Web.Http;
namespace Jackett.Controllers
{
[AllowAnonymous]
[JackettAPINoCache]
public class TorznabController : ApiController
{
private IIndexerManagerService indexerService;

View File

@ -44,9 +44,9 @@ namespace Jackett.Indexers
AddCategoryMapping(10, TorznabCatType.XXX);
AddCategoryMapping(20, TorznabCatType.XXX);
AddCategoryMapping(12, TorznabCatType.PCGames);
AddCategoryMapping(13, TorznabCatType.GameXbox);
AddCategoryMapping(14, TorznabCatType.GamePS3);
AddCategoryMapping(15, TorznabCatType.GameWii);
AddCategoryMapping(13, TorznabCatType.ConsoleXbox);
AddCategoryMapping(14, TorznabCatType.ConsolePS3);
AddCategoryMapping(15, TorznabCatType.ConsoleWii);
AddCategoryMapping(16, TorznabCatType.PC);
AddCategoryMapping(17, TorznabCatType.PCMac);
AddCategoryMapping(19, TorznabCatType.PCMobileOther);

View File

@ -0,0 +1,146 @@
using CsQuery;
using Jackett.Models;
using Jackett.Services;
using Jackett.Utils;
using Jackett.Utils.Clients;
using Newtonsoft.Json.Linq;
using NLog;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Jackett.Models.IndexerConfig;
namespace Jackett.Indexers
{
public class FileList : BaseIndexer, IIndexer
{
string LoginUrl { get { return SiteLink + "takelogin.php"; } }
string BrowseUrl { get { return SiteLink + "browse.php"; } }
new ConfigurationDataFileList configData
{
get { return (ConfigurationDataFileList)base.configData; }
set { base.configData = value; }
}
public FileList(IIndexerManagerService i, IWebClient wc, Logger l, IProtectionService ps)
: base(name: "FileList",
description: "The best Romanian site.",
link: "http://filelist.ro/",
caps: TorznabUtil.CreateDefaultTorznabTVCaps(),
manager: i,
client: wc,
logger: l,
p: ps,
configData: new ConfigurationDataFileList())
{
AddCategoryMapping(24, TorznabCatType.Anime);
AddCategoryMapping(11, TorznabCatType.Audio);
AddCategoryMapping(15, TorznabCatType.TV);
//AddCategoryMapping(18, TorznabCatType.); Other
AddCategoryMapping(16, TorznabCatType.TVDocs);
AddCategoryMapping(25, TorznabCatType.Movies3D);
AddCategoryMapping(20, TorznabCatType.MoviesBlueRay);
AddCategoryMapping(2, TorznabCatType.MoviesSD);
AddCategoryMapping(3, TorznabCatType.MoviesSD); //RO
AddCategoryMapping(4, TorznabCatType.MoviesHD);
AddCategoryMapping(19, TorznabCatType.MoviesHD); // RO
AddCategoryMapping(1, TorznabCatType.MoviesSD);
AddCategoryMapping(10, TorznabCatType.Consoles);
AddCategoryMapping(9, TorznabCatType.PCGames);
//AddCategoryMapping(17, TorznabCatType); Linux No cat
AddCategoryMapping(22, TorznabCatType.AppsMobile); //Apps/mobile
AddCategoryMapping(8, TorznabCatType.Apps);
AddCategoryMapping(21, TorznabCatType.TVHD);
AddCategoryMapping(23, TorznabCatType.TVSD);
AddCategoryMapping(13, TorznabCatType.TVSport);
AddCategoryMapping(14, TorznabCatType.TV);
AddCategoryMapping(12, TorznabCatType.AudioMusicVideos);
AddCategoryMapping(7, TorznabCatType.XXX);
}
public async Task ApplyConfiguration(JToken configJson)
{
configData.LoadValuesFromJson(configJson);
var pairs = new Dictionary<string, string> {
{ "username", configData.Username.Value },
{ "password", configData.Password.Value }
};
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, null, true, null, LoginUrl);
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
{
CQ dom = result.Content;
var errorMessage = dom[".main"].Text().Trim();
throw new ExceptionWithConfigData(errorMessage, configData);
});
}
public async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
{
var releases = new List<ReleaseInfo>();
var searchString = query.SanitizedSearchTerm + " " + query.GetEpisodeSearchString();
var searchUrl = BrowseUrl;
if (!string.IsNullOrWhiteSpace(searchString))
searchUrl += string.Format("?search={0}&cat=0&searchin=0&sort=0", HttpUtility.UrlEncode(searchString));
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
var results = response.Content;
try
{
CQ dom = results;
var rows = dom[".torrentrow"];
foreach (var row in rows)
{
var release = new ReleaseInfo();
var qRow = row.Cq();
var qTitleLink = qRow.Find(".torrenttable:eq(1) a").First();
release.Title = qRow.Find(".torrenttable:eq(1) a b").Text().Trim();
release.Description = release.Title;
release.Guid = new Uri(SiteLink + qTitleLink.Attr("href"));
release.Comments = release.Guid;
//22:05:3716/02/2013
var dateStr = qRow.Find(".torrenttable:eq(5)").Text().Trim();
release.PublishDate = DateTime.ParseExact(dateStr, "H:mm:ssdd/MM/yyyy", CultureInfo.InvariantCulture);
var qLink = qRow.Find(".torrenttable:eq(2) a").First();
release.Link = new Uri(SiteLink + qLink.Attr("href"));
var sizeStr = qRow.Find(".torrenttable:eq(6)").Text().Trim();
release.Size = ReleaseInfo.GetBytes(sizeStr);
release.Seeders = ParseUtil.CoerceInt(qRow.Find(".torrenttable:eq(8)").Text().Trim());
release.Peers = ParseUtil.CoerceInt(qRow.Find(".torrenttable:eq(9)").Text().Trim()) + release.Seeders;
var cat = qRow.Find(".torrenttable:eq(0) a").First().Attr("href").Substring(15);
release.Category = MapTrackerCatToNewznab(cat);
// Skip other
if (release.Category != 0)
{
// Skip Romanian releases
if ((cat == "3" || cat == "19") && !configData.IncludeRomanianReleases.Value)
continue;
releases.Add(release);
}
}
}
catch (Exception ex)
{
OnParseError(results, ex);
}
return releases;
}
}
}

View File

@ -172,6 +172,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AuthenticationException.cs" />
<Compile Include="CacheControlAttribute.cs" />
<Compile Include="Controllers\BlackholeController.cs" />
<Compile Include="Controllers\PotatoController.cs" />
<Compile Include="Controllers\TorznabController.cs" />
@ -191,6 +192,7 @@
<Compile Include="Indexers\HDTorrents.cs" />
<Compile Include="Indexers\IIndexer.cs" />
<Compile Include="Indexers\ImmortalSeed.cs" />
<Compile Include="Indexers\FileList.cs" />
<Compile Include="Indexers\TVChaosUK.cs" />
<Compile Include="Indexers\NCore.cs" />
<Compile Include="Indexers\RuTor.cs" />
@ -214,6 +216,7 @@
<Compile Include="Models\CachedLog.cs" />
<Compile Include="Models\CachedResult.cs" />
<Compile Include="Models\CategoryMapping.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataFileList.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataBasicLoginWithRSS.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataRecaptchaLogin.cs" />
<Compile Include="Models\IndexerConfig\ConfigurationDataLoginTokin.cs" />
@ -406,6 +409,9 @@
<Content Include="Content\logos\demonoid.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\logos\filelist.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\logos\frenchtorrentdb.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -0,0 +1,22 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jackett.Models.IndexerConfig
{
class ConfigurationDataFileList : ConfigurationDataBasicLogin
{
public BoolItem IncludeRomanianReleases { get; private set; }
public DisplayItem CatWarning { get; private set; }
public ConfigurationDataFileList()
: base()
{
IncludeRomanianReleases = new BoolItem() { Name = "IncludeRomanianReleases", Value = false };
CatWarning = new DisplayItem("When mapping TV ensure you add category 5000 in addition to 5030,5040.") { Name = "CatWarning" };
}
}
}

View File

@ -12,27 +12,53 @@ namespace Jackett.Models
static TorznabCatType()
{
cats.Add(5000, "TV");
cats.Add(5030, "TV/SD");
cats.Add(5040, "TV/HD");
cats.Add(5070, "TV/Anime");
cats.Add(5080, "TV/Documentary");
cats.Add(8000, "Books");
cats.Add(8020, "Books/Comics");
cats.Add(4000, "PC");
cats.Add(4050, "PC/Games");
cats.Add(3030, "Audio/Audiobook");
cats.Add(1000, "Consoles");
cats.Add(1010, "Consoles/DS");
cats.Add(1020, "Consoles/PSP");
cats.Add(1030, "Consoles/Wii");
cats.Add(1040, "Consoles/Xbox");
cats.Add(1050, "Consoles/360");
cats.Add(1080, "Consoles/PS3");
cats.Add(2000, "Movies");
cats.Add(2010, "Movies/Foreign");
cats.Add(2020, "Movies/Other");
cats.Add(2040, "Movies/HD");
cats.Add(2030, "Movies/SD");
cats.Add(2010, "Movies/Foreign");
cats.Add(2050, "Movies/3D");
cats.Add(2060, "Movies/BluRay");
cats.Add(3000, "Audio");
cats.Add(3010, "Audio/Lossy");
cats.Add(3020, "Audio/Video");
cats.Add(3030, "Audio/Audiobook");
cats.Add(3040, "Audio/Lossless");
cats.Add(3010, "Audio/MP3");
cats.Add(4000, "PC");
cats.Add(4010, "PC/Apps");
cats.Add(4020, "PC/ISO");
cats.Add(4030, "PC/Mac");
cats.Add(4040, "PC/Mobile");
cats.Add(4050, "PC/Games");
cats.Add(4060, "PC/Mobile/IOS");
cats.Add(4070, "PC/Mobile/Android");
cats.Add(5000, "TV");
cats.Add(5020, "TV/Foreign");
cats.Add(5030, "TV/SD");
cats.Add(5040, "TV/HD");
cats.Add(5060, "TV/Sport");
cats.Add(5070, "TV/Anime");
cats.Add(5080, "TV/Documentary");
cats.Add(6000, "XXX");
cats.Add(6040, "XXX/x264");
cats.Add(6010, "XXX/DVD");
cats.Add(6040, "XXX/x264");
cats.Add(6060, "XXX/Imageset");
cats.Add(8000, "Books");
cats.Add(8010, "Books/Ebook");
cats.Add(8020, "Books/Comics");
}
public static bool QueryContainsParentCategory(int[] queryCats, int releaseCat)
@ -116,7 +142,7 @@ namespace Jackett.Models
public static TorznabCategory EBooks
{
get { return GetCat(7020); }
get { return GetCat(8020); }
}
public static TorznabCategory Comic
@ -126,7 +152,12 @@ namespace Jackett.Models
public static TorznabCategory Apps
{
get { return GetCat(4000); }
get { return GetCat(4010); }
}
public static TorznabCategory AppsMobile
{
get { return GetCat(4040); }
}
public static TorznabCategory Movies
@ -156,12 +187,12 @@ namespace Jackett.Models
public static TorznabCategory MoviesBlueRay
{
get { return GetCat(2050); }
get { return GetCat(2060); }
}
public static TorznabCategory Movies3D
{
get { return GetCat(2060); }
get { return GetCat(2050); }
}
public static TorznabCategory Audio
@ -184,6 +215,12 @@ namespace Jackett.Models
get { return GetCat(3010); }
}
public static TorznabCategory AudioMusicVideos
{
get { return GetCat(3020); }
}
public static TorznabCategory XXX
{
get { return GetCat(6000); }
@ -244,32 +281,37 @@ namespace Jackett.Models
get { return GetCat(4070); }
}
public static TorznabCategory GameDNS
public static TorznabCategory Consoles
{
get { return GetCat(1000); }
}
public static TorznabCategory ConsoleDS
{
get { return GetCat(1010); }
}
public static TorznabCategory GamePSP
public static TorznabCategory ConsolePSP
{
get { return GetCat(1020); }
}
public static TorznabCategory GameXbox
public static TorznabCategory ConsoleXbox
{
get { return GetCat(1040); }
}
public static TorznabCategory GameXbox360
public static TorznabCategory ConsoleXbox360
{
get { return GetCat(1050); }
}
public static TorznabCategory GameWii
public static TorznabCategory ConsoleWii
{
get { return GetCat(1030); }
}
public static TorznabCategory GamePS3
public static TorznabCategory ConsolePS3
{
get { return GetCat(1080); }
}