mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
Refactor work
This commit is contained in:
parent
c3e0eba92c
commit
7ae21fbc85
8 changed files with 34 additions and 23 deletions
|
@ -97,7 +97,7 @@ namespace Roadie.Api.Services
|
|||
this.AudioMetaDataHelper = new AudioMetaDataHelper(configuration, httpEncoder, context, this.MusicBrainzProvider, this.LastFmHelper, cacheManager,
|
||||
logger, this.ArtistLookupEngine, this.ImageFactory, this.FileNameHelper, this.ID3TagsHelper);
|
||||
this.ReleaseFactory = new ReleaseFactory(configuration, httpEncoder, context, cacheManager, logger, this.ArtistLookupEngine, this.LabelFactory, this.AudioMetaDataHelper, this.ReleaseLookupEngine);
|
||||
this.ArtistFactory = new ArtistFactory(configuration, httpEncoder, context, cacheManager, logger, this.ArtistLookupEngine, this.ReleaseFactory, this.ImageFactory, this.ReleaseLookupEngine);
|
||||
this.ArtistFactory = new ArtistFactory(configuration, httpEncoder, context, cacheManager, logger, this.ArtistLookupEngine, this.ReleaseFactory, this.ImageFactory, this.ReleaseLookupEngine, this.AudioMetaDataHelper);
|
||||
}
|
||||
|
||||
private void EventMessageLogger_Messages(object sender, EventMessage e)
|
||||
|
@ -176,7 +176,7 @@ namespace Roadie.Api.Services
|
|||
await this.LogAndPublish($"** Processing Folder: [{d.FullName}]");
|
||||
|
||||
long processedFolders = 0;
|
||||
var folderProcessor = new FolderProcessor(this.Configuration, this.HttpEncoder, this.Configuration.LibraryFolder, this.DbContext, this.CacheManager, this.MessageLogger, this.ArtistLookupEngine, this.ArtistFactory, this.ReleaseFactory, this.ImageFactory);
|
||||
var folderProcessor = new FolderProcessor(this.Configuration, this.HttpEncoder, this.Configuration.LibraryFolder, this.DbContext, this.CacheManager, this.MessageLogger, this.ArtistLookupEngine, this.ArtistFactory, this.ReleaseFactory, this.ImageFactory, this.ReleaseLookupEngine, this.AudioMetaDataHelper);
|
||||
|
||||
var newArtists = 0;
|
||||
var newReleases = 0;
|
||||
|
|
|
@ -8,6 +8,7 @@ using Roadie.Library.Engines;
|
|||
using Roadie.Library.Enums;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Processors;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
|
@ -35,13 +36,15 @@ namespace Roadie.Library.Factories
|
|||
|
||||
private IReleaseFactory ReleaseFactory { get; }
|
||||
private IImageFactory ImageFactory { get; }
|
||||
private IAudioMetaDataHelper AudioMetaDataHelper { get; }
|
||||
|
||||
public ArtistFactory(IRoadieSettings configuration, IHttpEncoder httpEncoder, IRoadieDbContext context,
|
||||
ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IReleaseFactory releaseFactory, IImageFactory imageFactory, IReleaseLookupEngine releaseLookupEngine)
|
||||
ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IReleaseFactory releaseFactory, IImageFactory imageFactory, IReleaseLookupEngine releaseLookupEngine, IAudioMetaDataHelper audioMetaDataHelper)
|
||||
: base(configuration, context, cacheManager, logger, httpEncoder, artistLookupEngine, releaseLookupEngine)
|
||||
{
|
||||
this.ReleaseFactory = releaseFactory;
|
||||
this.ImageFactory = imageFactory;
|
||||
this.AudioMetaDataHelper = audioMetaDataHelper;
|
||||
}
|
||||
|
||||
public async Task<OperationResult<bool>> Delete(Guid RoadieId)
|
||||
|
@ -299,7 +302,7 @@ namespace Roadie.Library.Factories
|
|||
}
|
||||
}
|
||||
// Any folder found in Artist folder not already scanned scan
|
||||
var folderProcessor = new FolderProcessor(this.Configuration, this.HttpEncoder, destinationFolder, this.DbContext, this.CacheManager, this.Logger, this.ArtistLookupEngine, this, this.ReleaseFactory, this.ImageFactory);
|
||||
var folderProcessor = new FolderProcessor(this.Configuration, this.HttpEncoder, destinationFolder, this.DbContext, this.CacheManager, this.Logger, this.ArtistLookupEngine, this, this.ReleaseFactory, this.ImageFactory, this.ReleaseLookupEngine, this.AudioMetaDataHelper);
|
||||
var nonReleaseFolders = (from d in Directory.EnumerateDirectories(ArtistFolder)
|
||||
where !(from r in scannedArtistFolders select r).Contains(d)
|
||||
orderby d
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace Roadie.Library.Factories
|
|||
protected ILogger Logger { get; }
|
||||
protected IReleaseLookupEngine ReleaseLookupEngine { get; }
|
||||
|
||||
|
||||
public FactoryBase(IRoadieSettings configuration, IRoadieDbContext context, ICacheManager cacheManager, ILogger logger, IHttpEncoder httpEncoder, IArtistLookupEngine artistLookupEngine, IReleaseLookupEngine releaseLookupEngine)
|
||||
{
|
||||
this.Configuration = configuration;
|
||||
|
|
|
@ -7,6 +7,7 @@ using Roadie.Library.Extensions;
|
|||
using Roadie.Library.Factories;
|
||||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.MetaData.LastFm;
|
||||
using Roadie.Library.MetaData.MusicBrainz;
|
||||
using Roadie.Library.Utility;
|
||||
|
@ -48,9 +49,11 @@ namespace Roadie.Library.FilePlugins
|
|||
ICacheManager cacheManager,
|
||||
ILogger logger,
|
||||
IArtistLookupEngine artistLookupEngine,
|
||||
IReleaseLookupEngine releaseLookupEngine)
|
||||
IReleaseLookupEngine releaseLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper)
|
||||
: base(configuration, httpEncoder, artistFactory, releaseFactory, imageFactory, cacheManager, logger, artistLookupEngine, releaseLookupEngine)
|
||||
{
|
||||
this.AudioMetaDataHelper = audioMetaDataHelper;
|
||||
}
|
||||
|
||||
public override async Task<OperationResult<bool>> Process(string destinationRoot, FileInfo fileInfo, bool doJustInfo, int? submissionId)
|
||||
|
|
|
@ -15,13 +15,6 @@ namespace Roadie.Library.FilePlugins
|
|||
{
|
||||
public abstract class PluginBase : IFilePlugin
|
||||
{
|
||||
//protected readonly ICacheManager _cacheManager = null;
|
||||
//protected readonly IRoadieSettings _configuration = null;
|
||||
//protected readonly IHttpEncoder _httpEncoder = null;
|
||||
//protected readonly IImageFactory _imageFactory = null;
|
||||
//protected readonly ILogger _logger = null;
|
||||
//protected readonly IReleaseFactory _releaseFactory = null;
|
||||
//protected IID3TagsHelper _id3TagsHelper = null;
|
||||
public abstract string[] HandlesTypes { get; }
|
||||
|
||||
public int MinWeightToDelete
|
||||
|
@ -41,8 +34,6 @@ namespace Roadie.Library.FilePlugins
|
|||
|
||||
protected IHttpEncoder HttpEncoder { get; }
|
||||
|
||||
protected IID3TagsHelper ID3TagsHelper { get; }
|
||||
|
||||
protected IImageFactory ImageFactory { get; }
|
||||
|
||||
protected ILogger Logger { get; }
|
||||
|
|
|
@ -7,7 +7,8 @@ using Roadie.Library.Engines;
|
|||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Factories;
|
||||
using Roadie.Library.FilePlugins;
|
||||
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -38,7 +39,11 @@ namespace Roadie.Library.Processors
|
|||
{
|
||||
if (t.GetInterface("IFilePlugin") != null && !t.IsAbstract && !t.IsInterface)
|
||||
{
|
||||
IFilePlugin plugin = Activator.CreateInstance(t, new object[] { this.Configuration, this.HttpEncoder, this.ArtistFactory, this.ReleaseFactory, this.ImageFactory, this.CacheManager, this.Logger }) as IFilePlugin;
|
||||
|
||||
|
||||
IFilePlugin plugin = Activator.CreateInstance(t, new object[] { this.Configuration, this.HttpEncoder, this.ArtistFactory, this.ReleaseFactory,
|
||||
this.ImageFactory, this.CacheManager, this.Logger, this.ArtistLookupEngine,
|
||||
this.ReleaseLookupEngine, this.AudioMetaDataHelper}) as IFilePlugin;
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +58,8 @@ namespace Roadie.Library.Processors
|
|||
}
|
||||
}
|
||||
|
||||
public FileProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder, string destinationRoot, IRoadieDbContext context, ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory)
|
||||
: base(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory)
|
||||
public FileProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder, string destinationRoot, IRoadieDbContext context, ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory, IReleaseLookupEngine releaseLookupEngine, IAudioMetaDataHelper audioMetaDataHelper )
|
||||
: base(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory, releaseLookupEngine, audioMetaDataHelper)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ using Roadie.Library.Engines;
|
|||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Factories;
|
||||
using Roadie.Library.FilePlugins;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -30,11 +32,11 @@ namespace Roadie.Library.Processors
|
|||
}
|
||||
}
|
||||
|
||||
public FolderProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder, string destinationRoot, IRoadieDbContext context, ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory)
|
||||
: base(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory)
|
||||
public FolderProcessor(IRoadieSettings configuration, IHttpEncoder httpEncoder, string destinationRoot, IRoadieDbContext context, ICacheManager cacheManager, ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory, IReleaseLookupEngine releaseLookupEngine, IAudioMetaDataHelper audioMetaDataHelper)
|
||||
: base(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory, releaseLookupEngine, audioMetaDataHelper)
|
||||
{
|
||||
SimpleContract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(destinationRoot), "Invalid Destination Folder");
|
||||
this._fileProcessor = new FileProcessor(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory);
|
||||
this._fileProcessor = new FileProcessor(configuration, httpEncoder, destinationRoot, context, cacheManager, logger, artistLookupEngine, artistFactory, releaseFactory, imageFactory, releaseLookupEngine, audioMetaDataHelper);
|
||||
}
|
||||
|
||||
public static OperationResult<bool> DeleteEmptyFolders(DirectoryInfo processingFolder, ILogger logger)
|
||||
|
|
|
@ -5,7 +5,8 @@ using Roadie.Library.Data;
|
|||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Engines;
|
||||
using Roadie.Library.Factories;
|
||||
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
|
||||
namespace Roadie.Library.Processors
|
||||
{
|
||||
|
@ -50,6 +51,7 @@ namespace Roadie.Library.Processors
|
|||
|
||||
protected IReleaseFactory ReleaseFactory { get; }
|
||||
|
||||
|
||||
protected string UnknownFolder
|
||||
{
|
||||
get
|
||||
|
@ -59,9 +61,11 @@ namespace Roadie.Library.Processors
|
|||
}
|
||||
|
||||
protected IArtistLookupEngine ArtistLookupEngine { get; }
|
||||
protected IReleaseLookupEngine ReleaseLookupEngine { get; }
|
||||
protected IAudioMetaDataHelper AudioMetaDataHelper { get; }
|
||||
|
||||
public ProcessorBase(IRoadieSettings configuration, IHttpEncoder httpEncoder, string destinationRoot, IRoadieDbContext context, ICacheManager cacheManager,
|
||||
ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory)
|
||||
ILogger logger, IArtistLookupEngine artistLookupEngine, IArtistFactory artistFactory, IReleaseFactory releaseFactory, IImageFactory imageFactory, IReleaseLookupEngine releaseLookupEngine, IAudioMetaDataHelper audioMetaDataHelper)
|
||||
{
|
||||
this.Configuration = configuration;
|
||||
this.HttpEncoder = httpEncoder;
|
||||
|
@ -71,9 +75,11 @@ namespace Roadie.Library.Processors
|
|||
|
||||
this.DestinationRoot = destinationRoot;
|
||||
this.ArtistLookupEngine = artistLookupEngine;
|
||||
this.ReleaseLookupEngine = releaseLookupEngine;
|
||||
this.ArtistFactory = artistFactory;
|
||||
this.ReleaseFactory = releaseFactory;
|
||||
this.ImageFactory = imageFactory;
|
||||
this.AudioMetaDataHelper = audioMetaDataHelper;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue