1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00

Merge pull request #160 from Sonarr/torrent-ui

New: Show source/seed info in manual search
This commit is contained in:
Keivan Beigi 2014-12-19 22:28:47 -08:00
commit a55a77cb5b
18 changed files with 169 additions and 56 deletions

View File

@ -54,7 +54,7 @@ public ReleaseModule(IFetchAndParseRss rssFetcherAndParser,
private Response DownloadRelease(ReleaseResource release)
{
var remoteEpisode = _remoteEpisodeCache.Find(release.Guid);
if (remoteEpisode == null)
{
_logger.Debug("Couldn't find requested release in cache, cache timeout probably expired.");
@ -142,6 +142,21 @@ private List<ReleaseResource> MapDecisions(IEnumerable<DownloadDecision> decisio
release.QualityWeight += release.Quality.Revision.Real * 10;
release.QualityWeight += release.Quality.Revision.Version;
var torrentRelease = downloadDecision.RemoteEpisode.Release as TorrentInfo;
if (torrentRelease != null)
{
release.Protocol = DownloadProtocol.Torrent;
release.Seeders = torrentRelease.Seeders;
//TODO: move this up the chains
release.Leechers = torrentRelease.Peers - torrentRelease.Seeders;
}
else
{
release.Protocol = DownloadProtocol.Usenet;
}
result.Add(release);
}

View File

@ -42,6 +42,11 @@ public class ReleaseResource : RestResource
public DownloadProtocol DownloadProtocol { get; set; }
public Int32 ReleaseWeight { get; set; }
public int? Seeders { get; set; }
public int? Leechers { get; set; }
public DownloadProtocol Protocol { get; set; }
public Boolean IsDaily { get; set; }
public Boolean IsAbsoluteNumbering { get; set; }
public Boolean IsPossibleSpecialEpisode { get; set; }

View File

@ -52,7 +52,7 @@ public void should_parse_recent_feed_from_BitMeTv()
torrentInfo.InfoHash.Should().Be(null);
torrentInfo.MagnetUrl.Should().Be(null);
torrentInfo.Peers.Should().Be(null);
torrentInfo.Seeds.Should().Be(null);
torrentInfo.Seeders.Should().Be(null);
}
}
}

View File

@ -54,7 +54,7 @@ public void should_parse_recent_feed_from_BroadcastheNet()
torrentInfo.TvRageId.Should().Be(4055);
torrentInfo.MagnetUrl.Should().BeNullOrEmpty();
torrentInfo.Peers.Should().Be(9);
torrentInfo.Seeds.Should().Be(40);
torrentInfo.Seeders.Should().Be(40);
}
private void VerifyBackOff()

View File

@ -51,7 +51,7 @@ public void should_parse_recent_feed_from_Eztv()
torrentInfo.InfoHash.Should().Be("20FC4FBFA88272274AC671F857CC15144E9AA83E");
torrentInfo.MagnetUrl.Should().Be("magnet:?xt=urn:btih:ED6E7P5IQJZCOSWGOH4FPTAVCRHJVKB6&dn=S4C.I.Grombil.Cyfandir.Pell.American.Interior.PDTV.x264-MVGroup");
torrentInfo.Peers.Should().NotHaveValue();
torrentInfo.Seeds.Should().NotHaveValue();
torrentInfo.Seeders.Should().NotHaveValue();
}
}
}

View File

@ -51,7 +51,7 @@ public void should_parse_recent_feed_from_IPTorrents()
torrentInfo.InfoHash.Should().Be(null);
torrentInfo.MagnetUrl.Should().Be(null);
torrentInfo.Peers.Should().Be(null);
torrentInfo.Seeds.Should().Be(null);
torrentInfo.Seeders.Should().Be(null);
}
}
}

View File

@ -52,7 +52,7 @@ public void should_parse_recent_feed_from_KickassTorrents()
torrentInfo.InfoHash.Should().Be("208C4F7866612CC88BFEBC7C496FA72C2368D1C0");
torrentInfo.MagnetUrl.Should().Be("magnet:?xt=urn:btih:208C4F7866612CC88BFEBC7C496FA72C2368D1C0&dn=doctor+stranger+e03+140512+hdtv+h264+720p+ipop+avi+ctrg&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce");
torrentInfo.Peers.Should().Be(311);
torrentInfo.Seeds.Should().Be(206);
torrentInfo.Seeders.Should().Be(206);
}
[Test]

View File

@ -51,7 +51,7 @@ public void should_parse_recent_feed_from_Nyaa()
torrentInfo.InfoHash.Should().Be(null);
torrentInfo.MagnetUrl.Should().Be(null);
torrentInfo.Peers.Should().Be(2);
torrentInfo.Seeds.Should().Be(1);
torrentInfo.Seeders.Should().Be(1);
}
}
}

View File

@ -51,7 +51,7 @@ public void should_parse_recent_feed_from_Torrentleech()
torrentInfo.InfoHash.Should().Be(null);
torrentInfo.MagnetUrl.Should().Be(null);
torrentInfo.Peers.Should().Be(7);
torrentInfo.Seeds.Should().Be(1);
torrentInfo.Seeders.Should().Be(1);
}
}
}

View File

@ -31,10 +31,10 @@ public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase se
return Decision.Accept();
}
if (torrentInfo.Seeds != null && torrentInfo.Seeds < 1)
if (torrentInfo.Seeders != null && torrentInfo.Seeders < 1)
{
_logger.Debug("Not enough seeders. ({0})", torrentInfo.Seeds);
return Decision.Reject("Not enough seeders. ({0})", torrentInfo.Seeds);
_logger.Debug("Not enough seeders. ({0})", torrentInfo.Seeders);
return Decision.Reject("Not enough seeders. ({0})", torrentInfo.Seeders);
}
return Decision.Accept();

View File

@ -58,7 +58,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
torrentInfo.PublishDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).ToUniversalTime().AddSeconds(torrent.Time);
//torrentInfo.MagnetUrl =
torrentInfo.InfoHash = torrent.InfoHash;
torrentInfo.Seeds = torrent.Seeders;
torrentInfo.Seeders = torrent.Seeders;
torrentInfo.Peers = torrent.Leechers;
results.Add(torrentInfo);

View File

@ -26,7 +26,7 @@ protected override ReleaseInfo ProcessItem(XElement item, ReleaseInfo releaseInf
result.InfoHash = GetInfoHash(item);
result.MagnetUrl = GetMagnetUrl(item);
result.Seeds = GetSeeders(item);
result.Seeders = GetSeeders(item);
result.Peers = GetPeers(item);
return result;

View File

@ -6,7 +6,7 @@ public class TorrentInfo : ReleaseInfo
{
public string MagnetUrl { get; set; }
public string InfoHash { get; set; }
public Int32? Seeds { get; set; }
public Int32? Seeders { get; set; }
public Int32? Peers { get; set; }
public static Int32? GetSeeders(ReleaseInfo release)
@ -17,7 +17,7 @@ public class TorrentInfo : ReleaseInfo
{
return null;
}
return torrentInfo.Seeds;
return torrentInfo.Seeders;
}
}
}

View File

@ -19,7 +19,7 @@
@import "../Hotkeys/hotkeys";
.main-region {
@media (min-width: @screen-lg-min) {
@media (min-width : @screen-lg-min) {
padding-left : 30px;
padding-right : 30px;
}
@ -28,12 +28,12 @@
.toolbar {
&:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
visibility : hidden;
display : block;
font-size : 0;
content : " ";
clear : both;
height : 0;
}
.page-toolbar {
@ -41,13 +41,13 @@
margin-bottom : 30px;
.toolbar-group {
display: inline-block;
display : inline-block;
}
.sorting-buttons {
.sorting-title {
display: inline-block;
width: 110px;
display : inline-block;
width : 110px;
}
}
}
@ -86,7 +86,7 @@
.control-panel-visible {
#scroll-up {
bottom: 100px;
bottom : 100px;
}
}
@ -101,7 +101,7 @@
}
.label-disabled {
opacity: 0.5;
opacity : 0.5;
}
th {
@ -123,10 +123,9 @@ a, .btn {
}
body {
background:
url('../Content/Images/background/logo.png') 50px center no-repeat fixed,#272727;
background : url('../Content/Images/background/logo.png') 50px center no-repeat fixed, #272727;
margin-bottom : 100px;
margin-bottom : 100px;
p {
font-size : 0.9em;
}
@ -163,10 +162,10 @@ body {
.card(#aaaaaa);
/* width : 1210px;
min-width : 1210px; */
max-width : 1210px;
margin : auto;
// margin-top : -70px;
padding : 20px 0px;
max-width : 1210px;
margin : auto;
// margin-top : -70px;
padding : 20px 0px;
.header {
padding-bottom : 10px;
@ -203,15 +202,15 @@ body {
}
.error {
background: #FF0000;
background : #FF0000;
}
#errors{
#errors {
display : none;
}
.mono-space {
font-family: "ubuntu mono"
font-family : "ubuntu mono"
}
.file-path {
@ -221,26 +220,26 @@ body {
.control-panel {
.card(#333333);
color: #f5f5f5;
background-color: #333333;
margin: 0px;
margin-bottom: -100px;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 80px;
opacity: 0;
color : #f5f5f5;
background-color : #333333;
margin : 0px;
margin-bottom : -100px;
position : fixed;
left : 0;
bottom : 0;
width : 100%;
height : 80px;
opacity : 0;
@media (max-width: @screen-sm-max) {
height: initial;
position: static;
@media (max-width : @screen-sm-max) {
height : initial;
position : static;
}
}
.tab-content {
.tab-pane {
padding-top: 10px;
padding-top : 10px;
}
}
@ -251,6 +250,17 @@ body {
}
}
.modal-body {
table {
font-size : 12px;
font-weight : bold;
i {
font-size : 14px;
}
}
}
.tooltip {
.tooltip-inner {
max-width : 250px;
@ -259,6 +269,16 @@ body {
dl.info {
dt, dd {
padding-bottom: 5px;
padding-bottom : 5px;
}
}
.label {
&.protocol-torrent {
background-color : #00853D;
}
&.protocol-usenet {
background-color : #17B1D9;
}
}

View File

@ -8,8 +8,10 @@ define(
'Cells/QualityCell',
'Cells/ApprovalStatusCell',
'Release/DownloadReportCell',
'Release/AgeCell'
], function (Marionette, Backgrid, ReleaseTitleCell, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell, AgeCell) {
'Release/AgeCell',
'Release/ProtocolCell',
'Release/PeersCell'
], function (Marionette, Backgrid, ReleaseTitleCell, FileSizeCell, QualityCell, ApprovalStatusCell, DownloadReportCell, AgeCell, ProtocolCell, PeersCell) {
return Marionette.Layout.extend({
template: 'Episode/Search/ManualLayoutTemplate',
@ -21,6 +23,10 @@ define(
columns:
[
{
name : 'protocol',
label : 'Source',
cell : ProtocolCell
}, {
name : 'age',
label : 'Age',
cell : AgeCell
@ -40,6 +46,11 @@ define(
label : 'Size',
cell : FileSizeCell
},
{
name : 'seeders',
label : 'Peers',
cell : PeersCell
},
{
name : 'quality',
label : 'Quality',

View File

@ -0,0 +1,34 @@
'use strict';
define(['backgrid'], function (Backgrid) {
return Backgrid.Cell.extend({
className : 'peers-cell',
render : function () {
if (this.model.get('protocol') === 'torrent') {
var seeders = this.model.get('seeders') || 0;
var leechers = this.model.get('leechers') || 0;
var level = 'danger';
if(seeders > 0){
level='warning';
}
if(seeders > 10){
level = 'info';
}
if(seeders > 50){
level = 'primary';
}
this.$el.html('<div class="label label-{2}" title="{0} seeders, {1} leechers">{0} / {1}</div>'.format(seeders, leechers, level));
}
this.delegateEvents();
return this;
}
});
});

View File

@ -0,0 +1,28 @@
'use strict';
define(['backgrid'], function (Backgrid) {
return Backgrid.Cell.extend({
className : 'protocol-cell',
render : function () {
var protocol = this.model.get('protocol') || 'Unknown';
var label = '??';
if (protocol) {
if (protocol === 'torrent') {
label = 'torrent';
}
else if (protocol === 'usenet') {
label = 'nzb';
}
this.$el.html('<div class="label label-default protocol-{0}" title="{0}">{1}</div>'.format(protocol, label));
}
this.delegateEvents();
return this;
}
});
});

View File

@ -1,4 +1,4 @@
'use strict';
'use strict';
define(
[
'backbone.pageable',
@ -19,7 +19,7 @@ define(
sortMappings: {
'quality' : { sortKey: 'qualityWeight' },
'rejections' : { sortValue: function (model, attr) {
'rejections' : { sortValue: function (model) {
var rejections = model.get('rejections');
var releaseWeight = model.get('releaseWeight');