HDTorrents bugfix and reduce sizes of cards to improve presentation with the large number of indexers

This commit is contained in:
KZ 2015-07-18 09:52:26 +01:00
parent 869d89d663
commit 192406892d
5 changed files with 62 additions and 47 deletions

View File

@ -1,6 +1,7 @@
using CsQuery;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@ -19,20 +20,18 @@ namespace Jackett.Indexers
class ConfigurationDataBasicLoginAnimeBytes : ConfigurationDataBasicLogin
{
public BoolItem IncludeRaw { get; private set; }
public DisplayItem RageIdWarning { get; private set; }
public DisplayItem DateWarning { get; private set; }
public ConfigurationDataBasicLoginAnimeBytes()
: base()
{
IncludeRaw = new BoolItem() { Name = "IncludeRaw", Value = false };
RageIdWarning = new DisplayItem("Ensure rageid lookup is disabled in Sonarr for this tracker.") { Name = "RageWarning" };
DateWarning = new DisplayItem("This tracker does not supply upload dates so they are based off year of release.") { Name = "DateWarning" };
}
public override Item[] GetItems()
{
return new Item[] { Username, Password, IncludeRaw, RageIdWarning, DateWarning };
return new Item[] { Username, Password, IncludeRaw, DateWarning };
}
}
@ -196,12 +195,28 @@ namespace Jackett.Indexers
public async Task<ReleaseInfo[]> PerformQuery(TorznabQuery query)
{
// This tracker only deals with full seasons so chop off the episode/season number if we have it D:
if (!string.IsNullOrWhiteSpace(query.SearchTerm))
// The result list
var releases = new ConcurrentBag<ReleaseInfo>();
var titles = query.ShowTitles ?? new string[] { query.SearchTerm??string.Empty };
var tasks = titles.Select(async item =>
{
var splitindex = query.SearchTerm.LastIndexOf(' ');
foreach (var result in await GetResults(item))
releases.Add(result);
});
await Task.WhenAll(tasks);
return releases.ToArray();
}
public async Task<ReleaseInfo[]> GetResults(string searchTerm)
{
// This tracker only deals with full seasons so chop off the episode/season number if we have it D:
if (!string.IsNullOrWhiteSpace(searchTerm))
{
var splitindex = searchTerm.LastIndexOf(' ');
if (splitindex > -1)
query.SearchTerm = query.SearchTerm.Substring(0, splitindex);
searchTerm = searchTerm.Substring(0, splitindex);
}
// The result list
@ -213,17 +228,16 @@ namespace Jackett.Indexers
// Remove old cache items
CleanCache();
var cachedResult = cache.Where(i => i.Query == query.SearchTerm).FirstOrDefault();
var cachedResult = cache.Where(i => i.Query == searchTerm).FirstOrDefault();
if (cachedResult != null)
return cachedResult.Results.Select(s => (ReleaseInfo)s.Clone()).ToArray();
}
var queryUrl = SearchUrl;
// Only include the query bit if its required as hopefully the site caches the non query page
if (!string.IsNullOrWhiteSpace(query.SearchTerm))
if (!string.IsNullOrWhiteSpace(searchTerm))
{
queryUrl += "&action=advanced&search_type=title&sort=time_added&way=desc&anime%5Btv_series%5D=1&searchstr=" + WebUtility.UrlEncode(query.SearchTerm);
queryUrl += "&action=advanced&search_type=title&sort=time_added&way=desc&anime%5Btv_series%5D=1&searchstr=" + WebUtility.UrlEncode(searchTerm);
}
// Get the content from the tracker
@ -320,13 +334,15 @@ namespace Jackett.Indexers
release.MinimumRatio = 1;
release.MinimumSeedTime = 259200;
var downloadLink = links.Get(0);
release.Guid = new Uri(BaseUrl + "/" + downloadLink.Attributes.GetAttribute("href") + "&nh=" + Hash(title)); // Sonarr should dedupe on this url - allow a url per name.
release.Link = release.Guid;// We dont know this so try to fake based on the release year
// We dont know this so try to fake based on the release year
release.PublishDate = new DateTime(year, 1, 1);
release.PublishDate = release.PublishDate.AddDays(Math.Min(DateTime.Now.DayOfYear, 365) - 1);
var infoLink = links.Get(1);
release.Comments = new Uri(BaseUrl + "/" + infoLink.Attributes.GetAttribute("href"));
release.Guid = new Uri(BaseUrl + "/" + infoLink.Attributes.GetAttribute("href") + "&nh=" + Hash(title)); // Sonarr should dedupe on this url - allow a url per name.
release.Link = new Uri(BaseUrl + "/" + downloadLink.Attributes.GetAttribute("href"));
// We dont actually have a release name >.> so try to create one
var releaseTags = infoLink.InnerText.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
@ -390,11 +406,10 @@ namespace Jackett.Indexers
throw ex;
}
// Add to the cache
lock (cache)
{
cache.Add(new CachedResult(query.SearchTerm, releases));
cache.Add(new CachedResult(searchTerm, releases));
}
return releases.Select(s => (ReleaseInfo)s.Clone()).ToArray();

View File

