Merge pull request #103 from Taloth/develop

Styling episode Quality badge for Cutuff Unmet
pull/4/head
Mark McDowall 10 years ago
commit a933ab90ec

@ -11,6 +11,7 @@ using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Core.DecisionEngine;
namespace NzbDrone.Api.EpisodeFiles namespace NzbDrone.Api.EpisodeFiles
{ {
@ -20,18 +21,21 @@ namespace NzbDrone.Api.EpisodeFiles
private readonly IMediaFileService _mediaFileService; private readonly IMediaFileService _mediaFileService;
private readonly IRecycleBinProvider _recycleBinProvider; private readonly IRecycleBinProvider _recycleBinProvider;
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
private readonly Logger _logger; private readonly Logger _logger;
public EpisodeModule(ICommandExecutor commandExecutor, public EpisodeModule(ICommandExecutor commandExecutor,
IMediaFileService mediaFileService, IMediaFileService mediaFileService,
IRecycleBinProvider recycleBinProvider, IRecycleBinProvider recycleBinProvider,
ISeriesService seriesService, ISeriesService seriesService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
Logger logger) Logger logger)
: base(commandExecutor) : base(commandExecutor)
{ {
_mediaFileService = mediaFileService; _mediaFileService = mediaFileService;
_recycleBinProvider = recycleBinProvider; _recycleBinProvider = recycleBinProvider;
_seriesService = seriesService; _seriesService = seriesService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
_logger = logger; _logger = logger;
GetResourceById = GetEpisodeFile; GetResourceById = GetEpisodeFile;
GetResourceAll = GetEpisodeFiles; GetResourceAll = GetEpisodeFiles;
@ -80,11 +84,13 @@ namespace NzbDrone.Api.EpisodeFiles
_mediaFileService.Delete(episodeFile); _mediaFileService.Delete(episodeFile);
} }
private static EpisodeFileResource MapToResource(Core.Tv.Series series, EpisodeFile episodeFile) private EpisodeFileResource MapToResource(Core.Tv.Series series, EpisodeFile episodeFile)
{ {
var resource = episodeFile.InjectTo<EpisodeFileResource>(); var resource = episodeFile.InjectTo<EpisodeFileResource>();
resource.Path = Path.Combine(series.Path, episodeFile.RelativePath); resource.Path = Path.Combine(series.Path, episodeFile.RelativePath);
resource.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, episodeFile.Quality);
return resource; return resource;
} }

@ -14,5 +14,7 @@ namespace NzbDrone.Api.EpisodeFiles
public DateTime DateAdded { get; set; } public DateTime DateAdded { get; set; }
public String SceneName { get; set; } public String SceneName { get; set; }
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public Boolean QualityCutoffNotMet { get; set; }
} }
} }

@ -2,17 +2,23 @@
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.Api.Mapping;
using NzbDrone.Core.DecisionEngine;
namespace NzbDrone.Api.Episodes namespace NzbDrone.Api.Episodes
{ {
public class EpisodeModule : EpisodeModuleWithSignalR public class EpisodeModule : EpisodeModuleWithSignalR
{ {
private readonly ISeriesService _seriesService;
private readonly IEpisodeService _episodeService; private readonly IEpisodeService _episodeService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
public EpisodeModule(ICommandExecutor commandExecutor, IEpisodeService episodeService) public EpisodeModule(ICommandExecutor commandExecutor, ISeriesService seriesService, IEpisodeService episodeService, IQualityUpgradableSpecification qualityUpgradableSpecification)
: base(episodeService, commandExecutor) : base(episodeService, commandExecutor)
{ {
_seriesService = seriesService;
_episodeService = episodeService; _episodeService = episodeService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
GetResourceAll = GetEpisodes; GetResourceAll = GetEpisodes;
UpdateResource = SetMonitored; UpdateResource = SetMonitored;
@ -27,7 +33,21 @@ namespace NzbDrone.Api.Episodes
throw new BadRequestException("seriesId is missing"); throw new BadRequestException("seriesId is missing");
} }
return ToListResource(() => _episodeService.GetEpisodeBySeries(seriesId.Value)); var series = _seriesService.GetSeries(seriesId.Value);
var resources = new List<EpisodeResource>();
foreach (var episode in _episodeService.GetEpisodeBySeries(seriesId.Value))
{
var resource = episode.InjectTo<EpisodeResource>();
if (episode.EpisodeFile.IsLoaded)
{
resource.EpisodeFile.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, episode.EpisodeFile.Value.Quality);
}
resources.Add(resource);
}
return resources;
} }
private void SetMonitored(EpisodeResource episodeResource) private void SetMonitored(EpisodeResource episodeResource)

@ -9,7 +9,7 @@ using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Episodes namespace NzbDrone.Api.Episodes
{ {
public abstract class EpisodeModuleWithSignalR : NzbDroneRestModuleWithSignalR<EpisodeResource, Episode>, public abstract class EpisodeModuleWithSignalR : NzbDroneRestModuleWithSignalR<EpisodeResource, Episode>,
IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent> IHandle<EpisodeDownloadedEvent>
{ {
private readonly IEpisodeService _episodeService; private readonly IEpisodeService _episodeService;

@ -1,5 +1,6 @@
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
using NzbDrone.Api.EpisodeFiles;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
@ -15,7 +16,7 @@ namespace NzbDrone.Api.Episodes
public String AirDate { get; set; } public String AirDate { get; set; }
public DateTime? AirDateUtc { get; set; } public DateTime? AirDateUtc { get; set; }
public String Overview { get; set; } public String Overview { get; set; }
public EpisodeFile EpisodeFile { get; set; } public EpisodeFileResource EpisodeFile { get; set; }
public Boolean HasFile { get; set; } public Boolean HasFile { get; set; }
public Boolean Monitored { get; set; } public Boolean Monitored { get; set; }

@ -164,6 +164,7 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[Kaylith] Isshuukan Friends Specials - 01 [BD 720p AAC][B7EEE164].mkv", false)] [TestCase("[Kaylith] Isshuukan Friends Specials - 01 [BD 720p AAC][B7EEE164].mkv", false)]
[TestCase("WEEDS.S03E01-06.DUAL.Blu-ray.AC3.-HELLYWOOD.avi", false)] [TestCase("WEEDS.S03E01-06.DUAL.Blu-ray.AC3.-HELLYWOOD.avi", false)]
[TestCase("WEEDS.S03E01-06.DUAL.720p.Blu-ray.AC3.-HELLYWOOD.avi", false)] [TestCase("WEEDS.S03E01-06.DUAL.720p.Blu-ray.AC3.-HELLYWOOD.avi", false)]
[TestCase("[Elysium]Lucky.Star.01(BD.720p.AAC.DA)[0BB96AD8].mkv", false)]
public void should_parse_bluray720p_quality(string title, bool proper) public void should_parse_bluray720p_quality(string title, bool proper)
{ {
ParseAndVerifyQuality(title, Quality.Bluray720p, proper); ParseAndVerifyQuality(title, Quality.Bluray720p, proper);

@ -4,6 +4,7 @@ using MediaInfoLib;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Disk; using NzbDrone.Common.Disk;
using System.Globalization;
namespace NzbDrone.Core.MediaFiles.MediaInfo namespace NzbDrone.Core.MediaFiles.MediaInfo
{ {
@ -59,7 +60,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width); Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Width"), out width);
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height); Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "Height"), out height);
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate); Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "BitRate"), out videoBitRate);
Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), out videoFrameRate); Decimal.TryParse(mediaInfo.Get(StreamKind.Video, 0, "FrameRate"), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out videoFrameRate);
//Runtime //Runtime
Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out videoRuntime); Int32.TryParse(mediaInfo.Get(StreamKind.Video, 0, "PlayTime"), out videoRuntime);

@ -39,7 +39,7 @@ namespace NzbDrone.Core.Parser
private static readonly Regex OtherSourceRegex = new Regex(@"(?<hdtv>HD[-_. ]TV)|(?<sdtv>SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex OtherSourceRegex = new Regex(@"(?<hdtv>HD[-_. ]TV)|(?<sdtv>SD[-_. ]TV)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080)|(?<=\[|\(|\s)bd(?=\s|\)|\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex AnimeBlurayRegex = new Regex(@"bd(?:720|1080)|(?<=[-_. (\[])bd(?=[-_. )\]])", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex HighDefPdtvRegex = new Regex(@"hr[-_. ]ws", RegexOptions.Compiled | RegexOptions.IgnoreCase);

@ -52,7 +52,13 @@ define(
title += ' - {0}'.format(size); title += ' - {0}'.format(size);
} }
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name)); if (this.episodeFile.get('qualityCutoffNotMet')) {
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
else {
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
return; return;
} }

@ -86,6 +86,12 @@ td.episode-status-cell, td.quality-cell {
font-size: 9px; font-size: 9px;
} }
.badge-inverse {
background-color: #eee;
border: 1px solid @badge-bg;
color: @badge-bg;
}
.progress { .progress {
height : 10px; height : 10px;
margin-top : 5px; margin-top : 5px;

Loading…
Cancel
Save