1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Fixed: Unable to update custom formats for releases with bad Source Titles.

This commit is contained in:
Leonardo Galli 2018-10-30 13:18:46 +01:00
parent 9ea739f6cb
commit a50b74c177

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.History;
using NzbDrone.Core.MediaFiles.Commands;
@ -9,6 +10,7 @@
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using RestSharp.Extensions;
namespace NzbDrone.Core.MediaFiles
{
@ -51,6 +53,7 @@ public void Execute(UpdateMovieFileQualityCommand command)
var history = _historyService.FindByMovieId(movieFile.MovieId).OrderByDescending(h => h.Date);
var latestImported = history.FirstOrDefault(h => h.EventType == HistoryEventType.DownloadFolderImported);
var latestImportedName = latestImported?.SourceTitle;
var latestGrabbed = history.FirstOrDefault(h => h.EventType == HistoryEventType.Grabbed);
var sizeMovie = new LocalMovie();
sizeMovie.Size = movieFile.Size;
@ -67,7 +70,18 @@ public void Execute(UpdateMovieFileQualityCommand command)
helpers.Add(latestGrabbed);
}
var parsedMovieInfo = _parsingService.ParseMovieInfo(latestImported?.SourceTitle ?? movieFile.RelativePath, helpers);
ParsedMovieInfo parsedMovieInfo = null;
if (latestImportedName?.IsNotNullOrWhiteSpace() == false)
{
parsedMovieInfo = _parsingService.ParseMovieInfo(latestImportedName, helpers);
}
if (parsedMovieInfo == null)
{
_logger.Debug("Could not parse movie info from history source title, using current path instead: {0}.", movieFile.RelativePath);
parsedMovieInfo = _parsingService.ParseMovieInfo(movieFile.RelativePath, helpers);
}
//Only update Custom formats for now.
if (parsedMovieInfo != null)
@ -78,7 +92,7 @@ public void Execute(UpdateMovieFileQualityCommand command)
}
else
{
_logger.Debug("Could not update custom formats for {0}, since it's title could not be parsed!", movieFile);
_logger.Warn("Could not update custom formats for {0}, since it's title could not be parsed!", movieFile);
}
count++;