@ -18,7 +18,7 @@ namespace Jackett.Indexers
public event Action<IndexerInterface, string, Exception> OnResultParsingError;
const string DefaultUrl = "http://hd-torrents.org";
const string DefaultUrl = "http://hdts.ru"; // Of the accessible domains the .ru seems the most reliable. https://hdts.ru | https://hd-torrents.org | https://hd-torrents.net | https://hd-torrents.me
string BaseUrl = DefaultUrl;
static string chromeUserAgent = BrowserUtil.ChromeUserAgent;
private string SearchUrl = DefaultUrl + "/torrents.php?search={0}&active=1&options=0&category%5B%5D=59&category%5B%5D=60&category%5B%5D=30&category%5B%5D=38&page={1}";
@ -176,7 +176,7 @@ namespace Jackett.Indexers
release.MinimumRatio = 1;
release.MinimumSeedTime = 172800;
release.MagnetUri = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent").Get(3).FirstChild.GetAttribute("href"));
int seeders, peers;
if (ParseUtil.TryCoerceInt(qRow.Find("td").Get(9).FirstChild.FirstChild.InnerText, out seeders))
@ -207,15 +207,14 @@ namespace Jackett.Indexers
}
release.Size = size;
release.Link = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent b a").Attr("href"));
release.Guid = release.Link;
release.Guid = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent b a").Attr("href"));
release.Link = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent").Get(3).FirstChild.GetAttribute("href"));
release.Comments = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent b a").Attr("href") + "#comments");
string[] dateSplit = qRow.Find("td.mainblockcontent").Get(5).InnerHTML.Split(',');
string dateString = dateSplit[1].Substring(0, dateSplit[1].IndexOf('>'));
release.PublishDate = DateTime.Parse(dateString, CultureInfo.InvariantCulture);
release.Comments = new Uri(DefaultUrl + "/" + qRow.Find("td.mainblockcontent").Get(2).FirstChild.GetAttribute("href"));
releases.Add(release);
}
}
@ -237,7 +236,7 @@ namespace Jackett.Indexers
public Task<byte[]> Download(Uri link)
{
throw new NotImplementedException();
return client.GetByteArrayAsync(link);
}
}
}

View File

@ -276,7 +276,7 @@ namespace Jackett
jsonReply["api_key"] = ApiKey.CurrentKey;
jsonReply["app_version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
JArray items = new JArray();
foreach (var i in indexerManager.Indexers)
foreach (var i in indexerManager.Indexers.OrderBy(_=>_.Key))
{
var indexer = i.Value;
var item = new JObject();

View File

@ -25,18 +25,31 @@
border-radius: 6px;
box-shadow: 1px 1px 5px 2px #cdcdcd;
padding: 10px;
width: 260px;
width: 270px;
display: inline-block;
vertical-align: top;
margin: 10px;
margin: 5px;
}
#indexers {
text-align: center;
}
#unconfigured-indexers{
text-align: center;
}
#unconfigured-indexers .card {
width: 200px;
}
.unconfigured-indexer {
height: 170px;
height: 120px;
}
.indexer {
height: 230px;
height: 180px;
}
.add-indexer {
@ -45,6 +58,7 @@
.indexer-logo {
text-align: center;
padding-bottom: 5px;
}
.indexer-logo > img {

View File

@ -42,6 +42,9 @@
<hr />
<div class="input-area">
<p>
To add a Jackett indexer in Sonarr go to <b>Settings > Indexers > Add > Torznab > Custom</b>.
</p>
<span class="input-header">Jackett API Key: </span>
<input id="api-key-input" class="form-control input-right" type="text" value="" placeholder="API Key" readonly="">
<p>Use this key when adding indexers to Sonarr. This key works for all indexers.</p>
@ -52,23 +55,13 @@
</button>
<span title="Jackett will restart after changing the port" class="glyphicon glyphicon-info-sign"></span>
</div>
<hr />
<h3>Configured Indexers</h3>
<div id="indexers">
</div>
<div id="indexers"> </div>
<hr />
<div id="footer">
Jackett Version <span id="app-version"></span>
</div>
</div>
<div id="select-indexer-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
@ -81,10 +74,6 @@
<div class="modal-body">
<div id="unconfigured-indexers">
</div>
<hr />
<p>
To add a Jackett indexer in Sonarr go to <b>Settings > Indexers > Add > Torznab > Custom</b>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
@ -123,8 +112,7 @@
</button>
<div class="configured-indexer indexer card">
<div class="indexer-logo"><img src="logos/{{id}}.png" /></div>
<div class="indexer-name"><h3>{{name}}</h3></div>
<div class="indexer-logo"><img alt="{{name}}" title="{{name}}" src="logos/{{id}}.png" /></div>
<div class="indexer-buttons">
<button class="btn btn-primary btn-sm indexer-setup" data-id="{{id}}">
<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
@ -146,8 +134,7 @@
</div>
<div class="unconfigured-indexer card">
<div class="indexer-logo"><img src="logos/{{id}}.png" /></div>
<div class="indexer-name"><h3>{{name}}</h3></div>
<div class="indexer-logo"><img alt="{{name}}" title="{{name}}" src="logos/{{id}}.png" /></div>
<div class="indexer-buttons">
<a class="btn btn-info" target="_blank" href="{{site_link}}">Visit <span class="glyphicon glyphicon-new-window" aria-hidden="true"></span></a>
<button class="indexer-setup btn btn-success" data-id="{{id}}">Setup <span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>