mirror of
https://github.com/Lidarr/Lidarr
synced 2025-12-06 08:25:54 +01:00
Fixed: Custom List try id search for album not only artist
This commit is contained in:
parent
323b366ac6
commit
9644702add
1 changed files with 39 additions and 3 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using FluentValidation.Results;
|
using FluentValidation.Results;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
|
|
@ -12,12 +14,14 @@ namespace NzbDrone.Core.ImportLists.Custom
|
||||||
public class CustomImport : ImportListBase<CustomSettings>
|
public class CustomImport : ImportListBase<CustomSettings>
|
||||||
{
|
{
|
||||||
private readonly ICustomImportProxy _customProxy;
|
private readonly ICustomImportProxy _customProxy;
|
||||||
|
private readonly ISearchForNewAlbum _albumSearchService;
|
||||||
public override string Name => "Custom List";
|
public override string Name => "Custom List";
|
||||||
|
|
||||||
public override ImportListType ListType => ImportListType.Advanced;
|
public override ImportListType ListType => ImportListType.Advanced;
|
||||||
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
public override TimeSpan MinRefreshInterval => TimeSpan.FromHours(6);
|
||||||
|
|
||||||
public CustomImport(ICustomImportProxy customProxy,
|
public CustomImport(ICustomImportProxy customProxy,
|
||||||
|
ISearchForNewAlbum albumSearchService,
|
||||||
IImportListStatusService importListStatusService,
|
IImportListStatusService importListStatusService,
|
||||||
IConfigService configService,
|
IConfigService configService,
|
||||||
IParsingService parsingService,
|
IParsingService parsingService,
|
||||||
|
|
@ -25,6 +29,7 @@ public CustomImport(ICustomImportProxy customProxy,
|
||||||
: base(importListStatusService, configService, parsingService, logger)
|
: base(importListStatusService, configService, parsingService, logger)
|
||||||
{
|
{
|
||||||
_customProxy = customProxy;
|
_customProxy = customProxy;
|
||||||
|
_albumSearchService = albumSearchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IList<ImportListItemInfo> Fetch()
|
public override IList<ImportListItemInfo> Fetch()
|
||||||
|
|
@ -37,10 +42,41 @@ public override IList<ImportListItemInfo> Fetch()
|
||||||
|
|
||||||
foreach (var item in remoteSeries)
|
foreach (var item in remoteSeries)
|
||||||
{
|
{
|
||||||
artists.Add(new ImportListItemInfo
|
var importItem = new ImportListItemInfo();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ArtistMusicBrainzId = item.MusicBrainzId
|
var albumQuery = $"lidarr:{item.MusicBrainzId}";
|
||||||
});
|
var mappedAlbum = _albumSearchService.SearchForNewAlbum(albumQuery, null).FirstOrDefault();
|
||||||
|
|
||||||
|
if (mappedAlbum != null)
|
||||||
|
{
|
||||||
|
// MusicBrainzId was actually an album ID
|
||||||
|
importItem.AlbumMusicBrainzId = mappedAlbum.ForeignAlbumId;
|
||||||
|
importItem.Album = mappedAlbum.Title;
|
||||||
|
importItem.Artist = mappedAlbum.ArtistMetadata?.Value?.Name;
|
||||||
|
importItem.ArtistMusicBrainzId = mappedAlbum.ArtistMetadata?.Value?.ForeignArtistId;
|
||||||
|
|
||||||
|
_logger.Debug("Custom List item {0} identified as album: {1} - {2}",
|
||||||
|
item.MusicBrainzId,
|
||||||
|
importItem.Artist,
|
||||||
|
importItem.Album);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
importItem.ArtistMusicBrainzId = item.MusicBrainzId;
|
||||||
|
|
||||||
|
_logger.Debug("Custom List item {0} treated as artist ID", item.MusicBrainzId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Debug(ex, "Failed to search for album with ID {0}, treating as artist", item.MusicBrainzId);
|
||||||
|
|
||||||
|
importItem.ArtistMusicBrainzId = item.MusicBrainzId;
|
||||||
|
}
|
||||||
|
|
||||||
|
artists.Add(importItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
_importListStatusService.RecordSuccess(Definition.Id);
|
_importListStatusService.RecordSuccess(Definition.Id);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue