Fixed: Automatic import of releases when file is not matched to series

(cherry picked from commit e280897bc7f5c55d11714b0c25e7220477c18886)
pull/3648/head
Mark McDowall 3 years ago committed by Bogdan
parent a3c33fe8cc
commit bbe73ee7da

@ -0,0 +1,14 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(067)]
public class add_additional_info_to_pending_releases : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("PendingReleases").AddColumn("AdditionalInfo").AsString().Nullable();
}
}
}

@ -229,6 +229,7 @@ namespace NzbDrone.Core.Datastore
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ParsedAlbumInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ParsedTrackInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<ReleaseInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<PendingReleaseAdditionalInfo>());
SqlMapper.AddTypeHandler(new EmbeddedDocumentConverter<HashSet<int>>());
SqlMapper.AddTypeHandler(new OsPathConverter());
SqlMapper.RemoveTypeMap(typeof(Guid));

@ -14,6 +14,7 @@ using NzbDrone.Core.MediaFiles.TrackImport;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Music;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Download
{
@ -93,10 +94,15 @@ namespace NzbDrone.Core.Download
if (artist == null)
{
trackedDownload.Warn("Artist name mismatch, automatic import is not possible.");
Enum.TryParse(historyItem.Data.GetValueOrDefault(EntityHistory.ARTIST_MATCH_TYPE, ArtistMatchType.Unknown.ToString()), out ArtistMatchType artistMatchType);
if (artistMatchType == ArtistMatchType.Id)
{
trackedDownload.Warn("Found matching artist via grab history, but release was matched to artist by ID. Automatic import is not possible.");
return;
}
}
}
trackedDownload.State = TrackedDownloadState.ImportPending;
}

@ -12,8 +12,14 @@ namespace NzbDrone.Core.Download.Pending
public ParsedAlbumInfo ParsedAlbumInfo { get; set; }
public ReleaseInfo Release { get; set; }
public PendingReleaseReason Reason { get; set; }
public PendingReleaseAdditionalInfo AdditionalInfo { get; set; }
// Not persisted
public RemoteAlbum RemoteAlbum { get; set; }
}
public class PendingReleaseAdditionalInfo
{
public ArtistMatchType ArtistMatchType { get; set; }
}
}

@ -300,8 +300,7 @@ namespace NzbDrone.Core.Download.Pending
List<Album> albums;
RemoteAlbum knownRemoteAlbum;
if (knownRemoteAlbums != null && knownRemoteAlbums.TryGetValue(release.Release.Title, out knownRemoteAlbum))
if (knownRemoteAlbums != null && knownRemoteAlbums.TryGetValue(release.Release.Title, out var knownRemoteAlbum))
{
albums = knownRemoteAlbum.Albums;
}
@ -313,6 +312,7 @@ namespace NzbDrone.Core.Download.Pending
release.RemoteAlbum = new RemoteAlbum
{
Artist = artist,
ArtistMatchType = release.AdditionalInfo?.ArtistMatchType ?? ArtistMatchType.Unknown,
Albums = albums,
ParsedAlbumInfo = release.ParsedAlbumInfo,
Release = release.Release
@ -336,7 +336,11 @@ namespace NzbDrone.Core.Download.Pending
Release = decision.RemoteAlbum.Release,
Title = decision.RemoteAlbum.Release.Title,
Added = DateTime.UtcNow,
Reason = reason
Reason = reason,
AdditionalInfo = new PendingReleaseAdditionalInfo
{
ArtistMatchType = decision.RemoteAlbum.ArtistMatchType
}
});
_eventAggregator.PublishEvent(new PendingReleasesUpdatedEvent());

@ -9,6 +9,7 @@ namespace NzbDrone.Core.History
public class EntityHistory : ModelBase
{
public const string DOWNLOAD_CLIENT = "downloadClient";
public const string ARTIST_MATCH_TYPE = "artistMatchType";
public EntityHistory()
{

@ -165,6 +165,7 @@ namespace NzbDrone.Core.History
history.Data.Add("Protocol", ((int)message.Album.Release.DownloadProtocol).ToString());
history.Data.Add("DownloadForced", (!message.Album.DownloadAllowed).ToString());
history.Data.Add("CustomFormatScore", message.Album.CustomFormatScore.ToString());
history.Data.Add("ArtistMatchType", message.Album.ArtistMatchType.ToString());
if (!message.Album.ParsedAlbumInfo.ReleaseHash.IsNullOrWhiteSpace())
{

@ -0,0 +1,24 @@
using NzbDrone.Core.Music;
namespace NzbDrone.Core.Parser.Model
{
public class FindArtistResult
{
public Artist Artist { get; set; }
public ArtistMatchType MatchType { get; set; }
public FindArtistResult(Artist artist, ArtistMatchType matchType)
{
Artist = artist;
MatchType = matchType;
}
}
public enum ArtistMatchType
{
Unknown = 0,
Title = 1,
Alias = 2,
Id = 3
}
}

@ -17,6 +17,7 @@ namespace NzbDrone.Core.Parser.Model
public TorrentSeedConfiguration SeedConfiguration { get; set; }
public List<CustomFormat> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public ArtistMatchType ArtistMatchType { get; set; }
public RemoteAlbum()
{

@ -103,7 +103,15 @@ namespace NzbDrone.Core.Parser
ParsedAlbumInfo = parsedAlbumInfo,
};
var artist = GetArtist(parsedAlbumInfo, searchCriteria);
Artist artist = null;
var artistMatch = FindArtist(parsedAlbumInfo, searchCriteria);
if (artistMatch != null)
{
artist = artistMatch.Artist;
remoteAlbum.ArtistMatchType = artistMatch.MatchType;
}
if (artist == null)
{
@ -188,7 +196,7 @@ namespace NzbDrone.Core.Parser
};
}
private Artist GetArtist(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria)
private FindArtistResult FindArtist(ParsedAlbumInfo parsedAlbumInfo, SearchCriteriaBase searchCriteria)
{
Artist artist = null;
@ -196,16 +204,27 @@ namespace NzbDrone.Core.Parser
{
if (searchCriteria.Artist.CleanName == parsedAlbumInfo.ArtistName.CleanArtistName())
{
return searchCriteria.Artist;
return new FindArtistResult(searchCriteria.Artist, ArtistMatchType.Title);
}
}
var matchType = ArtistMatchType.Unknown;
artist = _artistService.FindByName(parsedAlbumInfo.ArtistName);
if (artist != null)
{
matchType = ArtistMatchType.Title;
}
if (artist == null)
{
_logger.Debug("Trying inexact artist match for {0}", parsedAlbumInfo.ArtistName);
artist = _artistService.FindByNameInexact(parsedAlbumInfo.ArtistName);
if (artist != null)
{
matchType = ArtistMatchType.Title;
}
}
if (artist == null)
@ -214,7 +233,7 @@ namespace NzbDrone.Core.Parser
return null;
}
return artist;
return new FindArtistResult(artist, matchType);
}
public Album GetLocalAlbum(string filename, Artist artist)

Loading…
Cancel
Save