2017-07-10 20:58:44 +00:00
|
|
|
|
using System;
|
2017-01-27 07:33:38 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using CsQuery;
|
2018-03-10 08:05:56 +00:00
|
|
|
|
using Jackett.Common.Models;
|
|
|
|
|
using Jackett.Common.Models.IndexerConfig;
|
|
|
|
|
using Jackett.Common.Services.Interfaces;
|
|
|
|
|
using Jackett.Common.Utils;
|
|
|
|
|
using Jackett.Common.Utils.Clients;
|
2017-01-27 07:33:38 +00:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
2018-03-10 08:05:56 +00:00
|
|
|
|
namespace Jackett.Common.Indexers
|
2017-01-27 07:33:38 +00:00
|
|
|
|
{
|
|
|
|
|
// ReSharper disable once InconsistentNaming
|
2017-07-10 20:58:44 +00:00
|
|
|
|
public class GimmePeers : BaseWebIndexer
|
2017-01-27 07:33:38 +00:00
|
|
|
|
{
|
|
|
|
|
private string BrowseUrl => SiteLink + "browse.php";
|
2017-01-27 19:23:57 +00:00
|
|
|
|
private string LoginUrl => SiteLink + "takelogin.php";
|
2017-01-27 07:33:38 +00:00
|
|
|
|
|
2017-10-29 06:21:18 +00:00
|
|
|
|
private new ConfigurationDataBasicLogin configData
|
2017-01-27 07:33:38 +00:00
|
|
|
|
{
|
|
|
|
|
get { return (ConfigurationDataBasicLogin)base.configData; }
|
|
|
|
|
set { base.configData = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-05 09:42:03 +00:00
|
|
|
|
public GimmePeers(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps)
|
2017-01-27 07:33:38 +00:00
|
|
|
|
: base(name: "GimmePeers",
|
|
|
|
|
description: "Formerly ILT",
|
|
|
|
|
link: "https://www.gimmepeers.com/",
|
|
|
|
|
caps: new TorznabCapabilities(),
|
2017-07-10 20:58:44 +00:00
|
|
|
|
configService: configService,
|
2017-01-27 07:33:38 +00:00
|
|
|
|
client: wc,
|
|
|
|
|
logger: l,
|
|
|
|
|
p: ps,
|
|
|
|
|
configData: new ConfigurationDataBasicLogin())
|
|
|
|
|
{
|
|
|
|
|
Encoding = Encoding.GetEncoding("iso-8859-1");
|
|
|
|
|
Language = "en-us";
|
2017-01-27 15:57:32 +00:00
|
|
|
|
Type = "private";
|
2017-01-27 07:33:38 +00:00
|
|
|
|
|
2017-01-28 05:53:16 +00:00
|
|
|
|
AddCategoryMapping(1, TorznabCatType.TVAnime);
|
|
|
|
|
AddCategoryMapping(5, TorznabCatType.BooksEbook);
|
|
|
|
|
AddCategoryMapping(10, TorznabCatType.PCGames);
|
|
|
|
|
AddCategoryMapping(11, TorznabCatType.ConsolePS3);
|
|
|
|
|
AddCategoryMapping(11, TorznabCatType.ConsolePS4);
|
|
|
|
|
AddCategoryMapping(11, TorznabCatType.ConsolePSP);
|
2017-01-27 07:33:38 +00:00
|
|
|
|
AddCategoryMapping(12, TorznabCatType.ConsoleXBOX360DLC);
|
|
|
|
|
AddCategoryMapping(12, TorznabCatType.ConsoleXbox);
|
|
|
|
|
AddCategoryMapping(12, TorznabCatType.ConsoleXbox360);
|
|
|
|
|
AddCategoryMapping(12, TorznabCatType.ConsoleXboxOne);
|
|
|
|
|
AddCategoryMapping(6, TorznabCatType.Audio);
|
|
|
|
|
|
2017-01-28 05:53:16 +00:00
|
|
|
|
AddCategoryMapping(21, TorznabCatType.TV);
|
|
|
|
|
AddCategoryMapping(20, TorznabCatType.TVSD);
|
|
|
|
|
AddCategoryMapping(21, TorznabCatType.TVHD);
|
2018-01-05 18:07:24 +00:00
|
|
|
|
AddCategoryMapping(22, TorznabCatType.TV);
|
|
|
|
|
AddCategoryMapping(24, TorznabCatType.TVSD);
|
|
|
|
|
AddCategoryMapping(25, TorznabCatType.TVHD);
|
2017-01-27 07:33:38 +00:00
|
|
|
|
|
2017-01-28 05:53:16 +00:00
|
|
|
|
AddCategoryMapping(50, TorznabCatType.XXX);
|
|
|
|
|
AddCategoryMapping(49, TorznabCatType.XXXDVD);
|
|
|
|
|
AddCategoryMapping(50, TorznabCatType.XXXx264);
|
2017-01-27 07:33:38 +00:00
|
|
|
|
|
2018-01-05 18:07:24 +00:00
|
|
|
|
AddCategoryMapping(13, TorznabCatType.Movies3D);
|
2017-01-28 05:53:16 +00:00
|
|
|
|
AddCategoryMapping(14, TorznabCatType.MoviesBluRay);
|
|
|
|
|
AddCategoryMapping(15, TorznabCatType.MoviesDVD);
|
|
|
|
|
AddCategoryMapping(16, TorznabCatType.MoviesHD);
|
2018-01-05 18:07:24 +00:00
|
|
|
|
AddCategoryMapping(17, TorznabCatType.Movies);
|
2017-01-27 07:33:38 +00:00
|
|
|
|
AddCategoryMapping(19, TorznabCatType.Movies);
|
2018-01-05 18:07:24 +00:00
|
|
|
|
AddCategoryMapping(26, TorznabCatType.MoviesUHD);
|
2017-01-27 07:33:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-28 05:31:38 +00:00
|
|
|
|
public override async Task<IndexerConfigurationStatus> ApplyConfiguration(JToken configJson)
|
2017-01-27 07:33:38 +00:00
|
|
|
|
{
|
|
|
|
|
LoadValuesFromJson(configJson);
|
|
|
|
|
var pairs = new Dictionary<string, string> {
|
|
|
|
|
{ "username", configData.Username.Value },
|
|
|
|
|
{ "password", configData.Password.Value },
|
|
|
|
|
{ "returnto", "/" },
|
|
|
|
|
{ "login", "Log in!" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var loginPage = await RequestStringWithCookies(SiteLink, string.Empty);
|
|
|
|
|
|
|
|
|
|
var result = await RequestLoginAndFollowRedirect(LoginUrl, pairs, loginPage.Cookies, true, SiteLink, SiteLink);
|
|
|
|
|
await ConfigureIfOK(result.Cookies, result.Content != null && result.Content.Contains("logout.php"), () =>
|
|
|
|
|
{
|
|
|
|
|
CQ dom = result.Content;
|
|
|
|
|
var messageEl = dom["body > div"].First();
|
|
|
|
|
var errorMessage = messageEl.Text().Trim();
|
|
|
|
|
throw new ExceptionWithConfigData(errorMessage, configData);
|
|
|
|
|
});
|
|
|
|
|
return IndexerConfigurationStatus.RequiresTesting;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-03 05:15:47 +00:00
|
|
|
|
protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuery query)
|
2017-01-27 07:33:38 +00:00
|
|
|
|
{
|
|
|
|
|
var releases = new List<ReleaseInfo>();
|
|
|
|
|
var searchString = query.GetQueryString();
|
|
|
|
|
var searchUrl = BrowseUrl;
|
|
|
|
|
var trackerCats = MapTorznabCapsToTrackers(query);
|
|
|
|
|
var queryCollection = new NameValueCollection();
|
|
|
|
|
|
|
|
|
|
// Tracker can only search OR return things in categories
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(searchString))
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("search", searchString);
|
|
|
|
|
queryCollection.Add("cat", "0");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var cat in MapTorznabCapsToTrackers(query))
|
|
|
|
|
{
|
|
|
|
|
queryCollection.Add("c" + cat, "1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
queryCollection.Add("incldead", "0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchUrl += "?" + queryCollection.GetQueryString();
|
|
|
|
|
|
|
|
|
|
await ProcessPage(releases, searchUrl);
|
|
|
|
|
return releases;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task ProcessPage(List<ReleaseInfo> releases, string searchUrl)
|
|
|
|
|
{
|
|
|
|
|
var response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
2018-12-02 08:06:40 +00:00
|
|
|
|
if (response.IsRedirect)
|
|
|
|
|
{
|
|
|
|
|
// re login
|
|
|
|
|
await ApplyConfiguration(null);
|
|
|
|
|
response = await RequestStringWithCookiesAndRetry(searchUrl, null, BrowseUrl);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 07:33:38 +00:00
|
|
|
|
var results = response.Content;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
CQ dom = results;
|
|
|
|
|
|
2018-01-03 18:49:07 +00:00
|
|
|
|
var rows = dom[".browsetable:last tr"]; //the class for the table changed
|
2017-01-27 07:33:38 +00:00
|
|
|
|
foreach (var row in rows.Skip(1))
|
|
|
|
|
{
|
|
|
|
|
var release = new ReleaseInfo();
|
|
|
|
|
|
|
|
|
|
var link = row.Cq().Find("td:eq(1) a:eq(0)").First();
|
|
|
|
|
release.Guid = new Uri(SiteLink + link.Attr("href"));
|
|
|
|
|
release.Comments = release.Guid;
|
2017-10-29 06:21:18 +00:00
|
|
|
|
release.Title = link.Text().Trim();
|
2017-01-27 07:33:38 +00:00
|
|
|
|
release.Description = release.Title;
|
|
|
|
|
|
|
|
|
|
// If we search an get no results, we still get a table just with no info.
|
|
|
|
|
if (string.IsNullOrWhiteSpace(release.Title))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if the release has been assigned a category
|
|
|
|
|
if (row.Cq().Find("td:eq(0) a").Length > 0)
|
|
|
|
|
{
|
|
|
|
|
var cat = row.Cq().Find("td:eq(0) a").First().Attr("href").Substring(15);
|
|
|
|
|
release.Category = MapTrackerCatToNewznab(cat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var qLink = row.Cq().Find("td:eq(2) a").First();
|
|
|
|
|
release.Link = new Uri(SiteLink + qLink.Attr("href"));
|
|
|
|
|
|
2017-05-20 14:17:55 +00:00
|
|
|
|
var added = row.Cq().Find("td:eq(6)").First().Text().Trim(); //column changed from 7 to 6
|
2017-01-27 07:33:38 +00:00
|
|
|
|
var date = added.Substring(0, 10);
|
2017-05-20 14:17:55 +00:00
|
|
|
|
var time = added.Substring(11, 8); //date layout wasn't quite right
|
2017-01-27 07:33:38 +00:00
|
|
|
|
var dateTime = date + time;
|
|
|
|
|
release.PublishDate = DateTime.ParseExact(dateTime, "yyyy-MM-ddHH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime();
|
|
|
|
|
|
2017-05-20 14:17:55 +00:00
|
|
|
|
var sizeStr = row.Cq().Find("td:eq(5)").First().Text().Trim(); //size column moved from 8 to 5
|
2017-01-27 07:33:38 +00:00
|
|
|
|
release.Size = ReleaseInfo.GetBytes(sizeStr);
|
|
|
|
|
|
|
|
|
|
release.Seeders = ParseUtil.CoerceInt(row.Cq().Find("td:eq(10)").First().Text().Trim());
|
|
|
|
|
release.Peers = ParseUtil.CoerceInt(row.Cq().Find("td:eq(11)").First().Text().Trim()) + release.Seeders;
|
|
|
|
|
|
|
|
|
|
releases.Add(release);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
OnParseError(results, ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|