mirror of https://github.com/lidarr/Lidarr
Use 'var' instead of explicit type
(cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393) Closes #3749
This commit is contained in:
parent
14816306a4
commit
cc27107668
|
@ -32,7 +32,7 @@ namespace Lidarr.Api.V1.Logs
|
||||||
|
|
||||||
var files = GetLogFiles().ToList();
|
var files = GetLogFiles().ToList();
|
||||||
|
|
||||||
for (int i = 0; i < files.Count; i++)
|
for (var i = 0; i < files.Count; i++)
|
||||||
{
|
{
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
var filename = Path.GetFileName(file);
|
var filename = Path.GetFileName(file);
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Lidarr.Api.V1.Profiles.Quality
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public QualityProfileResource GetSchema()
|
public QualityProfileResource GetSchema()
|
||||||
{
|
{
|
||||||
QualityProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
var qualityProfile = _profileService.GetDefaultProfile(string.Empty);
|
||||||
|
|
||||||
return qualityProfile.ToResource();
|
return qualityProfile.ToResource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Lidarr.Api.V1.Search
|
||||||
|
|
||||||
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
|
private static IEnumerable<SearchResource> MapToResource(IEnumerable<object> results)
|
||||||
{
|
{
|
||||||
int id = 1;
|
var id = 1;
|
||||||
foreach (var result in results)
|
foreach (var result in results)
|
||||||
{
|
{
|
||||||
var resource = new SearchResource();
|
var resource = new SearchResource();
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace Lidarr.Api.V1.TrackFiles
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
|
var qualityWeight = Quality.DefaultQualityDefinitions.Single(q => q.Quality == quality.Quality).Weight;
|
||||||
qualityWeight += quality.Revision.Real * 10;
|
qualityWeight += quality.Revision.Real * 10;
|
||||||
qualityWeight += quality.Revision.Version;
|
qualityWeight += quality.Revision.Version;
|
||||||
return qualityWeight;
|
return qualityWeight;
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace Lidarr.Http.ClientSchema
|
||||||
result = GetFieldMapping(type, "", v => v);
|
result = GetFieldMapping(type, "", v => v);
|
||||||
|
|
||||||
// Renumber al the field Orders since nested settings will have dupe Orders.
|
// Renumber al the field Orders since nested settings will have dupe Orders.
|
||||||
for (int i = 0; i < result.Length; i++)
|
for (var i = 0; i < result.Length; i++)
|
||||||
{
|
{
|
||||||
result[i].Field.Order = i;
|
result[i].Field.Order = i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace NzbDrone.Automation.Test
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Screenshot image = ((ITakesScreenshot)driver).GetScreenshot();
|
var image = ((ITakesScreenshot)driver).GetScreenshot();
|
||||||
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
|
image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace NzbDrone.Automation.Test.PageModel
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IWebElement element = d.FindElement(By.ClassName("followingBalls"));
|
var element = d.FindElement(By.ClassName("followingBalls"));
|
||||||
return !element.Displayed;
|
return !element.Displayed;
|
||||||
}
|
}
|
||||||
catch (NoSuchElementException)
|
catch (NoSuchElementException)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -65,9 +65,9 @@ namespace NzbDrone.Common.Test.CacheTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_store_null()
|
public void should_store_null()
|
||||||
{
|
{
|
||||||
int hitCount = 0;
|
var hitCount = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
_cachedString.Get("key", () =>
|
_cachedString.Get("key", () =>
|
||||||
{
|
{
|
||||||
|
@ -83,10 +83,10 @@ namespace NzbDrone.Common.Test.CacheTests
|
||||||
[Platform(Exclude = "MacOsX")]
|
[Platform(Exclude = "MacOsX")]
|
||||||
public void should_honor_ttl()
|
public void should_honor_ttl()
|
||||||
{
|
{
|
||||||
int hitCount = 0;
|
var hitCount = 0;
|
||||||
_cachedString = new Cached<string>();
|
_cachedString = new Cached<string>();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
_cachedString.Get("key",
|
_cachedString.Get("key",
|
||||||
() =>
|
() =>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
@ -142,7 +142,7 @@ namespace NzbDrone.Common.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void SaveDictionary_should_save_proper_value()
|
public void SaveDictionary_should_save_proper_value()
|
||||||
{
|
{
|
||||||
int port = 20555;
|
var port = 20555;
|
||||||
|
|
||||||
var dic = Subject.GetConfigDictionary();
|
var dic = Subject.GetConfigDictionary();
|
||||||
dic["Port"] = 20555;
|
dic["Port"] = 20555;
|
||||||
|
@ -155,9 +155,9 @@ namespace NzbDrone.Common.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void SaveDictionary_should_only_save_specified_values()
|
public void SaveDictionary_should_only_save_specified_values()
|
||||||
{
|
{
|
||||||
int port = 20555;
|
var port = 20555;
|
||||||
int origSslPort = 20551;
|
var origSslPort = 20551;
|
||||||
int sslPort = 20552;
|
var sslPort = 20552;
|
||||||
|
|
||||||
var dic = Subject.GetConfigDictionary();
|
var dic = Subject.GetConfigDictionary();
|
||||||
dic["Port"] = port;
|
dic["Port"] = port;
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_contain_recycling_bin_for_root_of_drive()
|
public void should_not_contain_recycling_bin_for_root_of_drive()
|
||||||
{
|
{
|
||||||
string root = @"C:\".AsOsAgnostic();
|
var root = @"C:\".AsOsAgnostic();
|
||||||
SetupFolders(root);
|
SetupFolders(root);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -56,7 +56,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_contain_system_volume_information()
|
public void should_not_contain_system_volume_information()
|
||||||
{
|
{
|
||||||
string root = @"C:\".AsOsAgnostic();
|
var root = @"C:\".AsOsAgnostic();
|
||||||
SetupFolders(root);
|
SetupFolders(root);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
@ -69,7 +69,7 @@ namespace NzbDrone.Common.Test.DiskTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive()
|
public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive()
|
||||||
{
|
{
|
||||||
string root = @"C:\".AsOsAgnostic();
|
var root = @"C:\".AsOsAgnostic();
|
||||||
SetupFolders(root);
|
SetupFolders(root);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
|
|
|
@ -800,7 +800,7 @@ namespace NzbDrone.Common.Test.Http
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// the date is bad in the below - should be 13-Jul-2026
|
// the date is bad in the below - should be 13-Jul-2026
|
||||||
string malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
|
||||||
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
|
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
|
||||||
.AddQueryParam("Set-Cookie", malformedCookie)
|
.AddQueryParam("Set-Cookie", malformedCookie)
|
||||||
.Build();
|
.Build();
|
||||||
|
@ -834,7 +834,7 @@ namespace NzbDrone.Common.Test.Http
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}";
|
||||||
|
|
||||||
var requestSet = new HttpRequest(url);
|
var requestSet = new HttpRequest(url);
|
||||||
requestSet.AllowAutoRedirect = false;
|
requestSet.AllowAutoRedirect = false;
|
||||||
|
|
|
@ -74,17 +74,17 @@ namespace NzbDrone.Common
|
||||||
continue; // Ignore directories
|
continue; // Ignore directories
|
||||||
}
|
}
|
||||||
|
|
||||||
string entryFileName = zipEntry.Name;
|
var entryFileName = zipEntry.Name;
|
||||||
|
|
||||||
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
|
// to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName);
|
||||||
// Optionally match entrynames against a selection list here to skip as desired.
|
// Optionally match entrynames against a selection list here to skip as desired.
|
||||||
// The unpacked length is available in the zipEntry.Size property.
|
// The unpacked length is available in the zipEntry.Size property.
|
||||||
byte[] buffer = new byte[4096]; // 4K is optimum
|
var buffer = new byte[4096]; // 4K is optimum
|
||||||
Stream zipStream = zipFile.GetInputStream(zipEntry);
|
var zipStream = zipFile.GetInputStream(zipEntry);
|
||||||
|
|
||||||
// Manipulate the output filename here as desired.
|
// Manipulate the output filename here as desired.
|
||||||
string fullZipToPath = Path.Combine(destination, entryFileName);
|
var fullZipToPath = Path.Combine(destination, entryFileName);
|
||||||
string directoryName = Path.GetDirectoryName(fullZipToPath);
|
var directoryName = Path.GetDirectoryName(fullZipToPath);
|
||||||
if (directoryName.Length > 0)
|
if (directoryName.Length > 0)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(directoryName);
|
Directory.CreateDirectory(directoryName);
|
||||||
|
@ -93,7 +93,7 @@ namespace NzbDrone.Common
|
||||||
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
|
// Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size
|
||||||
// of the file, but does not waste memory.
|
// of the file, but does not waste memory.
|
||||||
// The "using" will close the stream even if an exception occurs.
|
// The "using" will close the stream even if an exception occurs.
|
||||||
using (FileStream streamWriter = File.Create(fullZipToPath))
|
using (var streamWriter = File.Create(fullZipToPath))
|
||||||
{
|
{
|
||||||
StreamUtils.Copy(zipStream, streamWriter, buffer);
|
StreamUtils.Copy(zipStream, streamWriter, buffer);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Common
|
||||||
Stream inStream = File.OpenRead(compressedFile);
|
Stream inStream = File.OpenRead(compressedFile);
|
||||||
Stream gzipStream = new GZipInputStream(inStream);
|
Stream gzipStream = new GZipInputStream(inStream);
|
||||||
|
|
||||||
TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null);
|
||||||
tarArchive.ExtractContents(destination);
|
tarArchive.ExtractContents(destination);
|
||||||
tarArchive.Close();
|
tarArchive.Close();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
public static class ConvertBase32
|
public static class ConvertBase32
|
||||||
{
|
{
|
||||||
|
@ -6,17 +6,17 @@
|
||||||
|
|
||||||
public static byte[] FromBase32String(string str)
|
public static byte[] FromBase32String(string str)
|
||||||
{
|
{
|
||||||
int numBytes = str.Length * 5 / 8;
|
var numBytes = str.Length * 5 / 8;
|
||||||
byte[] bytes = new byte[numBytes];
|
var bytes = new byte[numBytes];
|
||||||
|
|
||||||
// all UPPERCASE chars
|
// all UPPERCASE chars
|
||||||
str = str.ToUpper();
|
str = str.ToUpper();
|
||||||
|
|
||||||
int bitBuffer = 0;
|
var bitBuffer = 0;
|
||||||
int bitBufferCount = 0;
|
var bitBufferCount = 0;
|
||||||
int index = 0;
|
var index = 0;
|
||||||
|
|
||||||
for (int i = 0; i < str.Length; i++)
|
for (var i = 0; i < str.Length; i++)
|
||||||
{
|
{
|
||||||
bitBuffer = (bitBuffer << 5) | ValidChars.IndexOf(str[i]);
|
bitBuffer = (bitBuffer << 5) | ValidChars.IndexOf(str[i]);
|
||||||
bitBufferCount += 5;
|
bitBufferCount += 5;
|
||||||
|
|
|
@ -255,7 +255,7 @@ namespace NzbDrone.Common.Disk
|
||||||
|
|
||||||
var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
|
var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture;
|
||||||
|
|
||||||
for (int i = 0; i < leftFragments.Length; i++)
|
for (var i = 0; i < leftFragments.Length; i++)
|
||||||
{
|
{
|
||||||
if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison))
|
if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison))
|
||||||
{
|
{
|
||||||
|
@ -372,12 +372,12 @@ namespace NzbDrone.Common.Disk
|
||||||
|
|
||||||
var newFragments = new List<string>();
|
var newFragments = new List<string>();
|
||||||
|
|
||||||
for (int j = i; j < rightFragments.Length; j++)
|
for (var j = i; j < rightFragments.Length; j++)
|
||||||
{
|
{
|
||||||
newFragments.Add("..");
|
newFragments.Add("..");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = i; j < leftFragments.Length; j++)
|
for (var j = i; j < leftFragments.Length; j++)
|
||||||
{
|
{
|
||||||
newFragments.Add(leftFragments[j]);
|
newFragments.Add(leftFragments[j]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -107,7 +107,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||||
|
|
||||||
private static string RunAndCapture(string filename, string args)
|
private static string RunAndCapture(string filename, string args)
|
||||||
{
|
{
|
||||||
Process p = new Process();
|
var p = new Process();
|
||||||
p.StartInfo.FileName = filename;
|
p.StartInfo.FileName = filename;
|
||||||
p.StartInfo.Arguments = args;
|
p.StartInfo.Arguments = args;
|
||||||
p.StartInfo.UseShellExecute = false;
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
@ -117,7 +117,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
||||||
p.Start();
|
p.Start();
|
||||||
|
|
||||||
// To avoid deadlocks, always read the output stream first and then wait.
|
// To avoid deadlocks, always read the output stream first and then wait.
|
||||||
string output = p.StandardOutput.ReadToEnd();
|
var output = p.StandardOutput.ReadToEnd();
|
||||||
p.WaitForExit(1000);
|
p.WaitForExit(1000);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* This file incorporates work covered by the following copyright and
|
* This file incorporates work covered by the following copyright and
|
||||||
* permission notice:
|
* permission notice:
|
||||||
*
|
*
|
||||||
|
@ -78,7 +78,7 @@ namespace NzbDrone.Common.Extensions
|
||||||
private static Tuple<int, double> match_bitap(string text, string pattern, double matchThreshold)
|
private static Tuple<int, double> match_bitap(string text, string pattern, double matchThreshold)
|
||||||
{
|
{
|
||||||
// Initialise the alphabet.
|
// Initialise the alphabet.
|
||||||
Dictionary<char, BigInteger> s = alphabet(pattern);
|
var s = alphabet(pattern);
|
||||||
|
|
||||||
// don't keep creating new BigInteger(1)
|
// don't keep creating new BigInteger(1)
|
||||||
var big1 = new BigInteger(1);
|
var big1 = new BigInteger(1);
|
||||||
|
@ -88,19 +88,19 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
// Initialise the bit arrays.
|
// Initialise the bit arrays.
|
||||||
var matchmask = big1 << (pattern.Length - 1);
|
var matchmask = big1 << (pattern.Length - 1);
|
||||||
int best_loc = -1;
|
var best_loc = -1;
|
||||||
|
|
||||||
// Empty initialization added to appease C# compiler.
|
// Empty initialization added to appease C# compiler.
|
||||||
var last_rd = Array.Empty<BigInteger>();
|
var last_rd = Array.Empty<BigInteger>();
|
||||||
for (int d = 0; d < pattern.Length; d++)
|
for (var d = 0; d < pattern.Length; d++)
|
||||||
{
|
{
|
||||||
// Scan for the best match; each iteration allows for one more error.
|
// Scan for the best match; each iteration allows for one more error.
|
||||||
int start = 1;
|
var start = 1;
|
||||||
int finish = text.Length + pattern.Length;
|
var finish = text.Length + pattern.Length;
|
||||||
|
|
||||||
var rd = new BigInteger[finish + 2];
|
var rd = new BigInteger[finish + 2];
|
||||||
rd[finish + 1] = (big1 << d) - big1;
|
rd[finish + 1] = (big1 << d) - big1;
|
||||||
for (int j = finish; j >= start; j--)
|
for (var j = finish; j >= start; j--)
|
||||||
{
|
{
|
||||||
BigInteger charMatch;
|
BigInteger charMatch;
|
||||||
if (text.Length <= j - 1 || !s.ContainsKey(text[j - 1]))
|
if (text.Length <= j - 1 || !s.ContainsKey(text[j - 1]))
|
||||||
|
@ -171,8 +171,8 @@ namespace NzbDrone.Common.Extensions
|
||||||
private static Dictionary<char, BigInteger> alphabet(string pattern)
|
private static Dictionary<char, BigInteger> alphabet(string pattern)
|
||||||
{
|
{
|
||||||
var s = new Dictionary<char, BigInteger>();
|
var s = new Dictionary<char, BigInteger>();
|
||||||
char[] char_pattern = pattern.ToCharArray();
|
var char_pattern = pattern.ToCharArray();
|
||||||
foreach (char c in char_pattern)
|
foreach (var c in char_pattern)
|
||||||
{
|
{
|
||||||
if (!s.ContainsKey(c))
|
if (!s.ContainsKey(c))
|
||||||
{
|
{
|
||||||
|
@ -180,8 +180,8 @@ namespace NzbDrone.Common.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
var i = 0;
|
||||||
foreach (char c in char_pattern)
|
foreach (var c in char_pattern)
|
||||||
{
|
{
|
||||||
s[c] = s[c] | (new BigInteger(1) << (pattern.Length - i - 1));
|
s[c] = s[c] | (new BigInteger(1) << (pattern.Length - i - 1));
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace NzbDrone.Common.Extensions
|
||||||
return text.Length * costDelete;
|
return text.Length * costDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] matrix = new int[other.Length + 1];
|
var matrix = new int[other.Length + 1];
|
||||||
|
|
||||||
for (var i = 1; i < matrix.Length; i++)
|
for (var i = 1; i < matrix.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -30,13 +30,13 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
for (var i = 0; i < text.Length; i++)
|
for (var i = 0; i < text.Length; i++)
|
||||||
{
|
{
|
||||||
int topLeft = matrix[0];
|
var topLeft = matrix[0];
|
||||||
matrix[0] = matrix[0] + costDelete;
|
matrix[0] = matrix[0] + costDelete;
|
||||||
|
|
||||||
for (var j = 0; j < other.Length; j++)
|
for (var j = 0; j < other.Length; j++)
|
||||||
{
|
{
|
||||||
int top = matrix[j];
|
var top = matrix[j];
|
||||||
int left = matrix[j + 1];
|
var left = matrix[j + 1];
|
||||||
|
|
||||||
var sumIns = top + costInsert;
|
var sumIns = top + costInsert;
|
||||||
var sumDel = left + costDelete;
|
var sumDel = left + costDelete;
|
||||||
|
|
|
@ -244,13 +244,13 @@ namespace NzbDrone.Common.Extensions
|
||||||
var firstPath = paths.First();
|
var firstPath = paths.First();
|
||||||
var length = firstPath.Length;
|
var length = firstPath.Length;
|
||||||
|
|
||||||
for (int i = 1; i < paths.Count; i++)
|
for (var i = 1; i < paths.Count; i++)
|
||||||
{
|
{
|
||||||
var path = paths[i];
|
var path = paths[i];
|
||||||
|
|
||||||
length = Math.Min(length, path.Length);
|
length = Math.Min(length, path.Length);
|
||||||
|
|
||||||
for (int characterIndex = 0; characterIndex < length; characterIndex++)
|
for (var characterIndex = 0; characterIndex < length; characterIndex++)
|
||||||
{
|
{
|
||||||
if (path[characterIndex] != firstPath[characterIndex])
|
if (path[characterIndex] != firstPath[characterIndex])
|
||||||
{
|
{
|
||||||
|
|
|
@ -188,11 +188,11 @@ namespace NzbDrone.Common.Extensions
|
||||||
{
|
{
|
||||||
double weightDenom = Math.Max(a.Length, b.Length);
|
double weightDenom = Math.Max(a.Length, b.Length);
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (int i = 0; i < a.Length; i++)
|
for (var i = 0; i < a.Length; i++)
|
||||||
{
|
{
|
||||||
double high = 0.0;
|
var high = 0.0;
|
||||||
int indexDistance = 0;
|
var indexDistance = 0;
|
||||||
for (int x = 0; x < b.Length; x++)
|
for (var x = 0; x < b.Length; x++)
|
||||||
{
|
{
|
||||||
var coef = LevenshteinCoefficient(a[i], b[x]);
|
var coef = LevenshteinCoefficient(a[i], b[x]);
|
||||||
if (coef > high)
|
if (coef > high)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common
|
||||||
|
@ -7,9 +7,9 @@ namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
public static string CalculateCrc(string input)
|
public static string CalculateCrc(string input)
|
||||||
{
|
{
|
||||||
uint mCrc = 0xffffffff;
|
var mCrc = 0xffffffff;
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
var bytes = Encoding.UTF8.GetBytes(input);
|
||||||
foreach (byte myByte in bytes)
|
foreach (var myByte in bytes)
|
||||||
{
|
{
|
||||||
mCrc ^= (uint)myByte << 24;
|
mCrc ^= (uint)myByte << 24;
|
||||||
for (var i = 0; i < 8; i++)
|
for (var i = 0; i < 8; i++)
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Common.Http
|
||||||
|
|
||||||
public HttpUri(string scheme, string host, int? port, string path, string query, string fragment)
|
public HttpUri(string scheme, string host, int? port, string path, string query, string fragment)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
|
|
||||||
if (scheme.IsNotNullOrWhiteSpace())
|
if (scheme.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Http.Proxy
|
namespace NzbDrone.Common.Http.Proxy
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ namespace NzbDrone.Common.Http.Proxy
|
||||||
if (!string.IsNullOrWhiteSpace(BypassFilter))
|
if (!string.IsNullOrWhiteSpace(BypassFilter))
|
||||||
{
|
{
|
||||||
var hostlist = BypassFilter.Split(',');
|
var hostlist = BypassFilter.Split(',');
|
||||||
for (int i = 0; i < hostlist.Length; i++)
|
for (var i = 0; i < hostlist.Length; i++)
|
||||||
{
|
{
|
||||||
if (hostlist[i].StartsWith("*"))
|
if (hostlist[i].StartsWith("*"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Instrumentation
|
namespace NzbDrone.Common.Instrumentation
|
||||||
|
@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (JToken token in json)
|
foreach (var token in json)
|
||||||
{
|
{
|
||||||
Visit(token);
|
Visit(token);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace NzbDrone.Common.Instrumentation
|
||||||
|
|
||||||
private static void RegisterDebugger()
|
private static void RegisterDebugger()
|
||||||
{
|
{
|
||||||
DebuggerTarget target = new DebuggerTarget();
|
var target = new DebuggerTarget();
|
||||||
target.Name = "debuggerLogger";
|
target.Name = "debuggerLogger";
|
||||||
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}";
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace NzbDrone.Common.Serializer
|
namespace NzbDrone.Common.Serializer
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ namespace NzbDrone.Common.Serializer
|
||||||
|
|
||||||
public virtual void Visit(JArray json)
|
public virtual void Visit(JArray json)
|
||||||
{
|
{
|
||||||
foreach (JToken token in json)
|
foreach (var token in json)
|
||||||
{
|
{
|
||||||
Visit(token);
|
Visit(token);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ namespace NzbDrone.Common.Serializer
|
||||||
|
|
||||||
public virtual void Visit(JObject json)
|
public virtual void Visit(JObject json)
|
||||||
{
|
{
|
||||||
foreach (JProperty property in json.Properties())
|
foreach (var property in json.Properties())
|
||||||
{
|
{
|
||||||
Visit(property);
|
Visit(property);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace NzbDrone.Common.Serializer
|
||||||
var enumText = value.ToString();
|
var enumText = value.ToString();
|
||||||
var builder = new StringBuilder(enumText.Length + 4);
|
var builder = new StringBuilder(enumText.Length + 4);
|
||||||
builder.Append(char.ToLower(enumText[0]));
|
builder.Append(char.ToLower(enumText[0]));
|
||||||
for (int i = 1; i < enumText.Length; i++)
|
for (var i = 1; i < enumText.Length; i++)
|
||||||
{
|
{
|
||||||
if (char.IsUpper(enumText[i]))
|
if (char.IsUpper(enumText[i]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Common.Serializer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Version v = new Version(reader.GetString());
|
var v = new Version(reader.GetString());
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL
|
||||||
/// <returns>An enumerable of the tasks currently scheduled.</returns>
|
/// <returns>An enumerable of the tasks currently scheduled.</returns>
|
||||||
protected sealed override IEnumerable<Task> GetScheduledTasks()
|
protected sealed override IEnumerable<Task> GetScheduledTasks()
|
||||||
{
|
{
|
||||||
bool lockTaken = false;
|
var lockTaken = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Monitor.TryEnter(_tasks, ref lockTaken);
|
Monitor.TryEnter(_tasks, ref lockTaken);
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace NzbDrone.Console
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
|
System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
|
||||||
for (int i = 0; i < 3600; i++)
|
for (var i = 0; i < 3600; i++)
|
||||||
{
|
{
|
||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Datastore
|
||||||
|
|
||||||
Subject.SetFields(_basicList, x => x.Interval);
|
Subject.SetFields(_basicList, x => x.Interval);
|
||||||
|
|
||||||
for (int i = 0; i < _basicList.Count; i++)
|
for (var i = 0; i < _basicList.Count; i++)
|
||||||
{
|
{
|
||||||
_basicList[i].LastExecution = executionBackup[i];
|
_basicList[i].LastExecution = executionBackup[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
|
||||||
private void GivenTracks(add_release_groups_etc c, int artistid, int albumid, int firstId, int count)
|
private void GivenTracks(add_release_groups_etc c, int artistid, int albumid, int firstId, int count)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var id = firstId + i;
|
var id = firstId + i;
|
||||||
c.Insert.IntoTable("Tracks").Row(new
|
c.Insert.IntoTable("Tracks").Row(new
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
|
||||||
private void GivenTrackFiles(add_mediafilerepository_mtime c, List<string> tracks, int albumReleaseId, int albumId, int firstId = 1, bool addTracks = true)
|
private void GivenTrackFiles(add_mediafilerepository_mtime c, List<string> tracks, int albumReleaseId, int albumId, int firstId = 1, bool addTracks = true)
|
||||||
{
|
{
|
||||||
int id = firstId;
|
var id = firstId;
|
||||||
foreach (var track in tracks)
|
foreach (var track in tracks)
|
||||||
{
|
{
|
||||||
c.Insert.IntoTable("TrackFiles").Row(new
|
c.Insert.IntoTable("TrackFiles").Row(new
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
|
public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
|
||||||
{
|
{
|
||||||
QualityProfile profile = new QualityProfile
|
var profile = new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.MP3_320.Id,
|
Cutoff = Quality.MP3_320.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
@ -104,7 +104,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality()
|
public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality()
|
||||||
{
|
{
|
||||||
QualityProfile profile = new QualityProfile
|
var profile = new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.FLAC_24.Id,
|
Cutoff = Quality.FLAC_24.Id,
|
||||||
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
Items = Qualities.QualityFixture.GetDefaultQualities(),
|
||||||
|
|
|
@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.Blackhole
|
||||||
VerifySingleItem(DownloadItemStatus.Downloading);
|
VerifySingleItem(DownloadItemStatus.Downloading);
|
||||||
|
|
||||||
// If we keep changing the file every 20ms we should stay Downloading.
|
// If we keep changing the file every 20ms we should stay Downloading.
|
||||||
for (int i = 0; i < 10; i++)
|
for (var i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
TestLogger.Info("Iteration {0}", i);
|
TestLogger.Info("Iteration {0}", i);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void ToBestDateTime_DayOfWeek()
|
public void ToBestDateTime_DayOfWeek()
|
||||||
{
|
{
|
||||||
for (int i = 2; i < 7; i++)
|
for (var i = 2; i < 7; i++)
|
||||||
{
|
{
|
||||||
var dateTime = DateTime.Today.AddDays(i);
|
var dateTime = DateTime.Today.AddDays(i);
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_ok_if_not_downloading_to_root_folder()
|
public void should_return_ok_if_not_downloading_to_root_folder()
|
||||||
{
|
{
|
||||||
string rootFolderPath = "c:\\Test2".AsOsAgnostic();
|
var rootFolderPath = "c:\\Test2".AsOsAgnostic();
|
||||||
|
|
||||||
GivenRootFolder(rootFolderPath);
|
GivenRootFolder(rootFolderPath);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.Instrumentation
|
||||||
public void write_long_log()
|
public void write_long_log()
|
||||||
{
|
{
|
||||||
var message = string.Empty;
|
var message = string.Empty;
|
||||||
for (int i = 0; i < 100; i++)
|
for (var i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
message += Guid.NewGuid();
|
message += Guid.NewGuid();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int i = 0;
|
var i = 0;
|
||||||
|
|
||||||
foreach (var tokens in tokenList)
|
foreach (var tokens in tokenList)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
||||||
private List<string> GivenFilenames(string[] fields, string fieldSeparator, string whitespace)
|
private List<string> GivenFilenames(string[] fields, string fieldSeparator, string whitespace)
|
||||||
{
|
{
|
||||||
var outp = new List<string>();
|
var outp = new List<string>();
|
||||||
for (int i = 1; i <= 3; i++)
|
for (var i = 1; i <= 3; i++)
|
||||||
{
|
{
|
||||||
var components = new List<string>();
|
var components = new List<string>();
|
||||||
foreach (var field in fields)
|
foreach (var field in fields)
|
||||||
|
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Aggregation.Aggregators
|
||||||
|
|
||||||
private void VerifyDataAuto(List<LocalTrack> tracks, string[] tokens, string whitespace)
|
private void VerifyDataAuto(List<LocalTrack> tracks, string[] tokens, string whitespace)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= tracks.Count; i++)
|
for (var i = 1; i <= tracks.Count; i++)
|
||||||
{
|
{
|
||||||
var info = tracks[i - 1].FileTrackInfo;
|
var info = tracks[i - 1].FileTrackInfo;
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
.Build()
|
.Build()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
for (int i = 0; i < tracks.Count; i++)
|
for (var i = 0; i < tracks.Count; i++)
|
||||||
{
|
{
|
||||||
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
Mocker.SetConstant<ICandidateService>(Mocker.Resolve<CandidateService>());
|
Mocker.SetConstant<ICandidateService>(Mocker.Resolve<CandidateService>());
|
||||||
|
|
||||||
// set up the augmenters
|
// set up the augmenters
|
||||||
List<IAggregate<LocalAlbumRelease>> aggregators = new List<IAggregate<LocalAlbumRelease>>
|
var aggregators = new List<IAggregate<LocalAlbumRelease>>
|
||||||
{
|
{
|
||||||
Mocker.Resolve<AggregateFilenameInfo>()
|
Mocker.Resolve<AggregateFilenameInfo>()
|
||||||
};
|
};
|
||||||
|
@ -97,7 +97,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
private List<Artist> GivenArtists(List<ArtistTestCase> artists)
|
private List<Artist> GivenArtists(List<ArtistTestCase> artists)
|
||||||
{
|
{
|
||||||
var outp = new List<Artist>();
|
var outp = new List<Artist>();
|
||||||
for (int i = 0; i < artists.Count; i++)
|
for (var i = 0; i < artists.Count; i++)
|
||||||
{
|
{
|
||||||
var meta = artists[i].MetadataProfile;
|
var meta = artists[i].MetadataProfile;
|
||||||
meta.Id = i + 1;
|
meta.Id = i + 1;
|
||||||
|
|
|
@ -30,17 +30,17 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
static RandomValueNamerShortStrings()
|
static RandomValueNamerShortStrings()
|
||||||
{
|
{
|
||||||
AllowedChars = new List<char>();
|
AllowedChars = new List<char>();
|
||||||
for (char c = 'a'; c < 'z'; c++)
|
for (var c = 'a'; c < 'z'; c++)
|
||||||
{
|
{
|
||||||
AllowedChars.Add(c);
|
AllowedChars.Add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char c = 'A'; c < 'Z'; c++)
|
for (var c = 'A'; c < 'Z'; c++)
|
||||||
{
|
{
|
||||||
AllowedChars.Add(c);
|
AllowedChars.Add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char c = '0'; c < '9'; c++)
|
for (var c = '0'; c < '9'; c++)
|
||||||
{
|
{
|
||||||
AllowedChars.Add(c);
|
AllowedChars.Add(c);
|
||||||
}
|
}
|
||||||
|
@ -48,17 +48,17 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
protected override string GetString(MemberInfo memberInfo)
|
protected override string GetString(MemberInfo memberInfo)
|
||||||
{
|
{
|
||||||
int length = _generator.Next(1, 100);
|
var length = _generator.Next(1, 100);
|
||||||
|
|
||||||
char[] chars = new char[length];
|
var chars = new char[length];
|
||||||
|
|
||||||
for (int i = 0; i < length; i++)
|
for (var i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
int index = _generator.Next(0, AllowedChars.Count - 1);
|
var index = _generator.Next(0, AllowedChars.Count - 1);
|
||||||
chars[i] = AllowedChars[index];
|
chars[i] = AllowedChars[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(chars);
|
var bytes = Encoding.UTF8.GetBytes(chars);
|
||||||
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
{
|
{
|
||||||
var outp = new List<LocalTrack>();
|
var outp = new List<LocalTrack>();
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
var track = Builder<LocalTrack>
|
var track = Builder<LocalTrack>
|
||||||
.CreateNew()
|
.CreateNew()
|
||||||
|
@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
public void should_separate_many_albums_in_same_directory()
|
public void should_separate_many_albums_in_same_directory()
|
||||||
{
|
{
|
||||||
var tracks = new List<LocalTrack>();
|
var tracks = new List<LocalTrack>();
|
||||||
for (int i = 0; i < 100; i++)
|
for (var i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
tracks.AddRange(GivenTracks($"C:\\music".AsOsAgnostic(), "artist" + i, "album" + i, 10));
|
tracks.AddRange(GivenTracks($"C:\\music".AsOsAgnostic(), "artist" + i, "album" + i, 10));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.TrackImport.Identification
|
||||||
.Build()
|
.Build()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
for (int i = 0; i < tracks.Count; i++)
|
for (var i = 0; i < tracks.Count; i++)
|
||||||
{
|
{
|
||||||
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
output[i].FileTrackInfo = GivenParsedTrackInfo(tracks[i], release);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.MusicTests.ArtistRepositoryTests
|
||||||
{
|
{
|
||||||
GivenArtists();
|
GivenArtists();
|
||||||
|
|
||||||
string name = "Alice Cooper";
|
var name = "Alice Cooper";
|
||||||
AddArtist(name, "ee58c59f-8e7f-4430-b8ca-236c4d3745ae");
|
AddArtist(name, "ee58c59f-8e7f-4430-b8ca-236c4d3745ae");
|
||||||
AddArtist(name, "4d7928cd-7ed2-4282-8c29-c0c9f966f1bd");
|
AddArtist(name, "4d7928cd-7ed2-4282-8c29-c0c9f966f1bd");
|
||||||
|
|
||||||
|
|
|
@ -39,13 +39,13 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_parse_md5()
|
public void should_not_parse_md5()
|
||||||
{
|
{
|
||||||
string hash = "CRAPPY TEST SEED";
|
var hash = "CRAPPY TEST SEED";
|
||||||
|
|
||||||
var hashAlgo = System.Security.Cryptography.MD5.Create();
|
var hashAlgo = System.Security.Cryptography.MD5.Create();
|
||||||
|
|
||||||
var repetitions = 100;
|
var repetitions = 100;
|
||||||
var success = 0;
|
var success = 0;
|
||||||
for (int i = 0; i < repetitions; i++)
|
for (var i = 0; i < repetitions; i++)
|
||||||
{
|
{
|
||||||
var hashData = hashAlgo.ComputeHash(System.Text.Encoding.Default.GetBytes(hash));
|
var hashData = hashAlgo.ComputeHash(System.Text.Encoding.Default.GetBytes(hash));
|
||||||
|
|
||||||
|
@ -64,17 +64,17 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
[TestCase(40)]
|
[TestCase(40)]
|
||||||
public void should_not_parse_random(int length)
|
public void should_not_parse_random(int length)
|
||||||
{
|
{
|
||||||
string charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
var charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
var hashAlgo = new Random();
|
var hashAlgo = new Random();
|
||||||
|
|
||||||
var repetitions = 500;
|
var repetitions = 500;
|
||||||
var success = 0;
|
var success = 0;
|
||||||
for (int i = 0; i < repetitions; i++)
|
for (var i = 0; i < repetitions; i++)
|
||||||
{
|
{
|
||||||
StringBuilder hash = new StringBuilder(length);
|
var hash = new StringBuilder(length);
|
||||||
|
|
||||||
for (int x = 0; x < length; x++)
|
for (var x = 0; x < length; x++)
|
||||||
{
|
{
|
||||||
hash.Append(charset[hashAlgo.Next() % charset.Length]);
|
hash.Append(charset[hashAlgo.Next() % charset.Length]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Profiles.Delay
|
||||||
var moving = _last;
|
var moving = _last;
|
||||||
var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
|
var result = Subject.Reorder(moving.Id, null).OrderBy(d => d.Order).ToList();
|
||||||
|
|
||||||
for (int i = 1; i < result.Count; i++)
|
for (var i = 1; i < result.Count; i++)
|
||||||
{
|
{
|
||||||
var delayProfile = result[i];
|
var delayProfile = result[i];
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Configuration
|
||||||
{
|
{
|
||||||
const string defaultValue = "*";
|
const string defaultValue = "*";
|
||||||
|
|
||||||
string bindAddress = GetValue("BindAddress", defaultValue);
|
var bindAddress = GetValue("BindAddress", defaultValue);
|
||||||
if (string.IsNullOrWhiteSpace(bindAddress))
|
if (string.IsNullOrWhiteSpace(bindAddress))
|
||||||
{
|
{
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
using (var conn = _database.OpenConnection())
|
using (var conn = _database.OpenConnection())
|
||||||
{
|
{
|
||||||
using (IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
|
||||||
{
|
{
|
||||||
foreach (var model in models)
|
foreach (var model in models)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Converters
|
||||||
}
|
}
|
||||||
|
|
||||||
string contract;
|
string contract;
|
||||||
using (JsonDocument body = JsonDocument.Parse(stringValue))
|
using (var body = JsonDocument.Parse(stringValue))
|
||||||
{
|
{
|
||||||
contract = body.RootElement.GetProperty("name").GetString();
|
contract = body.RootElement.GetProperty("name").GetString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
{
|
{
|
||||||
while (releaseReader.Read())
|
while (releaseReader.Read())
|
||||||
{
|
{
|
||||||
int albumId = releaseReader.GetInt32(0);
|
var albumId = releaseReader.GetInt32(0);
|
||||||
var albumRelease = Json.Deserialize<LegacyAlbumRelease>(releaseReader.GetString(1));
|
var albumRelease = Json.Deserialize<LegacyAlbumRelease>(releaseReader.GetString(1));
|
||||||
|
|
||||||
AlbumRelease023 toInsert = null;
|
AlbumRelease023 toInsert = null;
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
|
||||||
private void SetDefaultOptions(IDbConnection conn, IDbTransaction tran)
|
private void SetDefaultOptions(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
int metadataId = GetMinProfileId(conn, tran, "MetadataProfiles");
|
var metadataId = GetMinProfileId(conn, tran, "MetadataProfiles");
|
||||||
int qualityId = GetMinProfileId(conn, tran, "QualityProfiles");
|
var qualityId = GetMinProfileId(conn, tran, "QualityProfiles");
|
||||||
|
|
||||||
if (metadataId == 0 || qualityId == 0)
|
if (metadataId == 0 || qualityId == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
|
||||||
private void ConvertFileChmodToFolderChmod(IDbConnection conn, IDbTransaction tran)
|
private void ConvertFileChmodToFolderChmod(IDbConnection conn, IDbTransaction tran)
|
||||||
{
|
{
|
||||||
using (IDbCommand getFileChmodCmd = conn.CreateCommand())
|
using (var getFileChmodCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
getFileChmodCmd.Transaction = tran;
|
getFileChmodCmd.Transaction = tran;
|
||||||
getFileChmodCmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'filechmod'";
|
getFileChmodCmd.CommandText = @"SELECT Value FROM Config WHERE Key = 'filechmod'";
|
||||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
var folderChmodNum = fileChmodNum | ((fileChmodNum & 0x124) >> 2);
|
var folderChmodNum = fileChmodNum | ((fileChmodNum & 0x124) >> 2);
|
||||||
var folderChmod = Convert.ToString(folderChmodNum, 8).PadLeft(3, '0');
|
var folderChmod = Convert.ToString(folderChmodNum, 8).PadLeft(3, '0');
|
||||||
|
|
||||||
using (IDbCommand insertCmd = conn.CreateCommand())
|
using (var insertCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
insertCmd.Transaction = tran;
|
insertCmd.Transaction = tran;
|
||||||
insertCmd.CommandText = "INSERT INTO Config (Key, Value) VALUES ('chmodfolder', ?)";
|
insertCmd.CommandText = "INSERT INTO Config (Key, Value) VALUES ('chmodfolder', ?)";
|
||||||
|
@ -42,7 +42,7 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (IDbCommand deleteCmd = conn.CreateCommand())
|
using (var deleteCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
deleteCmd.Transaction = tran;
|
deleteCmd.Transaction = tran;
|
||||||
deleteCmd.CommandText = "DELETE FROM Config WHERE Key = 'filechmod'";
|
deleteCmd.CommandText = "DELETE FROM Config WHERE Key = 'filechmod'";
|
||||||
|
|
|
@ -231,11 +231,11 @@ namespace NzbDrone.Core.Datastore.Migration
|
||||||
{
|
{
|
||||||
var updatedNamingConfigs = new List<object>();
|
var updatedNamingConfigs = new List<object>();
|
||||||
|
|
||||||
using (IDbCommand namingConfigCmd = conn.CreateCommand())
|
using (var namingConfigCmd = conn.CreateCommand())
|
||||||
{
|
{
|
||||||
namingConfigCmd.Transaction = tran;
|
namingConfigCmd.Transaction = tran;
|
||||||
namingConfigCmd.CommandText = @"SELECT * FROM ""NamingConfig"" LIMIT 1";
|
namingConfigCmd.CommandText = @"SELECT * FROM ""NamingConfig"" LIMIT 1";
|
||||||
using (IDataReader namingConfigReader = namingConfigCmd.ExecuteReader())
|
using (var namingConfigReader = namingConfigCmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
var standardTrackFormatIndex = namingConfigReader.GetOrdinal("StandardTrackFormat");
|
var standardTrackFormatIndex = namingConfigReader.GetOrdinal("StandardTrackFormat");
|
||||||
var multiDiscTrackFormatIndex = namingConfigReader.GetOrdinal("MultiDiscTrackFormat");
|
var multiDiscTrackFormatIndex = namingConfigReader.GetOrdinal("MultiDiscTrackFormat");
|
||||||
|
|
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
|
|
||||||
public virtual IList<TableDefinition> ReadDbSchema()
|
public virtual IList<TableDefinition> ReadDbSchema()
|
||||||
{
|
{
|
||||||
IList<TableDefinition> tables = ReadTables();
|
var tables = ReadTables();
|
||||||
foreach (var table in tables)
|
foreach (var table in tables)
|
||||||
{
|
{
|
||||||
table.Indexes = ReadIndexes(table.SchemaName, table.Name);
|
table.Indexes = ReadIndexes(table.SchemaName, table.Name);
|
||||||
|
@ -264,7 +264,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||||
protected virtual IList<IndexDefinition> ReadIndexes(string schemaName, string tableName)
|
protected virtual IList<IndexDefinition> ReadIndexes(string schemaName, string tableName)
|
||||||
{
|
{
|
||||||
var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName);
|
var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName);
|
||||||
DataTable table = Read(sqlCommand).Tables[0];
|
var table = Read(sqlCommand).Tables[0];
|
||||||
|
|
||||||
IList<IndexDefinition> indexes = new List<IndexDefinition>();
|
IList<IndexDefinition> indexes = new List<IndexDefinition>();
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
|
||||||
|
|
||||||
private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
|
private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings)
|
||||||
{
|
{
|
||||||
string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
var url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase);
|
||||||
|
|
||||||
var requestBuilder = new JsonRpcRequestBuilder(url);
|
var requestBuilder = new JsonRpcRequestBuilder(url);
|
||||||
requestBuilder.LogResponseContent = true;
|
requestBuilder.LogResponseContent = true;
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
||||||
string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||||
|
|
||||||
if (defaultDestination.IsNotNullOrWhiteSpace())
|
if (defaultDestination.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
@ -73,7 +73,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
_logger.Trace("No directory configured in settings; falling back to client default destination folder.");
|
||||||
string defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
var defaultDestination = _defaultDestinationProxy.GetDefaultDestination(settings);
|
||||||
|
|
||||||
if (defaultDestination.IsNotNullOrWhiteSpace())
|
if (defaultDestination.IsNotNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
|
||||||
var items = new List<DownloadClientItem>();
|
var items = new List<DownloadClientItem>();
|
||||||
|
|
||||||
long totalRemainingSize = 0;
|
long totalRemainingSize = 0;
|
||||||
long globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
|
var globalSpeed = nzbTasks.Where(t => t.Status == DownloadStationTaskStatus.Downloading)
|
||||||
.Select(GetDownloadSpeed)
|
.Select(GetDownloadSpeed)
|
||||||
.Sum();
|
.Sum();
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
|
||||||
|
|
||||||
protected IEnumerable<NzbgetCategory> GetCategories(Dictionary<string, string> config)
|
protected IEnumerable<NzbgetCategory> GetCategories(Dictionary<string, string> config)
|
||||||
{
|
{
|
||||||
for (int i = 1; i < 100; i++)
|
for (var i = 1; i < 100; i++)
|
||||||
{
|
{
|
||||||
var name = config.GetValueOrDefault("Category" + i + ".Name");
|
var name = config.GetValueOrDefault("Category" + i + ".Name");
|
||||||
|
|
||||||
|
|
|
@ -494,7 +494,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, QBittorrentLabel> labels = Proxy.GetLabels(Settings);
|
var labels = Proxy.GetLabels(Settings);
|
||||||
|
|
||||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.ContainsKey(Settings.MusicCategory))
|
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && !labels.ContainsKey(Settings.MusicCategory))
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
|
||||||
var stringArray = (string[])value;
|
var stringArray = (string[])value;
|
||||||
writer.WriteStartArray();
|
writer.WriteStartArray();
|
||||||
|
|
||||||
for (int i = 0; i < stringArray.Length; i++)
|
for (var i = 0; i < stringArray.Length; i++)
|
||||||
{
|
{
|
||||||
writer.WriteValue(stringArray[i]);
|
writer.WriteValue(stringArray[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
|
||||||
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
|
_logger.Debug("Retrieved metadata of {0} torrents in client", torrents.Count);
|
||||||
|
|
||||||
var items = new List<DownloadClientItem>();
|
var items = new List<DownloadClientItem>();
|
||||||
foreach (RTorrentTorrent torrent in torrents)
|
foreach (var torrent in torrents)
|
||||||
{
|
{
|
||||||
// Don't concern ourselves with categories other than specified
|
// Don't concern ourselves with categories other than specified
|
||||||
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.MusicCategory)
|
if (Settings.MusicCategory.IsNotNullOrWhiteSpace() && torrent.Category != Settings.MusicCategory)
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
|
||||||
{
|
{
|
||||||
var config = _proxy.GetConfig(Settings);
|
var config = _proxy.GetConfig(Settings);
|
||||||
|
|
||||||
OsPath destDir = new OsPath(null);
|
var destDir = new OsPath(null);
|
||||||
|
|
||||||
if (config.GetValueOrDefault("dir_active_download_flag") == "true")
|
if (config.GetValueOrDefault("dir_active_download_flag") == "true")
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,13 +32,13 @@ namespace NzbDrone.Core.Download.Extensions
|
||||||
public static long ElementAsLong(this XElement element, XName name)
|
public static long ElementAsLong(this XElement element, XName name)
|
||||||
{
|
{
|
||||||
var el = element.Element(name);
|
var el = element.Element(name);
|
||||||
return long.TryParse(el?.Value, out long value) ? value : default;
|
return long.TryParse(el?.Value, out var value) ? value : default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ElementAsInt(this XElement element, XName name)
|
public static int ElementAsInt(this XElement element, XName name)
|
||||||
{
|
{
|
||||||
var el = element.Element(name);
|
var el = element.Element(name);
|
||||||
return int.TryParse(el?.Value, out int value) ? value : default(int);
|
return int.TryParse(el?.Value, out var value) ? value : default(int);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetIntResponse(this XDocument document)
|
public static int GetIntResponse(this XDocument document)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -105,17 +105,17 @@ namespace NzbDrone.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
var cs = s.ToCharArray();
|
var cs = s.ToCharArray();
|
||||||
int length = 0;
|
var length = 0;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
while (i < cs.Length)
|
while (i < cs.Length)
|
||||||
{
|
{
|
||||||
int charSize = 1;
|
var charSize = 1;
|
||||||
if (i < (cs.Length - 1) && char.IsSurrogate(cs[i]))
|
if (i < (cs.Length - 1) && char.IsSurrogate(cs[i]))
|
||||||
{
|
{
|
||||||
charSize = 2;
|
charSize = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
var byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize);
|
||||||
if ((byteSize + length) <= maxLength)
|
if ((byteSize + length) <= maxLength)
|
||||||
{
|
{
|
||||||
i = i + charSize;
|
i = i + charSize;
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.HealthCheck.Checks
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = _deploymentInfoProvider.PackageGlobalMessage;
|
var message = _deploymentInfoProvider.PackageGlobalMessage;
|
||||||
HealthCheckResult result = HealthCheckResult.Notice;
|
var result = HealthCheckResult.Notice;
|
||||||
|
|
||||||
if (message.StartsWith("Error:"))
|
if (message.StartsWith("Error:"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Core.ImportLists
|
||||||
|
|
||||||
var pageableRequestChain = pageableRequestChainSelector(generator);
|
var pageableRequestChain = pageableRequestChainSelector(generator);
|
||||||
|
|
||||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
for (var i = 0; i < pageableRequestChain.Tiers; i++)
|
||||||
{
|
{
|
||||||
var pageableRequests = pageableRequestChain.GetTier(i);
|
var pageableRequests = pageableRequestChain.GetTier(i);
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime);
|
return DateTime.TryParseExact(date, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<SpotifyImportListItemInfo> MapSpotifyReleases(IList<SpotifyImportListItemInfo> items)
|
public IList<SpotifyImportListItemInfo> MapSpotifyReleases(IList<SpotifyImportListItemInfo> items)
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace NzbDrone.Core.ImportLists.Spotify
|
||||||
where T : BasicModel
|
where T : BasicModel
|
||||||
where TSettings : SpotifySettingsBase<TSettings>, new()
|
where TSettings : SpotifySettingsBase<TSettings>, new()
|
||||||
{
|
{
|
||||||
T result = method(api);
|
var result = method(api);
|
||||||
if (result.HasError())
|
if (result.HasError())
|
||||||
{
|
{
|
||||||
// If unauthorized, refresh token and try again
|
// If unauthorized, refresh token and try again
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace NzbDrone.Core.IndexerSearch
|
||||||
|
|
||||||
if (message.ArtistId.HasValue)
|
if (message.ArtistId.HasValue)
|
||||||
{
|
{
|
||||||
int artistId = message.ArtistId.Value;
|
var artistId = message.ArtistId.Value;
|
||||||
|
|
||||||
var pagingSpec = new PagingSpec<Album>
|
var pagingSpec = new PagingSpec<Album>
|
||||||
{
|
{
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace NzbDrone.Core.Indexers
|
||||||
lastReleaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
|
lastReleaseInfo = _indexerStatusService.GetLastRssSyncReleaseInfo(Definition.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < pageableRequestChain.Tiers; i++)
|
for (var i = 0; i < pageableRequestChain.Tiers; i++)
|
||||||
{
|
{
|
||||||
var pageableRequests = pageableRequestChain.GetTier(i);
|
var pageableRequests = pageableRequestChain.GetTier(i);
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace NzbDrone.Core.Languages
|
||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
Language language = All.FirstOrDefault(v => v.Id == id);
|
var language = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
if (language == null)
|
if (language == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.MediaCover
|
||||||
|
|
||||||
private bool EnsureArtistCovers(Artist artist)
|
private bool EnsureArtistCovers(Artist artist)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
var toResize = new List<Tuple<MediaCover, bool>>();
|
var toResize = new List<Tuple<MediaCover, bool>>();
|
||||||
|
|
||||||
foreach (var cover in artist.Metadata.Value.Images)
|
foreach (var cover in artist.Metadata.Value.Images)
|
||||||
|
@ -196,7 +196,7 @@ namespace NzbDrone.Core.MediaCover
|
||||||
|
|
||||||
public bool EnsureAlbumCovers(Album album)
|
public bool EnsureAlbumCovers(Album album)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
|
|
||||||
foreach (var cover in album.Images.Where(e => e.CoverType == MediaCoverTypes.Cover))
|
foreach (var cover in album.Images.Where(e => e.CoverType == MediaCoverTypes.Cover))
|
||||||
{
|
{
|
||||||
|
@ -269,7 +269,7 @@ namespace NzbDrone.Core.MediaCover
|
||||||
|
|
||||||
private void EnsureResizedCovers(Artist artist, MediaCover cover, bool forceResize, Album album = null)
|
private void EnsureResizedCovers(Artist artist, MediaCover cover, bool forceResize, Album album = null)
|
||||||
{
|
{
|
||||||
int[] heights = GetDefaultHeights(cover.CoverType);
|
var heights = GetDefaultHeights(cover.CoverType);
|
||||||
|
|
||||||
foreach (var height in heights)
|
foreach (var height in heights)
|
||||||
{
|
{
|
||||||
|
|
|
@ -161,13 +161,13 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
OriginalYear = OriginalReleaseDate.HasValue ? (uint)OriginalReleaseDate?.Year : 0;
|
OriginalYear = OriginalReleaseDate.HasValue ? (uint)OriginalReleaseDate?.Year : 0;
|
||||||
|
|
||||||
foreach (ICodec codec in file.Properties.Codecs)
|
foreach (var codec in file.Properties.Codecs)
|
||||||
{
|
{
|
||||||
IAudioCodec acodec = codec as IAudioCodec;
|
var acodec = codec as IAudioCodec;
|
||||||
|
|
||||||
if (acodec != null && (acodec.MediaTypes & MediaTypes.Audio) != MediaTypes.None)
|
if (acodec != null && (acodec.MediaTypes & MediaTypes.Audio) != MediaTypes.None)
|
||||||
{
|
{
|
||||||
int bitrate = acodec.AudioBitrate;
|
var bitrate = acodec.AudioBitrate;
|
||||||
if (bitrate == 0)
|
if (bitrate == 0)
|
||||||
{
|
{
|
||||||
// Taglib can't read bitrate for Opus.
|
// Taglib can't read bitrate for Opus.
|
||||||
|
@ -222,7 +222,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
private int EstimateBitrate(TagLib.File file, string path)
|
private int EstimateBitrate(TagLib.File file, string path)
|
||||||
{
|
{
|
||||||
int bitrate = 0;
|
var bitrate = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Taglib File.Length is unreliable so use System.IO
|
// Taglib File.Length is unreliable so use System.IO
|
||||||
|
@ -241,22 +241,22 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
|
|
||||||
private DateTime? ReadId3Date(TagLib.Id3v2.Tag tag, string dateTag)
|
private DateTime? ReadId3Date(TagLib.Id3v2.Tag tag, string dateTag)
|
||||||
{
|
{
|
||||||
string date = tag.GetTextAsString(dateTag);
|
var date = tag.GetTextAsString(dateTag);
|
||||||
|
|
||||||
if (tag.Version == 4)
|
if (tag.Version == 4)
|
||||||
{
|
{
|
||||||
// the unabused TDRC/TDOR tags
|
// the unabused TDRC/TDOR tags
|
||||||
return DateTime.TryParse(date, out DateTime result) ? result : default(DateTime?);
|
return DateTime.TryParse(date, out var result) ? result : default(DateTime?);
|
||||||
}
|
}
|
||||||
else if (dateTag == "TDRC")
|
else if (dateTag == "TDRC")
|
||||||
{
|
{
|
||||||
// taglib maps the v3 TYER and TDAT to TDRC but does it incorrectly
|
// taglib maps the v3 TYER and TDAT to TDRC but does it incorrectly
|
||||||
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result) ? result : default(DateTime?);
|
return DateTime.TryParseExact(date, "yyyy-dd-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out var result) ? result : default(DateTime?);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// taglib maps the v3 TORY to TDRC so we just get a year
|
// taglib maps the v3 TORY to TDRC so we just get a year
|
||||||
return int.TryParse(date, out int year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
|
return int.TryParse(date, out var year) && year >= 1860 && year <= DateTime.UtcNow.Year + 1 ? new DateTime(year, 1, 1) : default(DateTime?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
var diff = Math.Abs(value - target);
|
var diff = Math.Abs(value - target);
|
||||||
if (diff > 0)
|
if (diff > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < diff; i++)
|
for (var i = 0; i < diff; i++)
|
||||||
{
|
{
|
||||||
Add(key, 1.0);
|
Add(key, 1.0);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private static string Clean(string input)
|
private static string Clean(string input)
|
||||||
{
|
{
|
||||||
char[] arr = input.ToLower().RemoveAccent().ToCharArray();
|
var arr = input.ToLower().RemoveAccent().ToCharArray();
|
||||||
|
|
||||||
arr = Array.FindAll<char>(arr, c => char.IsLetterOrDigit(c));
|
arr = Array.FindAll<char>(arr, c => char.IsLetterOrDigit(c));
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
public void AddPriority<T>(string key, List<T> values, List<T> options)
|
public void AddPriority<T>(string key, List<T> values, List<T> options)
|
||||||
where T : IEquatable<T>
|
where T : IEquatable<T>
|
||||||
{
|
{
|
||||||
for (int i = 0; i < options.Count; i++)
|
for (var i = 0; i < options.Count; i++)
|
||||||
{
|
{
|
||||||
if (values.Contains(options[i]))
|
if (values.Contains(options[i]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
var releases = GetLocalAlbumReleases(localTracks, config.SingleRelease);
|
var releases = GetLocalAlbumReleases(localTracks, config.SingleRelease);
|
||||||
|
|
||||||
int i = 0;
|
var i = 0;
|
||||||
foreach (var localRelease in releases)
|
foreach (var localRelease in releases)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
private void IdentifyRelease(LocalAlbumRelease localAlbumRelease, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config)
|
private void IdentifyRelease(LocalAlbumRelease localAlbumRelease, IdentificationOverrides idOverrides, ImportDecisionMakerConfig config)
|
||||||
{
|
{
|
||||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||||
bool fingerprinted = false;
|
var fingerprinted = false;
|
||||||
|
|
||||||
var candidateReleases = _candidateService.GetDbCandidatesFromTags(localAlbumRelease, idOverrides, config.IncludeExisting);
|
var candidateReleases = _candidateService.GetDbCandidatesFromTags(localAlbumRelease, idOverrides, config.IncludeExisting);
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
_logger.Debug("Matching {0} track files against {1} candidates", localAlbumRelease.TrackCount, candidateReleases.Count);
|
_logger.Debug("Matching {0} track files against {1} candidates", localAlbumRelease.TrackCount, candidateReleases.Count);
|
||||||
_logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalTracks.Select(x => x.Path)));
|
_logger.Trace("Processing files:\n{0}", string.Join("\n", localAlbumRelease.LocalTracks.Select(x => x.Path)));
|
||||||
|
|
||||||
double bestDistance = 1.0;
|
var bestDistance = 1.0;
|
||||||
|
|
||||||
foreach (var candidateRelease in candidateReleases)
|
foreach (var candidateRelease in candidateReleases)
|
||||||
{
|
{
|
||||||
|
@ -350,10 +350,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
var distances = new Distance[localTracks.Count, mbTracks.Count];
|
var distances = new Distance[localTracks.Count, mbTracks.Count];
|
||||||
var costs = new double[localTracks.Count, mbTracks.Count];
|
var costs = new double[localTracks.Count, mbTracks.Count];
|
||||||
|
|
||||||
for (int col = 0; col < mbTracks.Count; col++)
|
for (var col = 0; col < mbTracks.Count; col++)
|
||||||
{
|
{
|
||||||
var totalTrackNumber = DistanceCalculator.GetTotalTrackNumber(mbTracks[col], mbTracks);
|
var totalTrackNumber = DistanceCalculator.GetTotalTrackNumber(mbTracks[col], mbTracks);
|
||||||
for (int row = 0; row < localTracks.Count; row++)
|
for (var row = 0; row < localTracks.Count; row++)
|
||||||
{
|
{
|
||||||
distances[row, col] = DistanceCalculator.TrackDistance(localTracks[row], mbTracks[col], totalTrackNumber, false);
|
distances[row, col] = DistanceCalculator.TrackDistance(localTracks[row], mbTracks[col], totalTrackNumber, false);
|
||||||
costs[row, col] = distances[row, col].NormalizedDistance();
|
costs[row, col] = distances[row, col].NormalizedDistance();
|
||||||
|
|
|
@ -79,9 +79,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var value = new List<Tuple<int, int>>();
|
var value = new List<Tuple<int, int>>();
|
||||||
for (int row = 0; row < nrow_orig; row++)
|
for (var row = 0; row < nrow_orig; row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < ncol_orig; col++)
|
for (var col = 0; col < ncol_orig; col++)
|
||||||
{
|
{
|
||||||
if (M[row, col] == 1)
|
if (M[row, col] == 1)
|
||||||
{
|
{
|
||||||
|
@ -107,9 +107,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
{
|
{
|
||||||
var newdim = Math.Max(matrix.GetLength(0), matrix.GetLength(1));
|
var newdim = Math.Max(matrix.GetLength(0), matrix.GetLength(1));
|
||||||
var outp = new double[newdim, newdim];
|
var outp = new double[newdim, newdim];
|
||||||
for (int row = 0; row < matrix.GetLength(0); row++)
|
for (var row = 0; row < matrix.GetLength(0); row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < matrix.GetLength(1); col++)
|
for (var col = 0; col < matrix.GetLength(1); col++)
|
||||||
{
|
{
|
||||||
outp[row, col] = matrix[row, col];
|
outp[row, col] = matrix[row, col];
|
||||||
}
|
}
|
||||||
|
@ -124,10 +124,10 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
{
|
{
|
||||||
double min_in_row;
|
double min_in_row;
|
||||||
|
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
min_in_row = C[r, 0];
|
min_in_row = C[r, 0];
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (C[r, c] < min_in_row)
|
if (C[r, c] < min_in_row)
|
||||||
{
|
{
|
||||||
|
@ -135,7 +135,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
C[r, c] -= min_in_row;
|
C[r, c] -= min_in_row;
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
// matrix. Go to Step 3.
|
// matrix. Go to Step 3.
|
||||||
private void step_two(ref int step)
|
private void step_two(ref int step)
|
||||||
{
|
{
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (C[r, c] == 0 && RowCover[r] == 0 && ColCover[c] == 0)
|
if (C[r, c] == 0 && RowCover[r] == 0 && ColCover[c] == 0)
|
||||||
{
|
{
|
||||||
|
@ -162,12 +162,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
RowCover[r] = 0;
|
RowCover[r] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
ColCover[c] = 0;
|
ColCover[c] = 0;
|
||||||
}
|
}
|
||||||
|
@ -181,9 +181,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
private void step_three(ref int step)
|
private void step_three(ref int step)
|
||||||
{
|
{
|
||||||
int colcount;
|
int colcount;
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (M[r, c] == 1)
|
if (M[r, c] == 1)
|
||||||
{
|
{
|
||||||
|
@ -193,7 +193,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
}
|
}
|
||||||
|
|
||||||
colcount = 0;
|
colcount = 0;
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (ColCover[c] == 1)
|
if (ColCover[c] == 1)
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
// methods to support step 4
|
// methods to support step 4
|
||||||
private void find_a_zero(ref int row, ref int col)
|
private void find_a_zero(ref int row, ref int col)
|
||||||
{
|
{
|
||||||
int r = 0;
|
var r = 0;
|
||||||
int c;
|
int c;
|
||||||
bool done;
|
bool done;
|
||||||
row = -1;
|
row = -1;
|
||||||
|
@ -249,8 +249,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private bool star_in_row(int row)
|
private bool star_in_row(int row)
|
||||||
{
|
{
|
||||||
bool tmp = false;
|
var tmp = false;
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (M[row, c] == 1)
|
if (M[row, c] == 1)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +264,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
private void find_star_in_row(int row, ref int col)
|
private void find_star_in_row(int row, ref int col)
|
||||||
{
|
{
|
||||||
col = -1;
|
col = -1;
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (M[row, c] == 1)
|
if (M[row, c] == 1)
|
||||||
{
|
{
|
||||||
|
@ -280,8 +280,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
// Save the smallest uncovered value and Go to Step 6.
|
// Save the smallest uncovered value and Go to Step 6.
|
||||||
private void step_four(ref int step)
|
private void step_four(ref int step)
|
||||||
{
|
{
|
||||||
int row = -1;
|
var row = -1;
|
||||||
int col = -1;
|
var col = -1;
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
|
@ -317,7 +317,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
private void find_star_in_col(int c, ref int r)
|
private void find_star_in_col(int c, ref int r)
|
||||||
{
|
{
|
||||||
r = -1;
|
r = -1;
|
||||||
for (int i = 0; i < n; i++)
|
for (var i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
if (M[i, c] == 1)
|
if (M[i, c] == 1)
|
||||||
{
|
{
|
||||||
|
@ -328,7 +328,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private void find_prime_in_row(int r, ref int c)
|
private void find_prime_in_row(int r, ref int c)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < n; j++)
|
for (var j = 0; j < n; j++)
|
||||||
{
|
{
|
||||||
if (M[r, j] == 2)
|
if (M[r, j] == 2)
|
||||||
{
|
{
|
||||||
|
@ -339,7 +339,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private void augment_path()
|
private void augment_path()
|
||||||
{
|
{
|
||||||
for (int p = 0; p < path_count; p++)
|
for (var p = 0; p < path_count; p++)
|
||||||
{
|
{
|
||||||
if (M[path[p, 0], path[p, 1]] == 1)
|
if (M[path[p, 0], path[p, 1]] == 1)
|
||||||
{
|
{
|
||||||
|
@ -354,12 +354,12 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private void clear_covers()
|
private void clear_covers()
|
||||||
{
|
{
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
RowCover[r] = 0;
|
RowCover[r] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
ColCover[c] = 0;
|
ColCover[c] = 0;
|
||||||
}
|
}
|
||||||
|
@ -367,9 +367,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
private void erase_primes()
|
private void erase_primes()
|
||||||
{
|
{
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (M[r, c] == 2)
|
if (M[r, c] == 2)
|
||||||
{
|
{
|
||||||
|
@ -389,8 +389,8 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
private void step_five(ref int step)
|
private void step_five(ref int step)
|
||||||
{
|
{
|
||||||
bool done;
|
bool done;
|
||||||
int r = -1;
|
var r = -1;
|
||||||
int c = -1;
|
var c = -1;
|
||||||
|
|
||||||
path_count = 1;
|
path_count = 1;
|
||||||
path[path_count - 1, 0] = path_row_0;
|
path[path_count - 1, 0] = path_row_0;
|
||||||
|
@ -428,9 +428,9 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
// methods to support step 6
|
// methods to support step 6
|
||||||
private void find_smallest(ref double minval)
|
private void find_smallest(ref double minval)
|
||||||
{
|
{
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (RowCover[r] == 0 && ColCover[c] == 0)
|
if (RowCover[r] == 0 && ColCover[c] == 0)
|
||||||
{
|
{
|
||||||
|
@ -448,11 +448,11 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
// altering any stars, primes, or covered lines.
|
// altering any stars, primes, or covered lines.
|
||||||
private void step_six(ref int step)
|
private void step_six(ref int step)
|
||||||
{
|
{
|
||||||
double minval = double.MaxValue;
|
var minval = double.MaxValue;
|
||||||
find_smallest(ref minval);
|
find_smallest(ref minval);
|
||||||
for (int r = 0; r < n; r++)
|
for (var r = 0; r < n; r++)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < n; c++)
|
for (var c = 0; c < n; c++)
|
||||||
{
|
{
|
||||||
if (RowCover[r] == 1)
|
if (RowCover[r] == 1)
|
||||||
{
|
{
|
||||||
|
@ -471,7 +471,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Identification
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
bool done = false;
|
var done = false;
|
||||||
while (!done)
|
while (!done)
|
||||||
{
|
{
|
||||||
switch (step)
|
switch (step)
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
||||||
var albumDecisions = decisions.Where(e => e.Item.Album != null && e.Approved)
|
var albumDecisions = decisions.Where(e => e.Item.Album != null && e.Approved)
|
||||||
.GroupBy(e => e.Item.Album.ForeignAlbumId).ToList();
|
.GroupBy(e => e.Item.Album.ForeignAlbumId).ToList();
|
||||||
|
|
||||||
int iDecision = 1;
|
var iDecision = 1;
|
||||||
foreach (var albumDecision in albumDecisions)
|
foreach (var albumDecision in albumDecisions)
|
||||||
{
|
{
|
||||||
_logger.ProgressInfo($"Importing album {iDecision++}/{albumDecisions.Count}");
|
_logger.ProgressInfo($"Importing album {iDecision++}/{albumDecisions.Count}");
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport
|
||||||
downloadClientItemInfo = Parser.Parser.ParseAlbumTitle(downloadClientItem.Title);
|
downloadClientItemInfo = Parser.Parser.ParseAlbumTitle(downloadClientItem.Title);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 1;
|
var i = 1;
|
||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
_logger.ProgressInfo($"Reading file {i++}/{files.Count}");
|
_logger.ProgressInfo($"Reading file {i++}/{files.Count}");
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace NzbDrone.Core.MediaFiles.TrackImport.Specifications
|
||||||
|
|
||||||
foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|'))
|
foreach (var workingFolder in _configService.DownloadClientWorkingFolders.Split('|'))
|
||||||
{
|
{
|
||||||
DirectoryInfo parent = Directory.GetParent(item.Path);
|
var parent = Directory.GetParent(item.Path);
|
||||||
while (parent != null)
|
while (parent != null)
|
||||||
{
|
{
|
||||||
if (parent.Name.StartsWith(workingFolder))
|
if (parent.Name.StartsWith(workingFolder))
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace NzbDrone.Core.MediaFiles
|
||||||
var relDate = album.ReleaseDate.Value;
|
var relDate = album.ReleaseDate.Value;
|
||||||
|
|
||||||
// avoiding false +ve checks and set date skewing by not using UTC (Windows)
|
// avoiding false +ve checks and set date skewing by not using UTC (Windows)
|
||||||
DateTime oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath);
|
var oldDateTime = _diskProvider.FileGetLastWrite(trackFilePath);
|
||||||
|
|
||||||
if (OsInfo.IsNotWindows && relDate < EpochTime)
|
if (OsInfo.IsNotWindows && relDate < EpochTime)
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
||||||
{
|
{
|
||||||
_cancellationTokenSource = new CancellationTokenSource();
|
_cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
for (int i = 0; i < THREAD_LIMIT; i++)
|
for (var i = 0; i < THREAD_LIMIT; i++)
|
||||||
{
|
{
|
||||||
var thread = new Thread(ExecuteCommands);
|
var thread = new Thread(ExecuteCommands);
|
||||||
thread.Start();
|
thread.Start();
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Messaging.Commands
|
||||||
|
|
||||||
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
|
public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified)
|
||||||
{
|
{
|
||||||
dynamic command = GetCommand(commandName);
|
var command = GetCommand(commandName);
|
||||||
command.LastExecutionTime = lastExecutionTime;
|
command.LastExecutionTime = lastExecutionTime;
|
||||||
command.LastStartTime = lastStartTime;
|
command.LastStartTime = lastStartTime;
|
||||||
command.Trigger = trigger;
|
command.Trigger = trigger;
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace NzbDrone.Core.MetadataSource
|
||||||
|
|
||||||
public int Compare(Artist x, Artist y)
|
public int Compare(Artist x, Artist y)
|
||||||
{
|
{
|
||||||
int result = 0;
|
var result = 0;
|
||||||
|
|
||||||
// Prefer exact matches
|
// Prefer exact matches
|
||||||
result = Compare(x, y, s => CleanPunctuation(s.Name).Equals(CleanPunctuation(SearchQuery)));
|
result = Compare(x, y, s => CleanPunctuation(s.Name).Equals(CleanPunctuation(SearchQuery)));
|
||||||
|
|
|
@ -190,7 +190,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
{
|
{
|
||||||
var slug = lowerTitle.Split(':')[1].Trim();
|
var slug = lowerTitle.Split(':')[1].Trim();
|
||||||
|
|
||||||
bool isValid = Guid.TryParse(slug, out var searchGuid);
|
var isValid = Guid.TryParse(slug, out var searchGuid);
|
||||||
|
|
||||||
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
||||||
{
|
{
|
||||||
|
@ -252,7 +252,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
{
|
{
|
||||||
var slug = lowerTitle.Split(':')[1].Trim();
|
var slug = lowerTitle.Split(':')[1].Trim();
|
||||||
|
|
||||||
bool isValid = Guid.TryParse(slug, out var searchGuid);
|
var isValid = Guid.TryParse(slug, out var searchGuid);
|
||||||
|
|
||||||
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
if (slug.IsNullOrWhiteSpace() || slug.Any(char.IsWhiteSpace) || isValid == false)
|
||||||
{
|
{
|
||||||
|
@ -432,7 +432,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
private static Album MapAlbum(AlbumResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
private static Album MapAlbum(AlbumResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||||
{
|
{
|
||||||
Album album = new Album();
|
var album = new Album();
|
||||||
album.ForeignAlbumId = resource.Id;
|
album.ForeignAlbumId = resource.Id;
|
||||||
album.OldForeignAlbumIds = resource.OldIds;
|
album.OldForeignAlbumIds = resource.OldIds;
|
||||||
album.Title = resource.Title;
|
album.Title = resource.Title;
|
||||||
|
@ -475,7 +475,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
private static AlbumRelease MapRelease(ReleaseResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
private static AlbumRelease MapRelease(ReleaseResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||||
{
|
{
|
||||||
AlbumRelease release = new AlbumRelease();
|
var release = new AlbumRelease();
|
||||||
release.ForeignReleaseId = resource.Id;
|
release.ForeignReleaseId = resource.Id;
|
||||||
release.OldForeignReleaseIds = resource.OldIds;
|
release.OldForeignReleaseIds = resource.OldIds;
|
||||||
release.Title = resource.Title;
|
release.Title = resource.Title;
|
||||||
|
@ -490,7 +490,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
var allTracks = resource.Tracks.Select(x => MapTrack(x, artistDict));
|
var allTracks = resource.Tracks.Select(x => MapTrack(x, artistDict));
|
||||||
if (!allMedia.Any())
|
if (!allMedia.Any())
|
||||||
{
|
{
|
||||||
foreach (int n in allTracks.Select(x => x.MediumNumber).Distinct())
|
foreach (var n in allTracks.Select(x => x.MediumNumber).Distinct())
|
||||||
{
|
{
|
||||||
allMedia.Add(new Medium { Name = "Unknown", Number = n, Format = "Unknown" });
|
allMedia.Add(new Medium { Name = "Unknown", Number = n, Format = "Unknown" });
|
||||||
}
|
}
|
||||||
|
@ -514,7 +514,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
private static Medium MapMedium(MediumResource resource)
|
private static Medium MapMedium(MediumResource resource)
|
||||||
{
|
{
|
||||||
Medium medium = new Medium
|
var medium = new Medium
|
||||||
{
|
{
|
||||||
Name = resource.Name,
|
Name = resource.Name,
|
||||||
Number = resource.Position,
|
Number = resource.Position,
|
||||||
|
@ -526,7 +526,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
private static Track MapTrack(TrackResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
private static Track MapTrack(TrackResource resource, Dictionary<string, ArtistMetadata> artistDict)
|
||||||
{
|
{
|
||||||
Track track = new Track
|
var track = new Track
|
||||||
{
|
{
|
||||||
ArtistMetadata = artistDict[resource.ArtistId],
|
ArtistMetadata = artistDict[resource.ArtistId],
|
||||||
Title = resource.TrackName,
|
Title = resource.TrackName,
|
||||||
|
@ -545,7 +545,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
|
||||||
|
|
||||||
private static ArtistMetadata MapArtistMetadata(ArtistResource resource)
|
private static ArtistMetadata MapArtistMetadata(ArtistResource resource)
|
||||||
{
|
{
|
||||||
ArtistMetadata artist = new ArtistMetadata();
|
var artist = new ArtistMetadata();
|
||||||
|
|
||||||
artist.Name = resource.ArtistName;
|
artist.Name = resource.ArtistName;
|
||||||
artist.Aliases = resource.ArtistAliases;
|
artist.Aliases = resource.ArtistAliases;
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Music
|
||||||
return Album;
|
return Album;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
if (albumType == null)
|
if (albumType == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace NzbDrone.Core.Music
|
||||||
return Official;
|
return Official;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseStatus albumType = All.FirstOrDefault(v => v.Id == id);
|
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
if (albumType == null)
|
if (albumType == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace NzbDrone.Core.Music
|
||||||
return Studio;
|
return Studio;
|
||||||
}
|
}
|
||||||
|
|
||||||
SecondaryAlbumType albumType = All.FirstOrDefault(v => v.Id == id);
|
var albumType = All.FirstOrDefault(v => v.Id == id);
|
||||||
|
|
||||||
if (albumType == null)
|
if (albumType == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
|
@ -32,7 +32,7 @@ namespace NzbDrone.Core.Music
|
||||||
var existingMetadata = FindById(data.Select(x => x.ForeignArtistId).ToList());
|
var existingMetadata = FindById(data.Select(x => x.ForeignArtistId).ToList());
|
||||||
var updateMetadataList = new List<ArtistMetadata>();
|
var updateMetadataList = new List<ArtistMetadata>();
|
||||||
var addMetadataList = new List<ArtistMetadata>();
|
var addMetadataList = new List<ArtistMetadata>();
|
||||||
int upToDateMetadataCount = 0;
|
var upToDateMetadataCount = 0;
|
||||||
|
|
||||||
foreach (var meta in data)
|
foreach (var meta in data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace NzbDrone.Core.Music
|
||||||
if (_artistService.ArtistPathExists(path))
|
if (_artistService.ArtistPathExists(path))
|
||||||
{
|
{
|
||||||
var basepath = path;
|
var basepath = path;
|
||||||
int i = 0;
|
var i = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
public bool RefreshAlbumInfo(List<Album> albums, List<Album> remoteAlbums, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
public bool RefreshAlbumInfo(List<Album> albums, List<Album> remoteAlbums, bool forceAlbumRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
|
|
||||||
HashSet<string> updatedMusicbrainzAlbums = null;
|
HashSet<string> updatedMusicbrainzAlbums = null;
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
protected override UpdateResult UpdateEntity(Artist local, Artist remote)
|
protected override UpdateResult UpdateEntity(Artist local, Artist remote)
|
||||||
{
|
{
|
||||||
UpdateResult result = UpdateResult.None;
|
var result = UpdateResult.None;
|
||||||
|
|
||||||
if (!local.Metadata.Value.Equals(remote.Metadata.Value))
|
if (!local.Metadata.Value.Equals(remote.Metadata.Value))
|
||||||
{
|
{
|
||||||
|
@ -324,7 +324,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
private void RefreshSelectedArtists(List<int> artistIds, bool isNew, CommandTrigger trigger)
|
private void RefreshSelectedArtists(List<int> artistIds, bool isNew, CommandTrigger trigger)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
var artists = _artistService.GetArtists(artistIds);
|
var artists = _artistService.GetArtists(artistIds);
|
||||||
|
|
||||||
foreach (var artist in artists)
|
foreach (var artist in artists)
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
public bool RefreshEntityInfo(TEntity local, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
public bool RefreshEntityInfo(TEntity local, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags, DateTime? lastUpdate)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
|
|
||||||
LogProgress(local);
|
LogProgress(local);
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ namespace NzbDrone.Core.Music
|
||||||
|
|
||||||
public bool RefreshEntityInfo(List<TEntity> localList, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags)
|
public bool RefreshEntityInfo(List<TEntity> localList, List<TEntity> remoteList, bool forceChildRefresh, bool forceUpdateFileTags)
|
||||||
{
|
{
|
||||||
bool updated = false;
|
var updated = false;
|
||||||
foreach (var entity in localList)
|
foreach (var entity in localList)
|
||||||
{
|
{
|
||||||
updated |= RefreshEntityInfo(entity, remoteList, forceChildRefresh, forceUpdateFileTags, null);
|
updated |= RefreshEntityInfo(entity, remoteList, forceChildRefresh, forceUpdateFileTags, null);
|
||||||
|
|
|
@ -423,7 +423,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
{
|
{
|
||||||
var pattern = string.Empty;
|
var pattern = string.Empty;
|
||||||
|
|
||||||
for (int i = 0; i < tracks.Count; i++)
|
for (var i = 0; i < tracks.Count; i++)
|
||||||
{
|
{
|
||||||
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ namespace NzbDrone.Core.Organizer
|
||||||
{
|
{
|
||||||
var pattern = string.Empty;
|
var pattern = string.Empty;
|
||||||
|
|
||||||
for (int i = 0; i < tracks.Count; i++)
|
for (var i = 0; i < tracks.Count; i++)
|
||||||
{
|
{
|
||||||
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
var patternToReplace = i == 0 ? basePattern : formatPattern;
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace NzbDrone.Core.Parser
|
||||||
path = "fpcalc";
|
path = "fpcalc";
|
||||||
|
|
||||||
// check that the command exists
|
// check that the command exists
|
||||||
Process p = new Process();
|
var p = new Process();
|
||||||
p.StartInfo.FileName = path;
|
p.StartInfo.FileName = path;
|
||||||
p.StartInfo.Arguments = "-version";
|
p.StartInfo.Arguments = "-version";
|
||||||
p.StartInfo.UseShellExecute = false;
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Parser
|
||||||
p.Start();
|
p.Start();
|
||||||
|
|
||||||
// To avoid deadlocks, always read the output stream first and then wait.
|
// To avoid deadlocks, always read the output stream first and then wait.
|
||||||
string output = p.StandardOutput.ReadToEnd();
|
var output = p.StandardOutput.ReadToEnd();
|
||||||
p.WaitForExit(1000);
|
p.WaitForExit(1000);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@ -136,7 +136,7 @@ namespace NzbDrone.Core.Parser
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Process p = new Process();
|
var p = new Process();
|
||||||
p.StartInfo.FileName = _fpcalcPath;
|
p.StartInfo.FileName = _fpcalcPath;
|
||||||
p.StartInfo.Arguments = $"-version";
|
p.StartInfo.Arguments = $"-version";
|
||||||
p.StartInfo.UseShellExecute = false;
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
@ -146,7 +146,7 @@ namespace NzbDrone.Core.Parser
|
||||||
p.Start();
|
p.Start();
|
||||||
|
|
||||||
// To avoid deadlocks, always read the output stream first and then wait.
|
// To avoid deadlocks, always read the output stream first and then wait.
|
||||||
string output = p.StandardOutput.ReadToEnd();
|
var output = p.StandardOutput.ReadToEnd();
|
||||||
p.WaitForExit(1000);
|
p.WaitForExit(1000);
|
||||||
|
|
||||||
if (p.ExitCode != 0)
|
if (p.ExitCode != 0)
|
||||||
|
@ -241,7 +241,7 @@ namespace NzbDrone.Core.Parser
|
||||||
{
|
{
|
||||||
if (IsSetup() && File.Exists(file))
|
if (IsSetup() && File.Exists(file))
|
||||||
{
|
{
|
||||||
Process p = new Process();
|
var p = new Process();
|
||||||
p.StartInfo.FileName = _fpcalcPath;
|
p.StartInfo.FileName = _fpcalcPath;
|
||||||
p.StartInfo.Arguments = $"{_fpcalcArgs} \"{file}\"";
|
p.StartInfo.Arguments = $"{_fpcalcArgs} \"{file}\"";
|
||||||
p.StartInfo.UseShellExecute = false;
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
@ -251,14 +251,14 @@ namespace NzbDrone.Core.Parser
|
||||||
|
|
||||||
_logger.Trace("Executing {0} {1}", p.StartInfo.FileName, p.StartInfo.Arguments);
|
_logger.Trace("Executing {0} {1}", p.StartInfo.FileName, p.StartInfo.Arguments);
|
||||||
|
|
||||||
StringBuilder output = new StringBuilder();
|
var output = new StringBuilder();
|
||||||
StringBuilder error = new StringBuilder();
|
var error = new StringBuilder();
|
||||||
|
|
||||||
// see https://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why?lq=1
|
// see https://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why?lq=1
|
||||||
// this is most likely overkill...
|
// this is most likely overkill...
|
||||||
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
|
using (var outputWaitHandle = new AutoResetEvent(false))
|
||||||
{
|
{
|
||||||
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
|
using (var errorWaitHandle = new AutoResetEvent(false))
|
||||||
{
|
{
|
||||||
DataReceivedEventHandler outputHandler = (sender, e) =>
|
DataReceivedEventHandler outputHandler = (sender, e) =>
|
||||||
{
|
{
|
||||||
|
@ -353,7 +353,7 @@ namespace NzbDrone.Core.Parser
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var sb = new StringBuilder($"client={_acoustIdApiKey}&format=json&meta=recordingids&batch=1", 2000);
|
var sb = new StringBuilder($"client={_acoustIdApiKey}&format=json&meta=recordingids&batch=1", 2000);
|
||||||
for (int i = 0; i < toLookup.Count; i++)
|
for (var i = 0; i < toLookup.Count; i++)
|
||||||
{
|
{
|
||||||
sb.Append($"&duration.{i}={toLookup[i].Item2.Duration:F0}&fingerprint.{i}={toLookup[i].Item2.Fingerprint}");
|
sb.Append($"&duration.{i}={toLookup[i].Item2.Duration:F0}&fingerprint.{i}={toLookup[i].Item2.Fingerprint}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string albumString = "[Unknown Album]";
|
var albumString = "[Unknown Album]";
|
||||||
|
|
||||||
if (AlbumTitle != null)
|
if (AlbumTitle != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace NzbDrone.Core.Parser.Model
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string trackString = "[Unknown Track]";
|
var trackString = "[Unknown Track]";
|
||||||
|
|
||||||
if (TrackNumbers != null && TrackNumbers.Any())
|
if (TrackNumbers != null && TrackNumbers.Any())
|
||||||
{
|
{
|
||||||
|
|
|
@ -629,9 +629,9 @@ namespace NzbDrone.Core.Parser
|
||||||
// TODO: Split into separate method and write unit tests for.
|
// TODO: Split into separate method and write unit tests for.
|
||||||
var parts = artistName.Split('.');
|
var parts = artistName.Split('.');
|
||||||
artistName = "";
|
artistName = "";
|
||||||
int n = 0;
|
var n = 0;
|
||||||
bool previousAcronym = false;
|
var previousAcronym = false;
|
||||||
string nextPart = "";
|
var nextPart = "";
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
if (parts.Length >= n + 2)
|
if (parts.Length >= n + 2)
|
||||||
|
@ -665,7 +665,7 @@ namespace NzbDrone.Core.Parser
|
||||||
|
|
||||||
artistName = artistName.Trim(' ');
|
artistName = artistName.Trim(' ');
|
||||||
|
|
||||||
ParsedTrackInfo result = new ParsedTrackInfo();
|
var result = new ParsedTrackInfo();
|
||||||
|
|
||||||
result.ArtistTitle = artistName;
|
result.ArtistTitle = artistName;
|
||||||
result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistTitle);
|
result.ArtistTitleInfo = GetArtistTitleInfo(result.ArtistTitle);
|
||||||
|
|
|
@ -635,7 +635,7 @@ namespace NzbDrone.Core.Parser
|
||||||
result.Revision.IsRepack = true;
|
result.Revision.IsRepack = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Match versionRegexResult = VersionRegex.Match(normalizedName);
|
var versionRegexResult = VersionRegex.Match(normalizedName);
|
||||||
|
|
||||||
if (versionRegexResult.Success)
|
if (versionRegexResult.Success)
|
||||||
{
|
{
|
||||||
|
@ -643,7 +643,7 @@ namespace NzbDrone.Core.Parser
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: re-enable this when we have a reliable way to determine real
|
// TODO: re-enable this when we have a reliable way to determine real
|
||||||
MatchCollection realRegexResult = RealRegex.Matches(name);
|
var realRegexResult = RealRegex.Matches(name);
|
||||||
|
|
||||||
if (realRegexResult.Count > 0)
|
if (realRegexResult.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace NzbDrone.Core.Profiles.Delay
|
||||||
|
|
||||||
var all = All().OrderBy(d => d.Order).ToList();
|
var all = All().OrderBy(d => d.Order).ToList();
|
||||||
|
|
||||||
for (int i = 0; i < all.Count; i++)
|
for (var i = 0; i < all.Count; i++)
|
||||||
{
|
{
|
||||||
if (all[i].Id == 1)
|
if (all[i].Id == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Profiles.Metadata
|
||||||
|
|
||||||
var names = profiles.Select(x => x.Name).ToList();
|
var names = profiles.Select(x => x.Name).ToList();
|
||||||
|
|
||||||
int i = 1;
|
var i = 1;
|
||||||
emptyProfile.Name = $"{NONE_PROFILE_NAME}.{i}";
|
emptyProfile.Name = $"{NONE_PROFILE_NAME}.{i}";
|
||||||
|
|
||||||
while (names.Contains(emptyProfile.Name))
|
while (names.Contains(emptyProfile.Name))
|
||||||
|
|
|
@ -66,8 +66,8 @@ namespace NzbDrone.Core.Qualities
|
||||||
|
|
||||||
private void InsertMissingDefinitions()
|
private void InsertMissingDefinitions()
|
||||||
{
|
{
|
||||||
List<QualityDefinition> insertList = new List<QualityDefinition>();
|
var insertList = new List<QualityDefinition>();
|
||||||
List<QualityDefinition> updateList = new List<QualityDefinition>();
|
var updateList = new List<QualityDefinition>();
|
||||||
|
|
||||||
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
||||||
var existingDefinitions = _repo.All().ToList();
|
var existingDefinitions = _repo.All().ToList();
|
||||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Qualities
|
||||||
|
|
||||||
public void Execute(ResetQualityDefinitionsCommand message)
|
public void Execute(ResetQualityDefinitionsCommand message)
|
||||||
{
|
{
|
||||||
List<QualityDefinition> updateList = new List<QualityDefinition>();
|
var updateList = new List<QualityDefinition>();
|
||||||
|
|
||||||
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
var allDefinitions = Quality.DefaultQualityDefinitions.OrderBy(d => d.Weight).ToList();
|
||||||
var existingDefinitions = _repo.All().ToList();
|
var existingDefinitions = _repo.All().ToList();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue