Misc Fixes and Better Logging/Rejection Messages for Track Import

pull/221/head
Qstick 7 years ago
parent 425a9045b8
commit 8e626269d1

@ -218,16 +218,12 @@ class SignalRConnector extends Component {
} }
handleTrack = (body) => { handleTrack = (body) => {
const action = body.action; if (body.action === 'updated') {
const section = 'tracks';
if (action === 'updated') {
this.props.updateItem({ this.props.updateItem({
section, section: 'tracks',
updateOnly: true,
...body.resource ...body.resource
}); });
} else if (action === 'deleted') {
this.props.removeItem({ section, id: body.resource.id });
} }
} }

@ -5,7 +5,6 @@ using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Music.Events;
using NzbDrone.SignalR; using NzbDrone.SignalR;
using Lidarr.Api.V1.TrackFiles; using Lidarr.Api.V1.TrackFiles;
using Lidarr.Api.V1.Artist; using Lidarr.Api.V1.Artist;
@ -15,7 +14,6 @@ using NzbDrone.Core.MediaFiles.Events;
namespace Lidarr.Api.V1.Tracks namespace Lidarr.Api.V1.Tracks
{ {
public abstract class TrackModuleWithSignalR : LidarrRestModuleWithSignalR<TrackResource, Track>, public abstract class TrackModuleWithSignalR : LidarrRestModuleWithSignalR<TrackResource, Track>,
IHandle<TrackInfoRefreshedEvent>,
IHandle<TrackImportedEvent>, IHandle<TrackImportedEvent>,
IHandle<TrackFileDeletedEvent> IHandle<TrackFileDeletedEvent>
{ {
@ -107,24 +105,6 @@ namespace Lidarr.Api.V1.Tracks
return result; return result;
} }
public void Handle(TrackInfoRefreshedEvent message)
{
foreach (var track in message.Removed)
{
BroadcastResourceChange(ModelAction.Deleted, track.ToResource());
}
foreach (var track in message.Added)
{
BroadcastResourceChange(ModelAction.Updated, track.ToResource());
}
foreach (var track in message.Updated)
{
BroadcastResourceChange(ModelAction.Updated, track.Id);
}
}
public void Handle(TrackImportedEvent message) public void Handle(TrackImportedEvent message)
{ {
foreach (var track in message.TrackInfo.Tracks) foreach (var track in message.TrackInfo.Tracks)

@ -11,6 +11,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using NzbDrone.Core.Extras;
using NzbDrone.Core.Music; using NzbDrone.Core.Music;
using NzbDrone.Core.Languages; using NzbDrone.Core.Languages;
@ -25,7 +26,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
{ {
private readonly IUpgradeMediaFiles _trackFileUpgrader; private readonly IUpgradeMediaFiles _trackFileUpgrader;
private readonly IMediaFileService _mediaFileService; private readonly IMediaFileService _mediaFileService;
//private readonly IExtraService _extraService; private readonly IExtraService _extraService;
private readonly IDiskProvider _diskProvider; private readonly IDiskProvider _diskProvider;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IAlbumRepository _albumRepository; private readonly IAlbumRepository _albumRepository;
@ -33,7 +34,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
public ImportApprovedTracks(IUpgradeMediaFiles episodeFileUpgrader, public ImportApprovedTracks(IUpgradeMediaFiles episodeFileUpgrader,
IMediaFileService mediaFileService, IMediaFileService mediaFileService,
//IExtraService extraService, IExtraService extraService,
IAlbumRepository albumRepository, IAlbumRepository albumRepository,
IDiskProvider diskProvider, IDiskProvider diskProvider,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
@ -41,7 +42,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
{ {
_trackFileUpgrader = episodeFileUpgrader; _trackFileUpgrader = episodeFileUpgrader;
_mediaFileService = mediaFileService; _mediaFileService = mediaFileService;
// _extraService = extraService; _extraService = extraService;
_albumRepository = albumRepository; _albumRepository = albumRepository;
_diskProvider = diskProvider; _diskProvider = diskProvider;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
@ -129,10 +130,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
_mediaFileService.Add(trackFile); _mediaFileService.Add(trackFile);
importResults.Add(new ImportResult(importDecision)); importResults.Add(new ImportResult(importDecision));
//if (newDownload) if (newDownload)
//{ {
// _extraService.ImportExtraFiles(localTrack, trackFile, copyOnly); // TODO: Import Music Extras _extraService.ImportExtraFiles(localTrack, trackFile, copyOnly);
//} }
_eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, oldFiles, newDownload, downloadClientItem)); _eventAggregator.PublishEvent(new TrackImportedEvent(localTrack, trackFile, oldFiles, newDownload, downloadClientItem));

@ -94,7 +94,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
if (localTrack.Tracks.Empty()) if (localTrack.Tracks.Empty())
{ {
decision = new ImportDecision(localTrack, new Rejection("Invalid album or track")); decision = localTrack.Album != null ? new ImportDecision(localTrack, new Rejection($"Couldn't parse track from: {localTrack.ParsedTrackInfo}")) :
new ImportDecision(localTrack, new Rejection($"Couldn't parse album from: {localTrack.ParsedTrackInfo}"));
} }
else else
{ {

@ -12,14 +12,12 @@ namespace NzbDrone.Core.Music.Events
public Album Album { get; set; } public Album Album { get; set; }
public ReadOnlyCollection<Track> Added { get; private set; } public ReadOnlyCollection<Track> Added { get; private set; }
public ReadOnlyCollection<Track> Updated { get; private set; } public ReadOnlyCollection<Track> Updated { get; private set; }
public ReadOnlyCollection<Track> Removed { get; private set; }
public TrackInfoRefreshedEvent(Album album, IList<Track> added, IList<Track> updated, IList<Track> removed) public TrackInfoRefreshedEvent(Album album, IList<Track> added, IList<Track> updated)
{ {
Album = album; Album = album;
Added = new ReadOnlyCollection<Track>(added); Added = new ReadOnlyCollection<Track>(added);
Updated = new ReadOnlyCollection<Track>(updated); Updated = new ReadOnlyCollection<Track>(updated);
Removed = new ReadOnlyCollection<Track>(removed);
} }
} }
} }

@ -94,7 +94,7 @@ namespace NzbDrone.Core.Music
_trackService.UpdateMany(updateList); _trackService.UpdateMany(updateList);
_trackService.InsertMany(newList); _trackService.InsertMany(newList);
_eventAggregator.PublishEvent(new TrackInfoRefreshedEvent(album, newList, updateList, existingTracks)); _eventAggregator.PublishEvent(new TrackInfoRefreshedEvent(album, newList, updateList));
if (failCount != 0) if (failCount != 0)
{ {

@ -37,10 +37,10 @@ namespace NzbDrone.Core.Parser.Model
if (TrackNumbers != null && TrackNumbers.Any()) if (TrackNumbers != null && TrackNumbers.Any())
{ {
trackString = string.Format("T{0}", string.Join("-", TrackNumbers.Select(c => c.ToString("00")))); trackString = string.Format("{0}", string.Join("-", TrackNumbers.Select(c => c.ToString("00"))));
} }
return string.Format("{0} - {1} - {2}: {3}", ArtistTitle, AlbumTitle, trackString, Quality); return string.Format("{0} - {1} - {2}:{3} {4}: {5}", ArtistTitle, AlbumTitle, DiscNumber, trackString, Title, Quality);
} }
} }
} }

@ -11,6 +11,7 @@ using NzbDrone.Core.Music;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Languages; using NzbDrone.Core.Languages;
using TagLib; using TagLib;
using TagLib.IFD.Tags;
namespace NzbDrone.Core.Parser namespace NzbDrone.Core.Parser
{ {
@ -604,7 +605,6 @@ namespace NzbDrone.Core.Parser
private static ParsedTrackInfo ParseAudioTags(string path) private static ParsedTrackInfo ParseAudioTags(string path)
{ {
var fileInfo = new FileInfo(path);
var file = TagLib.File.Create(path); var file = TagLib.File.Create(path);
Logger.Debug("Starting Tag Parse for {0}", file.Name); Logger.Debug("Starting Tag Parse for {0}", file.Name);
@ -627,6 +627,7 @@ namespace NzbDrone.Core.Parser
var temp = new int[1]; var temp = new int[1];
temp[0] = (int)trackNumber; temp[0] = (int)trackNumber;
var result = new ParsedTrackInfo var result = new ParsedTrackInfo
{ {
Language = Language.English, //TODO Parse from Tag/Mediainfo Language = Language.English, //TODO Parse from Tag/Mediainfo
@ -641,6 +642,8 @@ namespace NzbDrone.Core.Parser
Title = trackTitle Title = trackTitle
}; };
Logger.Trace("File Tags Parsed: Artist: {0}, Album: {1}, Disc: {2}, Track Numbers(s): {3}, TrackTitle: {4}", result.ArtistTitle, result.AlbumTitle, result.DiscNumber, trackNumber, result.Title);
foreach (ICodec codec in file.Properties.Codecs) foreach (ICodec codec in file.Properties.Codecs)
{ {
IAudioCodec acodec = codec as IAudioCodec; IAudioCodec acodec = codec as IAudioCodec;

@ -286,16 +286,15 @@ namespace NzbDrone.Core.Parser
if (parsedTrackInfo.Title.IsNotNullOrWhiteSpace()) if (parsedTrackInfo.Title.IsNotNullOrWhiteSpace())
{ {
trackInfo = _trackService.FindTrackByTitle(artist.Id, album.Id, parsedTrackInfo.DiscNumber, parsedTrackInfo.Title); trackInfo = _trackService.FindTrackByTitle(artist.Id, album.Id, parsedTrackInfo.DiscNumber, parsedTrackInfo.Title);
_logger.Debug("Track {0} selected for {1}", trackInfo, parsedTrackInfo);
if (trackInfo != null) if (trackInfo != null)
{ {
_logger.Debug("Track {0} selected for {1}", trackInfo, parsedTrackInfo);
result.Add(trackInfo); result.Add(trackInfo);
} }
else else
{ {
_logger.Debug("Unable to find {0}", parsedTrackInfo); _logger.Debug("Unable to find track for {0}", parsedTrackInfo);
} }
} }

Loading…
Cancel
Save