mirror of
https://github.com/Readarr/Readarr.git
synced 2026-03-26 17:44:27 -04:00
Compare commits
4 Commits
v0.1.4.159
...
sonarr-pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcffb2fce3 | ||
|
|
d77aa82961 | ||
|
|
c7a4060c4c | ||
|
|
64e6f98683 |
@@ -9,7 +9,7 @@ variables:
|
||||
testsFolder: './_tests'
|
||||
yarnCacheFolder: $(Pipeline.Workspace)/.yarn
|
||||
nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages
|
||||
majorVersion: '0.1.4'
|
||||
majorVersion: '0.1.5'
|
||||
minorVersion: $[counter('minorVersion', 1)]
|
||||
readarrVersion: '$(majorVersion).$(minorVersion)'
|
||||
buildName: '$(Build.SourceBranchName).$(readarrVersion)'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
@@ -275,7 +276,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
||||
|
||||
[TestCase(-1)] // Infinite/Unknown
|
||||
[TestCase(-2)] // Magnet Downloading
|
||||
public void should_ignore_negative_eta(int eta)
|
||||
public void should_ignore_negative_eta(long eta)
|
||||
{
|
||||
_completed.Eta = eta;
|
||||
|
||||
@@ -284,6 +285,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.TransmissionTests
|
||||
item.RemainingTime.Should().NotHaveValue();
|
||||
}
|
||||
|
||||
[TestCase(2147483648)] // 2038-01-19T03:14:08Z > int.MaxValue as unix timestamp can be either an int or a long
|
||||
public void should_support_long_values_for_eta_in_seconds(long eta)
|
||||
{
|
||||
_downloading.Eta = eta;
|
||||
|
||||
PrepareClientToReturnDownloadingItem();
|
||||
var item = Subject.GetItems().Single();
|
||||
item.RemainingTime.Should().Be(TimeSpan.FromSeconds(eta));
|
||||
}
|
||||
|
||||
[TestCase(2147483648000)] // works with milliseconds format too
|
||||
public void should_support_long_values_for_eta_in_milliseconds(long eta)
|
||||
{
|
||||
_downloading.Eta = eta;
|
||||
|
||||
PrepareClientToReturnDownloadingItem();
|
||||
var item = Subject.GetItems().Single();
|
||||
item.RemainingTime.Should().Be(TimeSpan.FromMilliseconds(eta));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_removable_and_should_not_allow_move_files_if_max_ratio_reached_and_not_stopped()
|
||||
{
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.VuzeTests
|
||||
|
||||
[TestCase(-1)] // Infinite/Unknown
|
||||
[TestCase(-2)] // Magnet Downloading
|
||||
public void should_ignore_negative_eta(int eta)
|
||||
public void should_ignore_negative_eta(long eta)
|
||||
{
|
||||
_completed.Eta = eta;
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
using System.Collections.Generic;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
[TestFixture]
|
||||
public class MatchesGrabSpecificationFixture : CoreTest<MatchesGrabSpecification>
|
||||
{
|
||||
private Episode _episode1;
|
||||
private Episode _episode2;
|
||||
private Episode _episode3;
|
||||
private LocalEpisode _localEpisode;
|
||||
private DownloadClientItem _downloadClientItem;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_episode1 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Id = 1)
|
||||
.Build();
|
||||
|
||||
_episode2 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Id = 2)
|
||||
.Build();
|
||||
|
||||
_episode3 = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Id = 3)
|
||||
.Build();
|
||||
|
||||
_localEpisode = Builder<LocalEpisode>.CreateNew()
|
||||
.With(l => l.Path = @"C:\Test\Unsorted\Series.Title.S01E01.720p.HDTV-Sonarr\S01E05.mkv".AsOsAgnostic())
|
||||
.With(l => l.Episodes = new List<Episode> { _episode1 })
|
||||
.Build();
|
||||
|
||||
_downloadClientItem = Builder<DownloadClientItem>.CreateNew().Build();
|
||||
}
|
||||
|
||||
private void GivenHistoryForEpisodes(params Episode[] episodes)
|
||||
{
|
||||
var history = new List<EpisodeHistory>();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
{
|
||||
history.Add(Builder<EpisodeHistory>.CreateNew()
|
||||
.With(h => h.EventType = EpisodeHistoryEventType.Grabbed)
|
||||
.With(h => h.EpisodeId = episode.Id)
|
||||
.Build());
|
||||
}
|
||||
|
||||
Mocker.GetMock<IHistoryService>()
|
||||
.Setup(s => s.FindByDownloadId(It.IsAny<string>()))
|
||||
.Returns(history);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_for_existing_file()
|
||||
{
|
||||
_localEpisode.ExistingFile = true;
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_no_download_client_item()
|
||||
{
|
||||
Subject.IsSatisfiedBy(_localEpisode, null).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_no_grab_history()
|
||||
{
|
||||
GivenHistoryForEpisodes();
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_file_episode_matches_single_grab_history()
|
||||
{
|
||||
GivenHistoryForEpisodes(_episode1);
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_accepted_if_file_episode_is_in_multi_episode_grab_history()
|
||||
{
|
||||
GivenHistoryForEpisodes(_episode1, _episode2);
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_rejected_if_file_episode_does_not_match_single_grab_history()
|
||||
{
|
||||
GivenHistoryForEpisodes(_episode2);
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_rejected_if_file_episode_is_not_in_multi_episode_grab_history()
|
||||
{
|
||||
GivenHistoryForEpisodes(_episode2, _episode3);
|
||||
|
||||
Subject.IsSatisfiedBy(_localEpisode, _downloadClientItem).Accepted.Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,14 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
|
||||
if (torrent.Eta >= 0)
|
||||
{
|
||||
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
|
||||
try
|
||||
{
|
||||
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
item.RemainingTime = TimeSpan.FromMilliseconds(torrent.Eta);
|
||||
}
|
||||
}
|
||||
|
||||
if (!torrent.ErrorString.IsNullOrWhiteSpace())
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||
public long TotalSize { get; set; }
|
||||
public long LeftUntilDone { get; set; }
|
||||
public bool IsFinished { get; set; }
|
||||
public int Eta { get; set; }
|
||||
public long Eta { get; set; }
|
||||
public TransmissionTorrentStatus Status { get; set; }
|
||||
public int SecondsDownloading { get; set; }
|
||||
public int SecondsSeeding { get; set; }
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.MediaFiles.EpisodeImport.Specifications
|
||||
{
|
||||
public class MatchesGrabSpecification : IImportDecisionEngineSpecification
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private readonly IParsingService _parsingService;
|
||||
private readonly IHistoryService _historyService;
|
||||
|
||||
public MatchesGrabSpecification(IParsingService parsingService, IHistoryService historyService, Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_parsingService = parsingService;
|
||||
_historyService = historyService;
|
||||
}
|
||||
|
||||
public Decision IsSatisfiedBy(LocalEpisode localEpisode, DownloadClientItem downloadClientItem)
|
||||
{
|
||||
if (localEpisode.ExistingFile)
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
if (downloadClientItem == null)
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var grabbedHistory = _historyService.FindByDownloadId(downloadClientItem.DownloadId)
|
||||
.Where(h => h.EventType == EpisodeHistoryEventType.Grabbed)
|
||||
.ToList();
|
||||
|
||||
if (grabbedHistory.Empty())
|
||||
{
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
var unexpected = localEpisode.Episodes.Where(e => grabbedHistory.All(o => o.EpisodeId != e.Id)).ToList();
|
||||
|
||||
if (unexpected.Any())
|
||||
{
|
||||
_logger.Debug("Unexpected episode(s) in file: {0}", FormatEpisode(unexpected));
|
||||
|
||||
if (unexpected.Count == 1)
|
||||
{
|
||||
return Decision.Reject("Episode {0} was not found in the grabbed release: {1}", FormatEpisode(unexpected), grabbedHistory.First().SourceTitle);
|
||||
}
|
||||
|
||||
return Decision.Reject("Episodes {0} were not found in the grabbed release: {1}", FormatEpisode(unexpected), grabbedHistory.First().SourceTitle);
|
||||
}
|
||||
|
||||
return Decision.Accept();
|
||||
}
|
||||
|
||||
private string FormatEpisode(List<Episode> episodes)
|
||||
{
|
||||
return string.Join(", ", episodes.Select(e => $"{e.SeasonNumber}x{e.EpisodeNumber:00}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
|
||||
}
|
||||
|
||||
ImageUrl = element.ElementAsString("image_url");
|
||||
ImageUrl = element.ElementAsString("large_image_url");
|
||||
LargeImageUrl = element.ElementAsString("large_image_url");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user