mirror of
https://github.com/sphildreth/roadie
synced 2024-11-25 05:30:24 +00:00
Inspector work. Renamed 'disk' instances.
This commit is contained in:
parent
0732533bf7
commit
5711adaa28
20 changed files with 128 additions and 83 deletions
|
@ -58,7 +58,7 @@
|
|||
"MaximumArtistImagesToAdd": 12,
|
||||
"MaximumReleaseImagesToAdd": 12,
|
||||
"MaxImageWidth": 2048,
|
||||
"ReleaseRemoveStringsRegex": "(\\s*(-\\s)*((CD[0-9][0-9]*)))|((\\(|\\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\\s)+(]|\\)*))",
|
||||
"ReleaseRemoveStringsRegex": "(\\\\s*(-\\\\s)*((CD[_\\-#\\s]*[0-9]*)))|((\\\\(|\\\\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\\\\s)+(]|\\\\)*))",
|
||||
"TrackRemoveStringsRegex": "^([0-9]+)(\\.|-|\\s)*",
|
||||
"ReplaceStrings": [
|
||||
{
|
||||
|
|
|
@ -368,7 +368,7 @@ namespace Roadie.Library.Tests
|
|||
Assert.NotNull(metaData.Release);
|
||||
Assert.NotNull(metaData.Title);
|
||||
Assert.True(metaData.Year > 0);
|
||||
Assert.Equal(2, metaData.Disk);
|
||||
Assert.Equal(2, metaData.Disc);
|
||||
Assert.NotNull(metaData.TrackNumber);
|
||||
Assert.True(metaData.TotalSeconds > 0);
|
||||
Assert.True(metaData.ValidWeight > 30);
|
||||
|
|
|
@ -46,6 +46,9 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Cover.jpg")]
|
||||
[InlineData("cover.png")]
|
||||
[InlineData("Cover.Jpg")]
|
||||
[InlineData("Cover.JPG")]
|
||||
[InlineData("Cover.PNG")]
|
||||
[InlineData("CvR.Jpg")]
|
||||
[InlineData("Release.JPG")]
|
||||
[InlineData("folder.JPG")]
|
||||
[InlineData("front.jpg")]
|
||||
|
@ -170,9 +173,15 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Back.jpg")]
|
||||
[InlineData("BAcK.JPg")]
|
||||
[InlineData("Cd.jpg")]
|
||||
[InlineData("CD.JPG")]
|
||||
[InlineData("CD.JPG")]
|
||||
[InlineData("Cd1.jpg")]
|
||||
[InlineData("CD-1.jpg")]
|
||||
[InlineData("CD 1.jpg")]
|
||||
[InlineData("CD_1.jpg")]
|
||||
[InlineData("CD-5.jpg")]
|
||||
[InlineData("CD3.jpg")]
|
||||
[InlineData("Scan-1.jpg")]
|
||||
[InlineData("Scan-12.jpg")]
|
||||
[InlineData("cover_01.jpg")]
|
||||
[InlineData("cover 03.jpg")]
|
||||
[InlineData("cover 1.jpg")]
|
||||
|
@ -201,6 +210,8 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Booklet#2.jpg")]
|
||||
[InlineData("traycard.png")]
|
||||
[InlineData("Jewel Case.jpg")]
|
||||
[InlineData("Matrix-1.jpg")]
|
||||
[InlineData("Matrix 1.jpg")]
|
||||
public void Test_Should_Be_Release_Secondary_Images(string input)
|
||||
{
|
||||
Assert.True(ImageHelper.IsReleaseSecondaryImage(new FileInfo(input)));
|
||||
|
@ -248,8 +259,9 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
var cover = ImageHelper.FindImageTypeInDirectory(folder, Enums.ImageType.Release);
|
||||
Assert.NotNull(cover);
|
||||
Assert.Single(cover);
|
||||
Assert.Equal("cover.jpg", cover.First().Name);
|
||||
|
||||
var secondaryImages = ImageHelper.FindImageTypeInDirectory(folder, Enums.ImageType.ReleaseSecondary, SearchOption.AllDirectories);
|
||||
Assert.NotNull(secondaryImages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -179,7 +179,11 @@ namespace Roadie.Library.Tests
|
|||
[Theory]
|
||||
[InlineData("Angie (Limited)")]
|
||||
[InlineData("Angie CD1")]
|
||||
[InlineData("Angie CD 1")]
|
||||
[InlineData("Angie CD #2")]
|
||||
[InlineData("Angie CD2")]
|
||||
[InlineData("Angie CD-2")]
|
||||
[InlineData("Angie CD_2")]
|
||||
[InlineData("Angie CD23")]
|
||||
[InlineData("Angie - CD1")]
|
||||
[InlineData("Angie (Limited Edition)")]
|
||||
|
@ -204,10 +208,11 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Angie [2006, Self Released]")]
|
||||
[InlineData("Angie (2002 Expanded Edition)")]
|
||||
[InlineData("Angie (2004 Remastered)")]
|
||||
[InlineData("Angie (Japan Ltd Dig")]
|
||||
[InlineData("Angie (Japan Ltd Dig")]
|
||||
[InlineData("Angie (Japan Release)")]
|
||||
public void CleanString_Release_Should_Be_Angie(string input)
|
||||
{
|
||||
var r = @"(\s*(-\s)*((CD[0-9][0-9]*)))|((\(|\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\s)+(]|\)*))";
|
||||
var r = @"(\s*(-\s)*((CD[_\-#\s]*[0-9]*)))|((\(|\[)+([0-9]|,|self|bonus|re(leas|master|(e|d)*)*|th|anniversary|cd|disc|deluxe|dig(ipack)*|vinyl|japan(ese)*|asian|remastered|limited|ltd|expanded|edition|\s)+(]|\)*))";
|
||||
var cleaned = input.CleanString(this.Configuration, r);
|
||||
Assert.Equal("Angie", cleaned);
|
||||
}
|
||||
|
|
|
@ -80,6 +80,11 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
artist.Thumbnail = ImageHelper.ResizeImage(artist.Thumbnail, this.Configuration.ThumbnailImageSize.Width, this.Configuration.ThumbnailImageSize.Height);
|
||||
artist.Thumbnail = ImageHelper.ConvertToJpegFormat(artist.Thumbnail);
|
||||
if (artist.Thumbnail.Length >= 65535)
|
||||
{
|
||||
Logger.LogWarning($"Artist Thumbnail larger than maximum size after resizing to [{ this.Configuration.ThumbnailImageSize.Width }x{ this.Configuration.ThumbnailImageSize.Height}] Thumbnail Size [{ artist.Thumbnail.Length }]");
|
||||
artist.Thumbnail = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,7 +596,7 @@ namespace Roadie.Library.Factories
|
|||
var trackHash = HashHelper.CreateMD5(release.ArtistId.ToString() + file.LastWriteTimeUtc.GetHashCode().ToString() + audioMetaData.GetHashCode().ToString());
|
||||
totalNumberOfTracksFound++;
|
||||
totalTrackCount = totalTrackCount ?? (short)(audioMetaData.TotalTrackNumbers ?? 0);
|
||||
var releaseMediaNumber = (short)(audioMetaData.Disk ?? 1);
|
||||
var releaseMediaNumber = (short)(audioMetaData.Disc ?? 1);
|
||||
if (!releaseMediaTotalNumberOfTracks.ContainsKey(releaseMediaNumber))
|
||||
{
|
||||
releaseMediaTotalNumberOfTracks.Add(releaseMediaNumber, (short)(audioMetaData.TotalTrackNumbers ?? 0));
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Roadie.Library.FilePlugins
|
|||
var title = metaData.Title.CleanString(this.Configuration).ToTitleCase(false);
|
||||
var year = metaData.Year;
|
||||
var trackNumber = metaData.TrackNumber ?? 0;
|
||||
var diskNumber = metaData.Disk ?? 0;
|
||||
var discNumber = metaData.Disc ?? 0;
|
||||
|
||||
SimpleContract.Requires(metaData.IsValid, "Track MetaData Invalid");
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(artist), "Missing Track Artist");
|
||||
|
|
|
@ -154,7 +154,7 @@ namespace Roadie.Library.Imaging
|
|||
{
|
||||
return false;
|
||||
}
|
||||
return Regex.IsMatch(fileinfo.Name, @"((f[-_\s]*[0-9]*)|big|cover|folder|release|front[-_\s]*)\.(jpg|jpeg|png|bmp|gif)", RegexOptions.IgnoreCase);
|
||||
return Regex.IsMatch(fileinfo.Name, @"((f[-_\s]*[0-9]*)|big|cover|cvr|folder|release|front[-_\s]*)\.(jpg|jpeg|png|bmp|gif)", RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsReleaseSecondaryImage(FileInfo fileinfo)
|
||||
|
@ -163,7 +163,7 @@ namespace Roadie.Library.Imaging
|
|||
{
|
||||
return false;
|
||||
}
|
||||
return Regex.IsMatch(fileinfo.Name, @"((book[let]*[#-_\s(]*[0-9]*-*[0-9]*(\))*)|(encartes[-_\s]*[(]*[0-9]*[)]*)|(cover[\s_-]+[0-9]+)|back|traycard|jewel case|disc|(.*)[in]*side(.*)|in([side|lay|let|site])*[0-9]*|cd[0-9]*|(release[\s_-]+[0-9]+))\.(jpg|jpeg|png|bmp|gif)", RegexOptions.IgnoreCase);
|
||||
return Regex.IsMatch(fileinfo.Name, @"((book[let]*[#-_\s(]*[0-9]*-*[0-9]*(\))*)|(encartes[-_\s]*[(]*[0-9]*[)]*)|scan(.)?[0-9]*|matrix(.)?[0-9]*|(cover[\s_-]+[0-9]+)|back|traycard|jewel case|disc|(.*)[in]*side(.*)|in([side|lay|let|site])*[0-9]*|cd(.)?[0-9]*|(release[\s_-]+[0-9]+))\.(jpg|jpeg|png|bmp|gif)", RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsLabelImage(FileInfo fileinfo)
|
||||
|
|
|
@ -6,19 +6,18 @@ using Newtonsoft.Json;
|
|||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Inspect.Plugins;
|
||||
using Roadie.Library.Inspect.Plugins.File;
|
||||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.Inspect.Plugins.Directory;
|
||||
using Roadie.Library.Inspect.Plugins.File;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Processors;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.Utility;
|
||||
|
||||
namespace Roadie.Library.Inspect
|
||||
{
|
||||
|
@ -26,43 +25,10 @@ namespace Roadie.Library.Inspect
|
|||
{
|
||||
private static readonly string Salt = "6856F2EE-5965-4345-884B-2CCA457AAF59";
|
||||
|
||||
private IEnumerable<IInspectorFilePlugin> _filePlugins = null;
|
||||
private IEnumerable<IInspectorDirectoryPlugin> _directoryPlugins = null;
|
||||
|
||||
private IEnumerable<IInspectorFilePlugin> _filePlugins = null;
|
||||
public DictionaryCacheManager CacheManager { get; }
|
||||
|
||||
public IEnumerable<IInspectorFilePlugin> FilePlugins
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_filePlugins == null)
|
||||
{
|
||||
var plugins = new List<IInspectorFilePlugin>();
|
||||
try
|
||||
{
|
||||
var type = typeof(IInspectorFilePlugin);
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => type.IsAssignableFrom(p));
|
||||
foreach (Type t in types)
|
||||
{
|
||||
if (t.GetInterface("IInspectorFilePlugin") != null && !t.IsAbstract && !t.IsInterface)
|
||||
{
|
||||
IInspectorFilePlugin plugin = Activator.CreateInstance(t, new object[] { Configuration, CacheManager, Logger, TagsHelper }) as IInspectorFilePlugin;
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex);
|
||||
}
|
||||
_filePlugins = plugins.ToArray();
|
||||
}
|
||||
return _filePlugins;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IInspectorDirectoryPlugin> DirectoryPlugins
|
||||
{
|
||||
get
|
||||
|
@ -95,6 +61,38 @@ namespace Roadie.Library.Inspect
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IInspectorFilePlugin> FilePlugins
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_filePlugins == null)
|
||||
{
|
||||
var plugins = new List<IInspectorFilePlugin>();
|
||||
try
|
||||
{
|
||||
var type = typeof(IInspectorFilePlugin);
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => type.IsAssignableFrom(p));
|
||||
foreach (Type t in types)
|
||||
{
|
||||
if (t.GetInterface("IInspectorFilePlugin") != null && !t.IsAbstract && !t.IsInterface)
|
||||
{
|
||||
IInspectorFilePlugin plugin = Activator.CreateInstance(t, new object[] { Configuration, CacheManager, Logger, TagsHelper }) as IInspectorFilePlugin;
|
||||
plugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex);
|
||||
}
|
||||
_filePlugins = plugins.ToArray();
|
||||
}
|
||||
return _filePlugins;
|
||||
}
|
||||
}
|
||||
|
||||
private IRoadieSettings Configuration { get; }
|
||||
|
||||
private ILogger Logger
|
||||
|
@ -126,6 +124,10 @@ namespace Roadie.Library.Inspect
|
|||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, Logger);
|
||||
}
|
||||
|
||||
public static string ArtistInspectorToken(AudioMetaData metaData) => ToToken(metaData.Artist);
|
||||
|
||||
public static string ReleaseInspectorToken(AudioMetaData metaData) => ToToken(metaData.Artist + metaData.Release);
|
||||
|
||||
public static string ToToken(string input)
|
||||
{
|
||||
var hashids = new Hashids(Salt);
|
||||
|
@ -144,10 +146,6 @@ namespace Roadie.Library.Inspect
|
|||
return token;
|
||||
}
|
||||
|
||||
public static string ArtistInspectorToken(AudioMetaData metaData) => ToToken(metaData.Artist);
|
||||
|
||||
public static string ReleaseInspectorToken(AudioMetaData metaData) => ToToken(metaData.Artist + metaData.Release);
|
||||
|
||||
public void Inspect(bool doCopy, bool isReadOnly, string directoryToInspect, string destination, bool dontAppendSubFolder, bool dontDeleteEmptyFolders)
|
||||
{
|
||||
Configuration.Inspector.IsInReadOnlyMode = isReadOnly;
|
||||
|
@ -203,7 +201,7 @@ namespace Roadie.Library.Inspect
|
|||
Console.WriteLine($"Plugin Failed: Error [{ JsonConvert.SerializeObject(pluginResult)}]");
|
||||
return;
|
||||
}
|
||||
else if(!string.IsNullOrEmpty(pluginResult.Data))
|
||||
else if (!string.IsNullOrEmpty(pluginResult.Data))
|
||||
{
|
||||
Console.WriteLine($"╠╣ Directory Plugin Message: { pluginResult.Data }");
|
||||
}
|
||||
|
@ -296,7 +294,7 @@ namespace Roadie.Library.Inspect
|
|||
{
|
||||
releasesFound.Add(releaseToken);
|
||||
}
|
||||
var newFileName = $"CD{ (tagLib.Data.Disk ?? ID3TagsHelper.DetermineDiscNumber(tagLib.Data)).ToString("000") }_{ tagLib.Data.TrackNumber.Value.ToString("0000") }.mp3";
|
||||
var newFileName = $"CD{ (tagLib.Data.Disc ?? ID3TagsHelper.DetermineDiscNumber(tagLib.Data)).ToString("000") }_{ tagLib.Data.TrackNumber.Value.ToString("0000") }.mp3";
|
||||
// Artist sub folder is created to hold Releases for Artist and Artist Images
|
||||
var artistSubDirectory = directory == dest ? fileInfo.DirectoryName : Path.Combine(dest, artistToken);
|
||||
// Each release is put into a subfolder into the current run Inspector folder to hold MP3 Files and Release Images
|
||||
|
@ -328,6 +326,9 @@ namespace Roadie.Library.Inspect
|
|||
{
|
||||
fileInfo.CopyTo(newPath, true);
|
||||
}
|
||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine($"╠═» { (doCopy ? "Copied" : "Moved")} MP3 File to [{ newPath }]");
|
||||
Console.ResetColor();
|
||||
}
|
||||
if (!inspectedImagesInDirectories.Contains(directoryInfo.FullName))
|
||||
{
|
||||
|
@ -404,6 +405,9 @@ namespace Roadie.Library.Inspect
|
|||
{
|
||||
image.CopyTo(newImagePath, true);
|
||||
}
|
||||
Console.ForegroundColor = ConsoleColor.DarkYellow;
|
||||
Console.WriteLine($"╠═» { (doCopy ? "Copied" : "Moved")} Image File to [{ newImagePath }]");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,12 @@ namespace Roadie.Library.Inspect.Plugins.File
|
|||
{
|
||||
artist = artist.Replace(replace, splitCharacter, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
var originalArtist = artist;
|
||||
var result = artist.CleanString(this.Configuration, this.Configuration.Processing.ArtistRemoveStringsRegex).ToTitleCase(doPutTheAtEnd: false);
|
||||
|
||||
if(string.IsNullOrEmpty(result))
|
||||
{
|
||||
result = originalArtist;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(trackArtist))
|
||||
{
|
||||
result = result.Replace(splitCharacter + trackArtist + splitCharacter, "", StringComparison.OrdinalIgnoreCase);
|
||||
|
|
|
@ -22,7 +22,12 @@ namespace Roadie.Library.Inspect.Plugins.File
|
|||
var result = new OperationResult<AudioMetaData>();
|
||||
if (this.Configuration.Processing.DoAudioCleanup)
|
||||
{
|
||||
var originalRelease = metaData.Release;
|
||||
metaData.Release = metaData.Release?.CleanString(this.Configuration, this.Configuration.Processing.ReleaseRemoveStringsRegex).ToTitleCase(doPutTheAtEnd: false);
|
||||
if(string.IsNullOrEmpty(metaData.Release))
|
||||
{
|
||||
metaData.Release = originalRelease;
|
||||
}
|
||||
}
|
||||
result.Data = metaData;
|
||||
result.IsSuccess = true;
|
||||
|
|
|
@ -22,7 +22,12 @@ namespace Roadie.Library.Inspect.Plugins.File
|
|||
var result = new OperationResult<AudioMetaData>();
|
||||
if (this.Configuration.Processing.DoAudioCleanup)
|
||||
{
|
||||
var originalTitle = metaData.Title;
|
||||
metaData.Title = metaData.Title?.CleanString(this.Configuration, this.Configuration.Processing.TrackRemoveStringsRegex).ToTitleCase(doPutTheAtEnd: false);
|
||||
if(string.IsNullOrEmpty(metaData.Title))
|
||||
{
|
||||
metaData.Title = originalTitle;
|
||||
}
|
||||
}
|
||||
result.Data = metaData;
|
||||
result.IsSuccess = true;
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Roadie.Library.Inspect.Plugins.File
|
|||
var metaDatasForFilesInFolder = GetAudioMetaDatasForDirectory(metaData.FileInfo.Directory);
|
||||
metaData.TrackNumber = (metaData.TrackNumber ?? 0) > 0 ? metaData.TrackNumber : ID3TagsHelper.DetermineTrackNumber(metaData.FileInfo.Name);
|
||||
metaData.TotalTrackNumbers = ID3TagsHelper.DetermineTotalTrackNumbers(metaData.Filename) ?? metaDatasForFilesInFolder.Count();
|
||||
metaData.Disk = ID3TagsHelper.DetermineDiscNumber(metaData);
|
||||
metaData.Disc = ID3TagsHelper.DetermineDiscNumber(metaData);
|
||||
metaData.TotalDiscCount = ID3TagsHelper.DetermineTotalDiscNumbers(metaDatasForFilesInFolder);
|
||||
result.Data = metaData;
|
||||
result.IsSuccess = true;
|
||||
|
|
|
@ -118,12 +118,12 @@ namespace Roadie.Library.MetaData.Audio
|
|||
/// <summary>
|
||||
/// TPOS
|
||||
/// </summary>
|
||||
public int? Disk { get; set; }
|
||||
public int? Disc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TSST
|
||||
/// </summary>
|
||||
public string DiskSubTitle { get; set; }
|
||||
public string DiscSubTitle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Full filename to the file used to get this AudioMetaData
|
||||
|
@ -388,7 +388,12 @@ namespace Roadie.Library.MetaData.Audio
|
|||
{
|
||||
result += $", TrackArtist: { this.TrackArtist}";
|
||||
}
|
||||
result += $", Release: {this.Release}, TrackNumber: {this.TrackNumber}, TrackTotal: {this.TotalTrackNumbers}, Title: {this.Title}, Year: {this.Year}, Duration: {(this.Time == null ? "-" : this.Time.Value.ToString())}";
|
||||
result += $", Release: {this.Release}, TrackNumber: {this.TrackNumber}, TrackTotal: {this.TotalTrackNumbers}";
|
||||
if(this.TotalDiscCount > 1)
|
||||
{
|
||||
result += $", Disc: { this.Disc }/{ this.TotalDiscCount}";
|
||||
}
|
||||
result += $", Title: {this.Title}, Year: {this.Year}, Duration: {(this.Time == null ? "-" : this.Time.Value.ToString())}";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace Roadie.Library.MetaData.Audio
|
|||
result.Year = left.Year.Or(right.Year);
|
||||
result.TrackNumber = left.TrackNumber.Or(right.TrackNumber);
|
||||
result.TotalTrackNumbers = left.TotalTrackNumbers.Or(right.TotalTrackNumbers);
|
||||
result.Disk = left.Disk.Or(right.Disk);
|
||||
result.Disc = left.Disc.Or(right.Disc);
|
||||
result.Time = left.Time ?? right.Time;
|
||||
result.AudioBitrate = left.AudioBitrate.Or(right.AudioBitrate);
|
||||
result.AudioChannels = left.AudioChannels.Or(right.AudioChannels);
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace Roadie.Library.MetaData.Audio
|
|||
int? AudioSampleRate { get; set; }
|
||||
string Comments { get; set; }
|
||||
string Directory { get; }
|
||||
int? Disk { get; set; }
|
||||
string DiskSubTitle { get; set; }
|
||||
int? Disc { get; set; }
|
||||
string DiscSubTitle { get; set; }
|
||||
FileInfo FileInfo { get; }
|
||||
string Filename { get; set; }
|
||||
ICollection<string> Genres { get; set; }
|
||||
|
|
|
@ -248,7 +248,7 @@ namespace Roadie.Library.MetaData.FileName
|
|||
return new AudioMetaData
|
||||
{
|
||||
Artist = CleanString(artist),
|
||||
Disk = SafeParser.ToNumber<int?>(CleanString(tpos)),
|
||||
Disc = SafeParser.ToNumber<int?>(CleanString(tpos)),
|
||||
Release = CleanString(Release),
|
||||
TrackNumber = SafeParser.ToNumber<short?>(CleanString(trck)),
|
||||
Title = CleanString(title)
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace Roadie.Library.MetaData.ID3Tags
|
|||
var trackNumber = metaData.TrackNumber ?? 1;
|
||||
var totalTrackNumber = metaData.TotalTrackNumbers ?? trackNumber;
|
||||
|
||||
var disc = metaData.Disk ?? 1;
|
||||
var disc = metaData.Disc ?? 1;
|
||||
var discCount = metaData.TotalDiscCount ?? disc;
|
||||
|
||||
IID3v2Tag id3v2 = new ID3v2Tag(filename)
|
||||
|
@ -367,10 +367,10 @@ namespace Roadie.Library.MetaData.ID3Tags
|
|||
result.TrackArtistRaw = theTrack.OriginalArtist ?? theTrack.Artist ?? theTrack.AlbumArtist;
|
||||
result.AudioBitrate = (int?)theTrack.Bitrate;
|
||||
result.AudioSampleRate = (int)theTrack.Bitrate;
|
||||
result.Disk = theTrack.DiscNumber;
|
||||
result.Disc = theTrack.DiscNumber;
|
||||
if (theTrack.AdditionalFields.ContainsKey("TSST"))
|
||||
{
|
||||
result.DiskSubTitle = theTrack.AdditionalFields["TSST"];
|
||||
result.DiscSubTitle = theTrack.AdditionalFields["TSST"];
|
||||
}
|
||||
result.Images = theTrack.EmbeddedPictures?.Select(x => new AudioMetaDataImage
|
||||
{
|
||||
|
@ -429,8 +429,8 @@ namespace Roadie.Library.MetaData.ID3Tags
|
|||
result.AudioChannels = audioFile.Channels;
|
||||
result.AudioSampleRate = (int)audioFile.Bitrate;
|
||||
result.Comments = id3v2.CommentsList != null ? string.Join("|", id3v2.CommentsList?.Select(x => x.Value)) : null;
|
||||
result.Disk = ID3TagsHelper.ParseDiscNumber(id3v2.DiscNumber);
|
||||
result.DiskSubTitle = id3v2.SetSubtitle;
|
||||
result.Disc = ID3TagsHelper.ParseDiscNumber(id3v2.DiscNumber);
|
||||
result.DiscSubTitle = id3v2.SetSubtitle;
|
||||
result.Genres = ID3TagsHelper.SplitGenre(id3v2.Genre);
|
||||
result.Release = id3v2.Album;
|
||||
result.TrackArtist = id3v2.OriginalArtist ?? id3v2.Artist ?? id3v2.AlbumArtist;
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace Roadie.Library.MetaData.MusicBrainz
|
|||
Title = track.title,
|
||||
Time = track.length.HasValue ? (TimeSpan?)TimeSpan.FromMilliseconds(track.length.Value) : null,
|
||||
TrackNumber = SafeParser.ToNumber<short?>(track.position ?? track.number) ?? 0,
|
||||
Disk = media.position,
|
||||
Disc = media.position,
|
||||
Year = date > 0 ? (int?)date : null,
|
||||
TotalTrackNumbers = media.trackcount,
|
||||
//tagFile.Tag.Pictures.Select(x => new AudoMetaDataImage
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace Roadie.Library.Utility
|
|||
public static string TrackFileName(IRoadieSettings configuration, AudioMetaData metaData)
|
||||
{
|
||||
var fileInfo = new FileInfo(metaData.Filename);
|
||||
return FolderPathHelper.TrackFileName(configuration, metaData.Release, metaData.TrackNumber ?? 0, metaData.Disk, metaData.TotalTrackNumbers, fileInfo.Extension.ToLower());
|
||||
return FolderPathHelper.TrackFileName(configuration, metaData.Release, metaData.TrackNumber ?? 0, metaData.Disc, metaData.TotalTrackNumbers, fileInfo.Extension.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -158,10 +158,10 @@ namespace Roadie.Library.Utility
|
|||
/// </summary>
|
||||
/// <param name="trackTitle">Title of the Track</param>
|
||||
/// <param name="trackNumber">Track Number</param>
|
||||
/// <param name="diskNumber">Optional disk number defaults to 0</param>
|
||||
/// <param name="discNumber">Optional disc number defaults to 0</param>
|
||||
/// <param name="totalTrackNumber">Optional Total Tracks defaults to TrackNumber</param>
|
||||
/// <param name="fileExtension">Optional File Extension defaults to mp3</param>
|
||||
public static string TrackFileName(IRoadieSettings configuration, string trackTitle, short trackNumber, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3")
|
||||
public static string TrackFileName(IRoadieSettings configuration, string trackTitle, short trackNumber, int? discNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3")
|
||||
{
|
||||
SimpleContract.Requires<ArgumentException>(!string.IsNullOrEmpty(trackTitle), "Invalid Track Title");
|
||||
SimpleContract.Requires<ArgumentException>(trackNumber > 0, "Invalid Track Number");
|
||||
|
@ -170,8 +170,8 @@ namespace Roadie.Library.Utility
|
|||
// If the total number of tracks is more than 99 or the track number itself is more than 99 then 3 pad else 2 pad
|
||||
var track = (totalTrackNumber ?? trackNumber) > 99 || trackNumber > 99 ? trackNumber.ToString("D3") : trackNumber.ToString("D2");
|
||||
// Put an "m" for media on the TPOS greater than 1 so the directory sorts proper
|
||||
var dn = diskNumber ?? 0;
|
||||
var disk = dn > 1 ? string.Format("m{0} ", dn.ToString("D3")) : string.Empty;
|
||||
var dn = discNumber ?? 0;
|
||||
var disc = dn > 1 ? string.Format("m{0} ", dn.ToString("D3")) : string.Empty;
|
||||
|
||||
// Get new name for file
|
||||
var fileNameFromTitle = trackTitle.ToTitleCase(false).ToFileNameFriendly();
|
||||
|
@ -193,7 +193,7 @@ namespace Roadie.Library.Utility
|
|||
}
|
||||
}
|
||||
|
||||
return string.Format("{0}{1} {2}.{3}", disk, track, fileNameFromTitle, fileExtension.ToLower());
|
||||
return string.Format("{0}{1} {2}.{3}", disc, track, fileNameFromTitle, fileExtension.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -205,7 +205,7 @@ namespace Roadie.Library.Utility
|
|||
public static string TrackFullPath(IRoadieSettings configuration, AudioMetaData metaData, string destinationFolder = null, string artistFolder = null, string releaseFolder = null)
|
||||
{
|
||||
return FolderPathHelper.TrackFullPath(configuration, metaData.Artist, metaData.Release, SafeParser.ToDateTime(metaData.Year).Value,
|
||||
metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disk ?? 0,
|
||||
metaData.Title, metaData.TrackNumber ?? 0, destinationFolder, metaData.Disc ?? 0,
|
||||
metaData.TotalTrackNumbers ?? 0,
|
||||
artistFolder: artistFolder,
|
||||
releaseFolder: releaseFolder);
|
||||
|
@ -232,15 +232,15 @@ namespace Roadie.Library.Utility
|
|||
/// <param name="releaseDate">Date of Release</param>
|
||||
/// <param name="trackNumber">Track Number</param>
|
||||
/// <param name="destinationFolder">Optional Root folder defaults to Library Folder from Settings</param>
|
||||
/// <param name="diskNumber">Optional disk number defaults to 0</param>
|
||||
/// <param name="discNumber">Optional disc number defaults to 0</param>
|
||||
/// <param name="totalTrackNumber">Optional Total Tracks defaults to TrackNumber</param>
|
||||
/// <param name="fileExtension">Optional File Extension defaults to mp3</param>
|
||||
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null, string releaseFolder = null)
|
||||
public static string TrackFullPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? discNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3", string artistFolder = null, string releaseFolder = null)
|
||||
{
|
||||
destinationFolder = destinationFolder ?? configuration.LibraryFolder;
|
||||
artistFolder = artistFolder ?? FolderPathHelper.ArtistPath(configuration, artistSortName, destinationFolder);
|
||||
releaseFolder = releaseFolder ?? FolderPathHelper.ReleasePath(artistFolder, releaseTitle, releaseDate);
|
||||
var trackFileName = FolderPathHelper.TrackFileName(configuration, trackTitle, trackNumber, diskNumber, totalTrackNumber, fileExtension);
|
||||
var trackFileName = FolderPathHelper.TrackFileName(configuration, trackTitle, trackNumber, discNumber, totalTrackNumber, fileExtension);
|
||||
|
||||
var result = Path.Combine(artistFolder, releaseFolder, trackFileName);
|
||||
var resultInfo = new DirectoryInfo(result);
|
||||
|
@ -281,12 +281,12 @@ namespace Roadie.Library.Utility
|
|||
/// <param name="releaseDate">Date of Release</param>
|
||||
/// <param name="trackNumber">Track Number</param>
|
||||
/// <param name="destinationFolder">Optional Root folder defaults to Library Folder from Settings</param>
|
||||
/// <param name="diskNumber">Optional disk number defaults to 0</param>
|
||||
/// <param name="discNumber">Optional disc number defaults to 0</param>
|
||||
/// <param name="totalTrackNumber">Optional Total Tracks defaults to TrackNumber</param>
|
||||
/// <param name="fileExtension">Optional File Extension defaults to mp3</param>
|
||||
public static string TrackPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? diskNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3")
|
||||
public static string TrackPath(IRoadieSettings configuration, string artistSortName, string releaseTitle, DateTime releaseDate, string trackTitle, short trackNumber, string destinationFolder = null, int? discNumber = null, int? totalTrackNumber = null, string fileExtension = "mp3")
|
||||
{
|
||||
var fileInfo = new FileInfo(FolderPathHelper.TrackFullPath(configuration, artistSortName, releaseTitle, releaseDate, trackTitle, trackNumber, destinationFolder, diskNumber, totalTrackNumber));
|
||||
var fileInfo = new FileInfo(FolderPathHelper.TrackFullPath(configuration, artistSortName, releaseTitle, releaseDate, trackTitle, trackNumber, destinationFolder, discNumber, totalTrackNumber));
|
||||
return fileInfo.Directory.Name;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue