mirror of
https://github.com/Radarr/Radarr
synced 2025-02-25 15:43:08 +00:00
Merged branch develop into develop
This commit is contained in:
commit
1e2c28f67a
6 changed files with 88 additions and 124 deletions
|
@ -1,80 +0,0 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.AwesomeHD
|
||||
{
|
||||
public class Torrent
|
||||
{
|
||||
[XmlElement(ElementName = "id")]
|
||||
public string Id { get; set; }
|
||||
[XmlElement(ElementName = "groupid")]
|
||||
public string GroupId { get; set; }
|
||||
[XmlElement(ElementName = "time")]
|
||||
public DateTime Time { get; set; }
|
||||
[XmlElement(ElementName = "userid")]
|
||||
public string Userid { get; set; }
|
||||
[XmlElement(ElementName = "size")]
|
||||
public long Size { get; set; }
|
||||
[XmlElement(ElementName = "snatched")]
|
||||
public string Snatched { get; set; }
|
||||
[XmlElement(ElementName = "seeders")]
|
||||
public string Seeders { get; set; }
|
||||
[XmlElement(ElementName = "leechers")]
|
||||
public string Leechers { get; set; }
|
||||
[XmlElement(ElementName = "releasegroup")]
|
||||
public string Releasegroup { get; set; }
|
||||
[XmlElement(ElementName = "resolution")]
|
||||
public string Resolution { get; set; }
|
||||
[XmlElement(ElementName = "media")]
|
||||
public string Media { get; set; }
|
||||
[XmlElement(ElementName = "format")]
|
||||
public string Format { get; set; }
|
||||
[XmlElement(ElementName = "encoding")]
|
||||
public string Encoding { get; set; }
|
||||
[XmlElement(ElementName = "audioformat")]
|
||||
public string Audioformat { get; set; }
|
||||
[XmlElement(ElementName = "audiobitrate")]
|
||||
public string Audiobitrate { get; set; }
|
||||
[XmlElement(ElementName = "audiochannels")]
|
||||
public string Audiochannels { get; set; }
|
||||
[XmlElement(ElementName = "subtitles")]
|
||||
public string Subtitles { get; set; }
|
||||
[XmlElement(ElementName = "encodestatus")]
|
||||
public string Encodestatus { get; set; }
|
||||
[XmlElement(ElementName = "freeleech")]
|
||||
public string Freeleech { get; set; }
|
||||
[XmlElement(ElementName = "cover")]
|
||||
public string Cover { get; set; }
|
||||
[XmlElement(ElementName = "smallcover")]
|
||||
public string Smallcover { get; set; }
|
||||
[XmlElement(ElementName = "year")]
|
||||
public string Year { get; set; }
|
||||
[XmlElement(ElementName = "name")]
|
||||
public string Name { get; set; }
|
||||
[XmlElement(ElementName = "imdb")]
|
||||
public string Imdb { get; set; }
|
||||
[XmlElement(ElementName = "type")]
|
||||
public string Type { get; set; }
|
||||
[XmlElement(ElementName = "plotoutline")]
|
||||
public string Plotoutline { get; set; }
|
||||
}
|
||||
|
||||
public class SearchResults
|
||||
{
|
||||
[XmlElement(ElementName = "authkey")]
|
||||
public string AuthKey { get; set; }
|
||||
[XmlElement(ElementName = "torrent")]
|
||||
public List<Torrent> Torrent { get; set; }
|
||||
}
|
||||
|
||||
public class AwesomeHDSearchResponse
|
||||
{
|
||||
[XmlElement(ElementName = "?xml")]
|
||||
public string Xml { get; set; }
|
||||
[XmlElement(ElementName = "searchresults")]
|
||||
public SearchResults SearchResults { get; set; }
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Indexers.AwesomeHD
|
||||
{
|
||||
|
@ -31,38 +32,64 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
indexerResponse.HttpResponse.StatusCode);
|
||||
}
|
||||
|
||||
// Hacky ¯\_(ツ)_/¯
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(indexerResponse.Content);
|
||||
|
||||
var json = JsonConvert.SerializeXmlNode(doc);
|
||||
|
||||
Console.WriteLine(json);
|
||||
|
||||
var jsonResponse = JsonConvert.DeserializeObject<AwesomeHDSearchResponse>(json);
|
||||
|
||||
if (jsonResponse == null)
|
||||
try
|
||||
{
|
||||
throw new IndexerException(indexerResponse, "Unexpected response from request");
|
||||
}
|
||||
|
||||
foreach (var torrent in jsonResponse.SearchResults.Torrent)
|
||||
{
|
||||
var id = torrent.Id;
|
||||
var title = $"{torrent.Name}.{torrent.Year}.{torrent.Resolution}.{torrent.Media}.{torrent.Encoding}.{torrent.Audioformat}-{torrent.Releasegroup}";
|
||||
|
||||
torrentInfos.Add(new TorrentInfo()
|
||||
var xdoc = XDocument.Parse(indexerResponse.Content);
|
||||
var searchResults = xdoc.Descendants("searchresults").Select(x => new
|
||||
{
|
||||
Guid = string.Format("AwesomeHD-{0}", id),
|
||||
Title = title,
|
||||
Size = torrent.Size,
|
||||
DownloadUrl = GetDownloadUrl(id, jsonResponse.SearchResults.AuthKey, _settings.Passkey),
|
||||
InfoUrl = GetInfoUrl(torrent.GroupId, id),
|
||||
Seeders = int.Parse(torrent.Seeders),
|
||||
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
|
||||
PublishDate = torrent.Time.ToUniversalTime()
|
||||
});
|
||||
AuthKey = x.Element("authkey").Value,
|
||||
}).FirstOrDefault();
|
||||
|
||||
var torrents = xdoc.Descendants("torrent")
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Element("id").Value,
|
||||
Name = x.Element("name").Value,
|
||||
Year = x.Element("year").Value,
|
||||
GroupId = x.Element("groupid").Value,
|
||||
Time = DateTime.Parse(x.Element("time").Value),
|
||||
UserId = x.Element("userid").Value,
|
||||
Size = long.Parse(x.Element("size").Value),
|
||||
Snatched = x.Element("snatched").Value,
|
||||
Seeders = x.Element("seeders").Value,
|
||||
Leechers = x.Element("leechers").Value,
|
||||
ReleaseGroup = x.Element("releasegroup").Value,
|
||||
Resolution = x.Element("resolution").Value,
|
||||
Media = x.Element("media").Value,
|
||||
Format = x.Element("format").Value,
|
||||
Encoding = x.Element("encoding").Value,
|
||||
AudioFormat = x.Element("audioformat").Value,
|
||||
AudioBitrate = x.Element("audiobitrate").Value,
|
||||
AudioChannels = x.Element("audiochannels").Value,
|
||||
Subtitles = x.Element("subtitles").Value,
|
||||
EncodeStatus = x.Element("encodestatus").Value,
|
||||
Freeleech = x.Element("freeleech").Value,
|
||||
}).ToList();
|
||||
|
||||
foreach (var torrent in torrents)
|
||||
{
|
||||
var id = torrent.Id;
|
||||
var title = $"{torrent.Name}.{torrent.Year}.{torrent.Resolution}.{torrent.Media}.{torrent.Encoding}.{torrent.AudioFormat}-{torrent.ReleaseGroup}";
|
||||
|
||||
torrentInfos.Add(new TorrentInfo()
|
||||
{
|
||||
Guid = string.Format("AwesomeHD-{0}", id),
|
||||
Title = title,
|
||||
Size = torrent.Size,
|
||||
DownloadUrl = GetDownloadUrl(id, searchResults.AuthKey, _settings.Passkey),
|
||||
InfoUrl = GetInfoUrl(torrent.GroupId, id),
|
||||
Seeders = int.Parse(torrent.Seeders),
|
||||
Peers = int.Parse(torrent.Leechers) + int.Parse(torrent.Seeders),
|
||||
PublishDate = torrent.Time.ToUniversalTime()
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (XmlException)
|
||||
{
|
||||
throw new IndexerException(indexerResponse,
|
||||
"An error occurred while processing feed, feed invalid");
|
||||
}
|
||||
|
||||
|
||||
return torrentInfos.OrderByDescending(o => ((dynamic)o).Seeders).ToArray();
|
||||
}
|
||||
|
|
|
@ -56,14 +56,6 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
title = $"{title} ✔";
|
||||
}
|
||||
|
||||
//if (IsPropertyExist(torrent, "RemasterTitle"))
|
||||
//{
|
||||
// if (torrent.RemasterTitle != null)
|
||||
// {
|
||||
// title = $"{title} - {torrent.RemasterTitle}";
|
||||
// }
|
||||
//}
|
||||
|
||||
// Only add approved torrents
|
||||
if (_settings.Approved && torrent.Checked)
|
||||
{
|
||||
|
@ -109,9 +101,37 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
}
|
||||
|
||||
// prefer golden
|
||||
if (_settings.Golden)
|
||||
{
|
||||
if (_settings.Scene)
|
||||
{
|
||||
return
|
||||
torrentInfos.OrderByDescending(o => o.PublishDate)
|
||||
.ThenBy(o => ((dynamic)o).Golden ? 0 : 1)
|
||||
.ThenBy(o => ((dynamic) o).Scene ? 0 : 1)
|
||||
.ToArray();
|
||||
}
|
||||
return
|
||||
torrentInfos.OrderByDescending(o => o.PublishDate)
|
||||
.ThenBy(o => ((dynamic)o).Golden ? 0 : 1)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
// prefer scene
|
||||
// require approval
|
||||
return torrentInfos.OrderBy(o => ((dynamic)o).Golden ? 0 : 1).ThenBy(o => ((dynamic)o).Scene ? 0 : 1).ThenByDescending(o => ((dynamic)o).PublishDate).ToArray();
|
||||
if (_settings.Scene)
|
||||
{
|
||||
return
|
||||
torrentInfos.OrderByDescending(o => o.PublishDate)
|
||||
.ThenBy(o => ((dynamic)o).Scene ? 0 : 1)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
// order by date
|
||||
return
|
||||
torrentInfos
|
||||
.OrderByDescending(o => o.PublishDate)
|
||||
.ToArray();
|
||||
|
||||
}
|
||||
|
||||
private string GetDownloadUrl(int torrentId, string authKey, string passKey)
|
||||
|
|
|
@ -47,8 +47,8 @@ public PassThePopcornSettings()
|
|||
[FieldDefinition(6, Label = "Require Approved", Type = FieldType.Checkbox, HelpText = "Require staff-approval for releases to be accepted.")]
|
||||
public bool Approved { get; set; }
|
||||
|
||||
[FieldDefinition(7, Label = "Require Golden", Type = FieldType.Checkbox, HelpText = "Require Golden Popcorn-releases for releases to be accepted.")]
|
||||
public bool RequireGolden { get; set; }
|
||||
//[FieldDefinition(7, Label = "Require Golden", Type = FieldType.Checkbox, HelpText = "Require Golden Popcorn-releases for releases to be accepted.")]
|
||||
//public bool RequireGolden { get; set; }
|
||||
|
||||
public NzbDroneValidationResult Validate()
|
||||
{
|
||||
|
|
|
@ -636,7 +636,6 @@
|
|||
<Compile Include="Indexers\EzrssTorrentRssParser.cs" />
|
||||
<Compile Include="Indexers\FetchAndParseRssService.cs" />
|
||||
<Compile Include="Indexers\AwesomeHD\AwesomeHD.cs" />
|
||||
<Compile Include="Indexers\AwesomeHD\AwesomeHDApi.cs" />
|
||||
<Compile Include="Indexers\AwesomeHD\AwesomeHDRequestGenerator.cs" />
|
||||
<Compile Include="Indexers\AwesomeHD\AwesomeHDSettings.cs" />
|
||||
<Compile Include="Indexers\PassThePopcorn\PassThePopcorn.cs" />
|
||||
|
|
|
@ -41,7 +41,6 @@ module.exports = Marionette.Layout.extend({
|
|||
name : 'this',
|
||||
label : 'Movie Title',
|
||||
cell : MovieTitleCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'inCinemas',
|
||||
|
@ -57,7 +56,6 @@ module.exports = Marionette.Layout.extend({
|
|||
name : 'status',
|
||||
label : 'Status',
|
||||
cell : MovieStatusWithTextCell,
|
||||
sortable : false
|
||||
},
|
||||
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue