|
|
@ -1,17 +1,15 @@
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Common.Disk;
|
|
|
|
using NzbDrone.Common.Exceptions;
|
|
|
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Extras;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Languages;
|
|
|
|
using NzbDrone.Core.MediaFiles.Events;
|
|
|
|
using NzbDrone.Core.MediaFiles.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using NzbDrone.Core.Qualities;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Extras;
|
|
|
|
|
|
|
|
using NzbDrone.Core.Languages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -29,14 +27,14 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
private readonly IEventAggregator _eventAggregator;
|
|
|
|
private readonly IEventAggregator _eventAggregator;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
|
|
public ImportApprovedTracks(IUpgradeMediaFiles episodeFileUpgrader,
|
|
|
|
public ImportApprovedTracks(IUpgradeMediaFiles trackFileUpgrader,
|
|
|
|
IMediaFileService mediaFileService,
|
|
|
|
IMediaFileService mediaFileService,
|
|
|
|
IExtraService extraService,
|
|
|
|
IExtraService extraService,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
IDiskProvider diskProvider,
|
|
|
|
IEventAggregator eventAggregator,
|
|
|
|
IEventAggregator eventAggregator,
|
|
|
|
Logger logger)
|
|
|
|
Logger logger)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_trackFileUpgrader = episodeFileUpgrader;
|
|
|
|
_trackFileUpgrader = trackFileUpgrader;
|
|
|
|
_mediaFileService = mediaFileService;
|
|
|
|
_mediaFileService = mediaFileService;
|
|
|
|
_extraService = extraService;
|
|
|
|
_extraService = extraService;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
|
_diskProvider = diskProvider;
|
|
|
@ -55,6 +53,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var importResults = new List<ImportResult>();
|
|
|
|
var importResults = new List<ImportResult>();
|
|
|
|
|
|
|
|
var allImportedTrackFiles = new List<TrackFile>();
|
|
|
|
|
|
|
|
var allOldTrackFiles = new List<TrackFile>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var importDecision in qualifiedImports.OrderBy(e => e.LocalTrack.Tracks.Select(track => track.AbsoluteTrackNumber).MinOrDefault())
|
|
|
|
foreach (var importDecision in qualifiedImports.OrderBy(e => e.LocalTrack.Tracks.Select(track => track.AbsoluteTrackNumber).MinOrDefault())
|
|
|
|
.ThenByDescending(e => e.LocalTrack.Size))
|
|
|
|
.ThenByDescending(e => e.LocalTrack.Size))
|
|
|
@ -130,6 +130,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
_extraService.ImportTrack(localTrack, trackFile, copyOnly);
|
|
|
|
_extraService.ImportTrack(localTrack, trackFile, copyOnly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
allImportedTrackFiles.Add(trackFile);
|
|
|
|
|
|
|
|
allOldTrackFiles.AddRange(oldFiles);
|
|
|
|
|
|
|
|
|
|
|
|
_eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, oldFiles, newDownload, downloadClientItem));
|
|
|
|
_eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, oldFiles, newDownload, downloadClientItem));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -167,7 +170,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
|
|
|
|
|
|
|
|
|
|
|
if (albumImport.Where(e => e.Errors.Count == 0).ToList().Count > 0 && artist != null && album != null)
|
|
|
|
if (albumImport.Where(e => e.Errors.Count == 0).ToList().Count > 0 && artist != null && album != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_eventAggregator.PublishEvent(new AlbumImportedEvent(artist, album, albumImport.Select(e => e.ImportDecision.LocalTrack).ToList(), newDownload, downloadClientItem));
|
|
|
|
_eventAggregator.PublishEvent(new AlbumImportedEvent(
|
|
|
|
|
|
|
|
artist,
|
|
|
|
|
|
|
|
album,
|
|
|
|
|
|
|
|
allImportedTrackFiles.Where(s => s.AlbumId == album.Id).ToList(),
|
|
|
|
|
|
|
|
allOldTrackFiles.Where(s => s.AlbumId == album.Id).ToList(), newDownload,
|
|
|
|
|
|
|
|
downloadClientItem));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|