mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
Merge pull request #45 from sphildreth/enhace-42
Updated NuGet packages, reworked HttpClient to be async and use Factory.
This commit is contained in:
commit
0c3d978dfb
51 changed files with 389 additions and 273 deletions
|
@ -21,8 +21,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.1.0" />
|
||||
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using McMaster.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Inspector
|
||||
{
|
||||
|
@ -29,15 +32,18 @@ namespace Inspector
|
|||
|
||||
public static int Main(string[] args) => CommandLineApplication.Execute<Program>(args);
|
||||
|
||||
#pragma warning disable RCS1213 // Remove unused member declaration.
|
||||
#pragma warning disable IDE0051 // Remove unused private members
|
||||
#pragma warning disable CRR0026
|
||||
private void OnExecute()
|
||||
#pragma warning restore IDE0051 // Remove unused private members
|
||||
#pragma warning restore RCS1213 // Remove unused member declaration.
|
||||
#pragma warning restore CRR0026
|
||||
{
|
||||
var inspector = new Roadie.Library.Inspect.Inspector();
|
||||
var builder = new HostBuilder()
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHttpClient();
|
||||
}).UseConsoleLifetime();
|
||||
|
||||
var host = builder.Build();
|
||||
var inspector = new Roadie.Library.Inspect.Inspector(host.Services.GetRequiredService<IHttpClientFactory>());
|
||||
inspector.Inspect(DoCopy, IsReadOnly, Folder, Destination ?? Folder, DontAppendSubFolder, IsReadOnly ? true : DontDeleteEmptyFolders, DontRunPreScript);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Roadie.Library.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
@ -44,9 +40,5 @@ namespace Roadie.Library.Tests
|
|||
var configInboundFolder = Settings.InboundFolder;
|
||||
Assert.Equal(inboundFolder, configInboundFolder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
@ -21,8 +19,6 @@ namespace Roadie.Library.Tests
|
|||
var decrypted = EncryptionHelper.Decrypt(encrypted, key);
|
||||
Assert.NotNull(decrypted);
|
||||
Assert.Equal(decrypted, value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,13 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Extensions;
|
||||
using Roadie.Library.Processors;
|
||||
using Roadie.Library.SearchEngines.MetaData.Discogs;
|
||||
using Roadie.Library.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public class ExtensionTests
|
||||
{
|
||||
|
||||
[Fact]
|
||||
public void ShuffleUniqueOrder()
|
||||
{
|
||||
|
@ -32,7 +23,7 @@ namespace Roadie.Library.Tests
|
|||
Release = new Models.Releases.ReleaseList
|
||||
{
|
||||
Release = new Models.DataToken { Value = "R1", Text = "R1" }
|
||||
}
|
||||
}
|
||||
},
|
||||
new Models.TrackList
|
||||
{
|
||||
|
@ -218,7 +209,7 @@ namespace Roadie.Library.Tests
|
|||
|
||||
var shuffledTracks = Models.TrackList.Shuffle(tracks);
|
||||
var lastTrack = shuffledTracks.First();
|
||||
foreach(var track in shuffledTracks.Skip(1))
|
||||
foreach (var track in shuffledTracks.Skip(1))
|
||||
{
|
||||
Assert.False(string.Equals(track.Artist.Artist.Text, lastTrack.Artist.Artist.Text, StringComparison.Ordinal) &&
|
||||
string.Equals(track.Release.Release.Text, lastTrack.Release.Release.Text, StringComparison.Ordinal));
|
||||
|
@ -228,7 +219,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(tracks.Count, shuffledTracks.Count());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void FromUnixTime()
|
||||
{
|
||||
|
@ -269,7 +259,6 @@ namespace Roadie.Library.Tests
|
|||
decimal? unixDateTime = (long)(shouldBe).TotalSeconds;
|
||||
var ts = unixDateTime.ToTimeSpan();
|
||||
Assert.Equal(shouldBe, ts);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -295,7 +284,7 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Song (ft. Joe)")]
|
||||
[InlineData("Song (featuring Joe)")]
|
||||
[InlineData("Song (feat. Joe)")]
|
||||
public void StringHaveFeatureFragments(string input)
|
||||
public void StringHaveFeatureFragments(string input)
|
||||
{
|
||||
Assert.True(input.HasFeaturingFragments());
|
||||
}
|
||||
|
@ -308,4 +297,4 @@ namespace Roadie.Library.Tests
|
|||
Assert.False(input.HasFeaturingFragments());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
@ -67,7 +66,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal("01aad0e51fcd5582b307613842e4ffe5", md51.ToLower());
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void CreateAndEnsureStandardMd5()
|
||||
{
|
||||
|
@ -79,4 +77,4 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal("ce114e4501d2f4e2dcea3e17b546f339", md5.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
Roadie.Api.Library.Tests/HttpClientFactoryBaseTests.cs
Normal file
44
Roadie.Api.Library.Tests/HttpClientFactoryBaseTests.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using Moq;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public abstract class HttpClientFactoryBaseTests
|
||||
{
|
||||
protected readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
public HttpClientFactoryBaseTests()
|
||||
{
|
||||
// var clientHandlerStub = new DelegatingHandlerStub();
|
||||
// var client = new HttpClient(clientHandlerStub);
|
||||
var client = new HttpClient();
|
||||
var mockFactory = new Mock<IHttpClientFactory>();
|
||||
mockFactory.Setup(_ => _.CreateClient(It.IsAny<string>())).Returns(client);
|
||||
_httpClientFactory = mockFactory.Object;
|
||||
}
|
||||
|
||||
protected class DelegatingHandlerStub : DelegatingHandler
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> _handlerFunc;
|
||||
|
||||
public DelegatingHandlerStub()
|
||||
{
|
||||
_handlerFunc = (request, cancellationToken) => Task.FromResult(request.CreateResponse(HttpStatusCode.OK));
|
||||
}
|
||||
|
||||
public DelegatingHandlerStub(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> handlerFunc)
|
||||
{
|
||||
_handlerFunc = handlerFunc;
|
||||
}
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
return _handlerFunc(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,19 +4,17 @@ using Roadie.Library.Caching;
|
|||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Processors;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public class ID3TagsHelperTests
|
||||
public class ID3TagsHelperTests : HttpClientFactoryBaseTests
|
||||
{
|
||||
private IEventMessageLogger MessageLogger { get; }
|
||||
|
||||
private ILogger Logger
|
||||
{
|
||||
get
|
||||
|
@ -45,7 +43,8 @@ namespace Roadie.Library.Tests
|
|||
CacheManager = new DictionaryCacheManager(Logger, new NewtonsoftCacheSerializer(Logger), new CachePolicy(TimeSpan.FromHours(4)));
|
||||
var tagHelperLooper = new EventMessageLogger<ID3TagsHelper>();
|
||||
tagHelperLooper.Messages += MessageLoggerMessages;
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper);
|
||||
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper, _httpClientFactory);
|
||||
}
|
||||
|
||||
private void MessageLoggerMessages(object sender, EventMessage e)
|
||||
|
@ -89,7 +88,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(5, dn.Value);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("1983")]
|
||||
[InlineData("02/24/1983")]
|
||||
|
@ -121,7 +119,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Null(dn);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("Z")]
|
||||
|
@ -134,7 +131,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Null(dn);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("2")]
|
||||
[InlineData("02")]
|
||||
|
@ -148,7 +144,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(2, dn.Value);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("1")]
|
||||
[InlineData("01")]
|
||||
|
@ -175,7 +170,7 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("")]
|
||||
[InlineData(" /2")]
|
||||
[InlineData(null)]
|
||||
[InlineData("BATMAN")]
|
||||
|
@ -195,10 +190,10 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("1 - Tithe II.mp3")]
|
||||
[InlineData("1 Up.mp3")]
|
||||
[InlineData("1. Up.mp3")]
|
||||
[InlineData("1- Up.mp3")]
|
||||
[InlineData("1- Up.mp3")]
|
||||
[InlineData("(01) [Iperyt] The Black Emperor.mp3")]
|
||||
[InlineData("[01] [Iperyt] The Black Emperor.mp3")]
|
||||
[InlineData("Van Morrison - 01 - Some Peace of Mind (with Bobby Womack).mp3")]
|
||||
[InlineData("[01] [Iperyt] The Black Emperor.mp3")]
|
||||
[InlineData("Van Morrison - 01 - Some Peace of Mind (with Bobby Womack).mp3")]
|
||||
public void DetermineTrackNumber(string filename)
|
||||
{
|
||||
var tn = ID3TagsHelper.DetermineTrackNumber(filename);
|
||||
|
@ -210,13 +205,13 @@ namespace Roadie.Library.Tests
|
|||
{
|
||||
var cuesDir = @"C:\roadie_dev_root\test_cue_and_playlists\cues1";
|
||||
var directory = new DirectoryInfo(cuesDir);
|
||||
if(directory.Exists)
|
||||
{
|
||||
foreach(var file in Directory.GetFiles(cuesDir))
|
||||
if (directory.Exists)
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(cuesDir))
|
||||
{
|
||||
var t = ID3TagsHelper.DetermineTotalTrackNumbers(file);
|
||||
Assert.Equal(5, t.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -319,7 +314,6 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ReadTotalTrackNumbersFromM3uShouldBeFour()
|
||||
{
|
||||
|
@ -380,7 +374,7 @@ namespace Roadie.Library.Tests
|
|||
[Fact]
|
||||
public void ReadID3v24Tags()
|
||||
{
|
||||
// var file = new FileInfo(@"N:\_complete\JN Dutplanet net Reset String - Ancient Future 2014\JN Dutplanet.net Reset String - Ancient Future 2014\01 O.P.D. (Obsessive Personality Disorder).mp3");
|
||||
// var file = new FileInfo(@"N:\_complete\JN Dutplanet net Reset String - Ancient Future 2014\JN Dutplanet.net Reset String - Ancient Future 2014\01 O.P.D. (Obsessive Personality Disorder).mp3");
|
||||
var file = new FileInfo(@"C:\roadie_dev_root\mp3_tests\01 O.P.D. (Obsessive Personality Disorder).mp3");
|
||||
if (file.Exists)
|
||||
{
|
||||
|
@ -403,7 +397,6 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ReadID3TagsMultipleMediasWithMax()
|
||||
{
|
||||
|
@ -471,7 +464,7 @@ namespace Roadie.Library.Tests
|
|||
else
|
||||
{
|
||||
var folderFiles = Directory.GetFiles(folderName, "*.mp3", SearchOption.AllDirectories);
|
||||
foreach(var file in folderFiles)
|
||||
foreach (var file in folderFiles)
|
||||
{
|
||||
var tagLib = TagsHelper.MetaDataForFile(file);
|
||||
Assert.True(tagLib.IsSuccess);
|
||||
|
@ -484,7 +477,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.True(metaData.IsValid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -646,7 +638,6 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ReadID3TagsFromFileWithTrackAndArtistTheSame()
|
||||
{
|
||||
|
@ -728,9 +719,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(metaData.Title, tagLibAfterWrite.Data.Title);
|
||||
Assert.Equal(trackNumber, tagLibAfterWrite.Data.TrackNumber);
|
||||
Assert.Equal(numberOfTracks, tagLibAfterWrite.Data.TotalTrackNumbers);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -948,6 +936,5 @@ namespace Roadie.Library.Tests
|
|||
Assert.True(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using Roadie.Library.Imaging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
|
||||
|
@ -10,7 +9,7 @@ namespace Roadie.Library.Tests
|
|||
[Fact]
|
||||
public void GenerateImageHash()
|
||||
{
|
||||
if(!Directory.Exists(@"C:\temp\image_tests"))
|
||||
if (!Directory.Exists(@"C:\temp\image_tests"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -35,7 +34,6 @@ namespace Roadie.Library.Tests
|
|||
|
||||
Assert.True(ImageHasher.ImagesAreSame(imageFilename, secondImagFilename));
|
||||
|
||||
|
||||
secondHash = ImageHasher.AverageHash(resizedFirstImageFilename);
|
||||
Assert.True(secondHash > 0);
|
||||
Assert.Equal(hash, secondHash);
|
||||
|
@ -43,4 +41,4 @@ namespace Roadie.Library.Tests
|
|||
Assert.False(ImageHasher.ImagesAreSame(imageFilename, thirdImageFilename));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using Roadie.Library.Imaging;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
@ -139,7 +138,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.False(ImageHelper.IsReleaseImage(new FileInfo(input)));
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("label.jpeg")]
|
||||
[InlineData("label.jpg")]
|
||||
|
@ -178,7 +176,6 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
|
||||
[InlineData("Booklet-1.jpg")]
|
||||
[InlineData("Booklet-10.jpg")]
|
||||
[InlineData("Booklet_1.jpg")]
|
||||
|
@ -314,6 +311,5 @@ namespace Roadie.Library.Tests
|
|||
Assert.Single(artist);
|
||||
Assert.Equal("artist.jpg", artist.First().Name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,24 +1,20 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using configuration = Roadie.Library.Configuration;
|
||||
using Roadie.Library.Inspect;
|
||||
using Roadie.Library.Inspect.Plugins.File;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Processors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
using configuration = Roadie.Library.Configuration;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public class InspectorTests
|
||||
public class InspectorTests : HttpClientFactoryBaseTests
|
||||
{
|
||||
private IEventMessageLogger MessageLogger { get; }
|
||||
|
||||
private ILogger Logger
|
||||
{
|
||||
get
|
||||
|
@ -32,7 +28,6 @@ namespace Roadie.Library.Tests
|
|||
private configuration.IRoadieSettings Configuration { get; }
|
||||
public DictionaryCacheManager CacheManager { get; }
|
||||
|
||||
|
||||
public InspectorTests()
|
||||
{
|
||||
MessageLogger = new EventMessageLogger<ID3TagsHelperTests>();
|
||||
|
@ -48,7 +43,7 @@ namespace Roadie.Library.Tests
|
|||
CacheManager = new DictionaryCacheManager(Logger, new NewtonsoftCacheSerializer(Logger), new CachePolicy(TimeSpan.FromHours(4)));
|
||||
var tagHelperLooper = new EventMessageLogger<ID3TagsHelper>();
|
||||
tagHelperLooper.Messages += MessageLoggerMessages;
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper);
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper, _httpClientFactory);
|
||||
}
|
||||
|
||||
private void MessageLoggerMessages(object sender, EventMessage e)
|
||||
|
@ -66,7 +61,7 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("Bob Jones & Mary Jones", "Bob Jones & Mary Jones")]
|
||||
[InlineData("Bob Jones ", "Bob Jones")]
|
||||
[InlineData(" BoB Jones ", "Bob Jones")]
|
||||
[InlineData("Ain't NO THING", "Ain't No Thing")]
|
||||
[InlineData("Ain't NO THING", "Ain't No Thing")]
|
||||
public void CleanArtistPlugin(string artist, string shouldBe)
|
||||
{
|
||||
var plugin = new CleanUpArtists(Configuration, CacheManager, Logger, TagsHelper);
|
||||
|
@ -78,15 +73,14 @@ namespace Roadie.Library.Tests
|
|||
public void CleanTrackTitlePlugin(string title, string shouldBe)
|
||||
{
|
||||
var plugin = new CleanUpTrackTitle(Configuration, CacheManager, Logger, TagsHelper);
|
||||
var result = plugin.Process(new MetaData.Audio.AudioMetaData { Title = title});
|
||||
var result = plugin.Process(new MetaData.Audio.AudioMetaData { Title = title });
|
||||
Assert.Equal(shouldBe, result.Data.Title);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CleanArtistPluginRemoveArtistFromTrackArtist()
|
||||
{
|
||||
var artist = "Bob Jones";
|
||||
var artist = "Bob Jones";
|
||||
var trackArtist = "Bob Jones;Mary Jones";
|
||||
var trackShouldBe = "Mary Jones";
|
||||
|
||||
|
@ -132,8 +126,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.NotNull(releaseToken);
|
||||
|
||||
Assert.NotEqual(artistToken, releaseToken);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
@ -28,8 +25,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(0, parsed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ParseLargerInt()
|
||||
{
|
||||
|
@ -52,7 +47,6 @@ namespace Roadie.Library.Tests
|
|||
var nothing = "";
|
||||
parsed = SafeParser.ToNumber<int?>(nothing);
|
||||
Assert.Null(parsed);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -82,8 +76,8 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("1988/05")]
|
||||
[InlineData("1988/05/02")]
|
||||
[InlineData("88")]
|
||||
[InlineData("1988-06-15T07:00:00Z")]
|
||||
[InlineData("1988-07-14T07:00:00Z")]
|
||||
[InlineData("1988-06-15T07:00:00Z")]
|
||||
[InlineData("1988-07-14T07:00:00Z")]
|
||||
public void ParseDatetimeShouldBe1988(string input)
|
||||
{
|
||||
var parsed = SafeParser.ToDateTime(input);
|
||||
|
@ -105,7 +99,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.NotNull(parsed);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("DEB4F298-5D22-4304-916E-F130B02864B7")]
|
||||
[InlineData("12d65c61-1b7d-4c43-9aab-7d398a1a880e")]
|
||||
|
@ -131,7 +124,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.True(parsed);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("BATMAN")]
|
||||
|
@ -148,4 +140,4 @@ namespace Roadie.Library.Tests
|
|||
Assert.False(parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,9 +13,10 @@ using Xunit;
|
|||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public class SearchEngineTests
|
||||
public class SearchEngineTests : HttpClientFactoryBaseTests
|
||||
{
|
||||
private IEventMessageLogger MessageLogger { get; }
|
||||
|
||||
private ILogger Logger
|
||||
{
|
||||
get
|
||||
|
@ -39,8 +40,6 @@ namespace Roadie.Library.Tests
|
|||
HttpEncoder = new Encoding.DummyHttpEncoder();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private IRoadieSettings Configuration { get; }
|
||||
public DictionaryCacheManager CacheManager { get; }
|
||||
private Encoding.IHttpEncoder HttpEncoder { get; }
|
||||
|
@ -55,7 +54,7 @@ namespace Roadie.Library.Tests
|
|||
var discogsLogger = new EventMessageLogger<DiscogsHelper>();
|
||||
discogsLogger.Messages += MessageLogger_Messages;
|
||||
|
||||
var engine = new DiscogsHelper(Configuration, CacheManager, discogsLogger);
|
||||
var engine = new DiscogsHelper(Configuration, CacheManager, discogsLogger, _httpClientFactory);
|
||||
|
||||
var artistName = "With The Dead";
|
||||
var title = "Love From With The Dead";
|
||||
|
@ -63,7 +62,6 @@ namespace Roadie.Library.Tests
|
|||
var result = await engine.PerformReleaseSearch(artistName, title, 1).ConfigureAwait(false);
|
||||
Assert.NotNull(result);
|
||||
Assert.NotEmpty(result.Data);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -75,7 +73,7 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
var logger = new EventMessageLogger<MusicBrainzProvider>();
|
||||
logger.Messages += MessageLogger_Messages;
|
||||
var mb = new MusicBrainzProvider(Configuration, CacheManager, logger);
|
||||
var mb = new MusicBrainzProvider(Configuration, CacheManager, logger, _httpClientFactory);
|
||||
|
||||
var artistName = "Billy Joel";
|
||||
var mbId = "64b94289-9474-4d43-8c93-918ccc1920d1"; //https://musicbrainz.org/artist/64b94289-9474-4d43-8c93-918ccc1920d1
|
||||
|
@ -103,7 +101,7 @@ namespace Roadie.Library.Tests
|
|||
}
|
||||
var logger = new EventMessageLogger<MusicBrainzProvider>();
|
||||
logger.Messages += MessageLogger_Messages;
|
||||
var mb = new MusicBrainzProvider(Configuration, CacheManager, logger);
|
||||
var mb = new MusicBrainzProvider(Configuration, CacheManager, logger, _httpClientFactory);
|
||||
|
||||
var artistName = "Billy Joel";
|
||||
var mbId = "584a3887-c74e-4ff2-81e1-1620fbbe4f84"; // https://musicbrainz.org/release/584a3887-c74e-4ff2-81e1-1620fbbe4f84
|
||||
|
@ -122,11 +120,9 @@ namespace Roadie.Library.Tests
|
|||
Assert.Equal(release.MusicBrainzId, mbId);
|
||||
}
|
||||
|
||||
|
||||
private void MessageLogger_Messages(object sender, EventMessage e)
|
||||
{
|
||||
Console.WriteLine($"Log Level [{ e.Level }] Log Message [{ e.Message }] ");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -313,10 +313,10 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("THE BATMAN", "Batman, The")]
|
||||
[InlineData("THE batman", "Batman, The")]
|
||||
[InlineData("ThE BatmaN", "Batman, The")]
|
||||
[InlineData(" THE BatmaN ", "Batman, The")]
|
||||
[InlineData("Don’T Threaten Me With A Good Time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("Don’t Threaten Me With A Good Time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("don’t threaten me with a good time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData(" THE BatmaN ", "Batman, The")]
|
||||
[InlineData("Don’T Threaten Me With A Good Time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("Don’t Threaten Me With A Good Time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("don’t threaten me with a good time", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("DON'T THREATEN ME WITH A GOOD TIME", "Don't Threaten Me With A Good Time")]
|
||||
[InlineData("McDonald's", "McDonald's")]
|
||||
[InlineData("Macey Grey", "Macey Grey")]
|
||||
|
@ -331,7 +331,7 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("bIlLy jOeL", "Billy Joel")]
|
||||
[InlineData("dick van dyke", "Dick Van Dyke")]
|
||||
[InlineData("Dick van Dyke", "Dick Van Dyke")]
|
||||
[InlineData("DICK VAN DYKE", "Dick Van Dyke")]
|
||||
[InlineData("DICK VAN DYKE", "Dick Van Dyke")]
|
||||
[InlineData("Michael Mcdonald", "Michael McDonald")]
|
||||
[InlineData("MICHAEL MCDONALD", "Michael McDonald")]
|
||||
[InlineData("delbert mcclinton", "Delbert McClinton")]
|
||||
|
@ -346,8 +346,8 @@ namespace Roadie.Library.Tests
|
|||
[InlineData("don mcclean", "Don McClean")]
|
||||
[InlineData("edWIN mccain", "Edwin McCain")]
|
||||
[InlineData("kyle mcevoy", "Kyle McEvoy")]
|
||||
[InlineData("c.w. mccall", "C.W. McCall")]
|
||||
[InlineData("Loreena Mckennitt", "Loreena McKennitt")]
|
||||
[InlineData("c.w. mccall", "C.W. McCall")]
|
||||
[InlineData("Loreena Mckennitt", "Loreena McKennitt")]
|
||||
public void ToTitleCase(string input, string shouldBe)
|
||||
{
|
||||
Assert.Equal(shouldBe, input.ToTitleCase());
|
||||
|
@ -389,7 +389,6 @@ namespace Roadie.Library.Tests
|
|||
Assert.Null(t);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://itunes.apple.com/us/artist/id485953", "id485953")]
|
||||
[InlineData("https://www.last.fm/music/Billy+Joel", "Billy+Joel")]
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
using Roadie.Api.Services;
|
||||
using Roadie.Library.Identity;
|
||||
using Roadie.Library.MetaData.Audio;
|
||||
using Roadie.Library.MetaData.ID3Tags;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
|
@ -28,4 +23,4 @@ namespace Roadie.Library.Tests
|
|||
Assert.NotNull(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +1,22 @@
|
|||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Roadie.Library.Utility;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
|
||||
namespace Roadie.Library.Tests
|
||||
{
|
||||
public class WebHelperTests
|
||||
public class WebHelperTests : HttpClientFactoryBaseTests
|
||||
{
|
||||
[Fact]
|
||||
public void DownloadTestImage()
|
||||
public async Task DownloadTestImage()
|
||||
{
|
||||
var testImageUrl = @"https://i.ytimg.com/vi/OiH5YMXQwYg/maxresdefault.jpg";
|
||||
var imageBytes = WebHelper.BytesForImageUrl(testImageUrl);
|
||||
var imageBytes = await WebHelper.BytesForImageUrl(_httpClientFactory, testImageUrl).ConfigureAwait(false);
|
||||
Assert.NotNull(imageBytes);
|
||||
Assert.NotEmpty(imageBytes);
|
||||
|
||||
var coverFileName = Path.Combine(@"C:\roadie_dev_root", "testImage.jpg");
|
||||
File.WriteAllBytes(coverFileName, imageBytes);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using discogs = Roadie.Library.SearchEngines.MetaData.Discogs;
|
||||
|
@ -57,8 +58,9 @@ namespace Roadie.Library.Engines
|
|||
spotify.ISpotifyHelper spotifyHelper,
|
||||
wikipedia.IWikipediaHelper wikipediaHelper,
|
||||
discogs.IDiscogsHelper discogsHelper,
|
||||
IITunesSearchEngine iTunesSearchEngine)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger)
|
||||
IITunesSearchEngine iTunesSearchEngine,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
ITunesArtistSearchEngine = iTunesSearchEngine;
|
||||
MusicBrainzArtistSearchEngine = musicBrainzProvider;
|
||||
|
|
|
@ -11,6 +11,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using discogs = Roadie.Library.SearchEngines.MetaData.Discogs;
|
||||
|
||||
|
@ -20,9 +21,15 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
private ILabelSearchEngine DiscogsLabelSearchEngine { get; }
|
||||
|
||||
public LabelLookupEngine(IRoadieSettings configuration, IHttpEncoder httpEncoder, IRoadieDbContext context,
|
||||
ICacheManager cacheManager, ILogger<LabelLookupEngine> logger, discogs.IDiscogsHelper discogsHelper)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger)
|
||||
public LabelLookupEngine(
|
||||
IRoadieSettings configuration,
|
||||
IHttpEncoder httpEncoder,
|
||||
IRoadieDbContext context,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<LabelLookupEngine> logger,
|
||||
discogs.IDiscogsHelper discogsHelper,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
DiscogsLabelSearchEngine = discogsHelper;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using Roadie.Library.Caching;
|
|||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Data.Context;
|
||||
using Roadie.Library.Encoding;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Roadie.Library.Engines
|
||||
{
|
||||
|
@ -18,14 +19,22 @@ namespace Roadie.Library.Engines
|
|||
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
public LookupEngineBase(IRoadieSettings configuration, IHttpEncoder httpEncoder, IRoadieDbContext context,
|
||||
ICacheManager cacheManager, ILogger logger)
|
||||
protected IHttpClientFactory HttpClientFactory { get; }
|
||||
|
||||
public LookupEngineBase(
|
||||
IRoadieSettings configuration,
|
||||
IHttpEncoder httpEncoder,
|
||||
IRoadieDbContext context,
|
||||
ICacheManager cacheManager,
|
||||
ILogger logger,
|
||||
IHttpClientFactory httpclientFactory)
|
||||
{
|
||||
Configuration = configuration;
|
||||
HttpEncoder = httpEncoder;
|
||||
DbContext = context;
|
||||
CacheManager = cacheManager;
|
||||
Logger = logger;
|
||||
HttpClientFactory = httpclientFactory;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using discogs = Roadie.Library.SearchEngines.MetaData.Discogs;
|
||||
using lastfm = Roadie.Library.MetaData.LastFm;
|
||||
|
@ -53,12 +54,22 @@ namespace Roadie.Library.Engines
|
|||
|
||||
public IReleaseSearchEngine WikipediaReleaseSearchEngine { get; }
|
||||
|
||||
public ReleaseLookupEngine(IRoadieSettings configuration, IHttpEncoder httpEncoder, IRoadieDbContext context,
|
||||
ICacheManager cacheManager, ILogger<ReleaseLookupEngine> logger, IArtistLookupEngine artistLookupEngine,
|
||||
ILabelLookupEngine labelLookupEngine, musicbrainz.IMusicBrainzProvider musicBrainzProvider, lastfm.ILastFmHelper lastFmHelper,
|
||||
spotify.ISpotifyHelper spotifyHelper, wikipedia.IWikipediaHelper wikipediaHelper, discogs.IDiscogsHelper discogsHelper,
|
||||
IITunesSearchEngine iTunesSearchEngine)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger)
|
||||
public ReleaseLookupEngine(
|
||||
IRoadieSettings configuration,
|
||||
IHttpEncoder httpEncoder,
|
||||
IRoadieDbContext context,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<ReleaseLookupEngine> logger,
|
||||
IArtistLookupEngine artistLookupEngine,
|
||||
ILabelLookupEngine labelLookupEngine,
|
||||
musicbrainz.IMusicBrainzProvider musicBrainzProvider,
|
||||
lastfm.ILastFmHelper lastFmHelper,
|
||||
spotify.ISpotifyHelper spotifyHelper,
|
||||
wikipedia.IWikipediaHelper wikipediaHelper,
|
||||
discogs.IDiscogsHelper discogsHelper,
|
||||
IITunesSearchEngine iTunesSearchEngine,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
ArtistLookupEngine = artistLookupEngine;
|
||||
LabelLookupEngine = labelLookupEngine;
|
||||
|
@ -497,7 +508,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
releaseImages.Add(new Imaging.Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(i.ReleaseThumbnailUrl)
|
||||
Bytes = await WebHelper.BytesForImageUrl(HttpClientFactory, i.ReleaseThumbnailUrl).ConfigureAwait(false)
|
||||
});
|
||||
}
|
||||
result.CopyTo(new Release
|
||||
|
@ -578,7 +589,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(mb.ReleaseThumbnailUrl)
|
||||
Bytes = await WebHelper.BytesForImageUrl(HttpClientFactory, mb.ReleaseThumbnailUrl).ConfigureAwait(false)
|
||||
});
|
||||
}
|
||||
result.CopyTo(new Release
|
||||
|
@ -664,7 +675,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(l.ReleaseThumbnailUrl)
|
||||
Bytes = await WebHelper.BytesForImageUrl(HttpClientFactory, l.ReleaseThumbnailUrl).ConfigureAwait(false)
|
||||
});
|
||||
}
|
||||
result.CopyTo(new Release
|
||||
|
@ -743,7 +754,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(s.ReleaseThumbnailUrl)
|
||||
Bytes = await WebHelper.BytesForImageUrl(HttpClientFactory, s.ReleaseThumbnailUrl).ConfigureAwait(false)
|
||||
});
|
||||
}
|
||||
result.CopyTo(new Release
|
||||
|
@ -816,7 +827,7 @@ namespace Roadie.Library.Engines
|
|||
{
|
||||
releaseImages.Add(new Image()
|
||||
{
|
||||
Bytes = WebHelper.BytesForImageUrl(d.ReleaseThumbnailUrl)
|
||||
Bytes = await WebHelper.BytesForImageUrl(HttpClientFactory, d.ReleaseThumbnailUrl).ConfigureAwait(false)
|
||||
});
|
||||
}
|
||||
result.CopyTo(new Release
|
||||
|
|
|
@ -13,7 +13,9 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using models = Roadie.Library.Models;
|
||||
|
||||
namespace Roadie.Library.Imaging
|
||||
|
@ -332,7 +334,7 @@ namespace Roadie.Library.Imaging
|
|||
public static string[] ImageMimeTypes()
|
||||
{ return new string[4] { "image/bmp", "image/jpeg", "image/png", "image/gif" }; }
|
||||
|
||||
public static ImageSearchResult ImageSearchResultForImageUrl(string imageUrl)
|
||||
public static async Task<ImageSearchResult> ImageSearchResultForImageUrl(IHttpClientFactory httpClientFactory, string imageUrl)
|
||||
{
|
||||
if (!WebHelper.IsStringUrl(imageUrl))
|
||||
{
|
||||
|
@ -340,7 +342,7 @@ namespace Roadie.Library.Imaging
|
|||
}
|
||||
|
||||
var result = new ImageSearchResult();
|
||||
var imageBytes = WebHelper.BytesForImageUrl(imageUrl);
|
||||
var imageBytes = await WebHelper.BytesForImageUrl(httpClientFactory, imageUrl);
|
||||
IImageFormat imageFormat = null;
|
||||
using (var image = SixLabors.ImageSharp.Image.Load(imageBytes, out imageFormat))
|
||||
{
|
||||
|
|
|
@ -20,6 +20,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Roadie.Library.Inspect
|
||||
|
@ -121,7 +122,7 @@ namespace Roadie.Library.Inspect
|
|||
}
|
||||
}
|
||||
|
||||
public Inspector()
|
||||
public Inspector(IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
MessageLogger = new EventMessageLogger<Inspector>();
|
||||
MessageLogger.Messages += MessageLogger_Messages;
|
||||
|
@ -137,7 +138,7 @@ namespace Roadie.Library.Inspect
|
|||
|
||||
var tagHelperLooper = new EventMessageLogger<ID3TagsHelper>();
|
||||
tagHelperLooper.Messages += MessageLogger_Messages;
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper);
|
||||
TagsHelper = new ID3TagsHelper(Configuration, CacheManager, tagHelperLooper, httpClientFactory);
|
||||
}
|
||||
|
||||
private void InspectImage(bool isReadOnly, bool doCopy, string dest, string subdirectory, FileInfo image)
|
||||
|
|
|
@ -12,38 +12,39 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="AutoCompare.Core" Version="1.0.0" />
|
||||
<PackageReference Include="CsvHelper" Version="27.2.1" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="6.1.6" />
|
||||
<PackageReference Include="FluentFTP" Version="35.2.1" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="6.3.0" />
|
||||
<PackageReference Include="FluentFTP" Version="36.1.0" />
|
||||
<PackageReference Include="Hashids.net" Version="1.4.1" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.39" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.40" />
|
||||
<PackageReference Include="IdSharp.Common" Version="1.0.1" />
|
||||
<PackageReference Include="IdSharp.Tagging" Version="1.0.0-rc3" />
|
||||
<PackageReference Include="Inflatable.Lastfm" Version="1.2.0" />
|
||||
<PackageReference Include="LiteDB" Version="5.0.11" />
|
||||
<PackageReference Include="Magick.NET-Q16-x64" Version="8.4.0" />
|
||||
<PackageReference Include="Magick.NET-Q16-x64" Version="8.6.1" />
|
||||
<PackageReference Include="Mapster" Version="7.2.0" />
|
||||
<PackageReference Include="MetadataExtractor" Version="2.7.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
|
||||
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.0" />
|
||||
<PackageReference Include="Microsoft.PowerShell.SDK" Version="7.2.1" />
|
||||
<PackageReference Include="MimeMapping" Version="1.0.1.37" />
|
||||
<PackageReference Include="NodaTime" Version="3.0.9" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.15.0" />
|
||||
<PackageReference Include="RestSharp" Version="107.1.1" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
|
||||
<PackageReference Include="System.Runtime.Caching" Version="6.0.0" />
|
||||
<PackageReference Include="Utf8Json" Version="1.3.7" />
|
||||
<PackageReference Include="z440.atl.core" Version="3.25.0" />
|
||||
<PackageReference Include="zlib.net-mutliplatform" Version="1.0.5" />
|
||||
<PackageReference Include="z440.atl.core" Version="4.3.0" />
|
||||
<PackageReference Include="zlib.net-mutliplatform" Version="1.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "/bing/v7.0/images/search",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
ImageSearchResult[] result = null;
|
||||
try
|
||||
{
|
||||
var response = _client.Execute<ITunesSearchResult>(request);
|
||||
var response = await _client.ExecuteAsync<ITunesSearchResult>(request);
|
||||
if (response.ResponseStatus == ResponseStatus.Error)
|
||||
{
|
||||
if (response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
|
@ -164,7 +164,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "search",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
|
||||
|
|
|
@ -37,10 +37,10 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
_requestIp = requestIp;
|
||||
_logger = logger;
|
||||
|
||||
_client = new RestClient(baseUrl)
|
||||
_client = new RestClient(new RestClientOptions(baseUrl)
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
};
|
||||
});
|
||||
|
||||
ServicePointManager.ServerCertificateValidationCallback += delegate
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using Roadie.Library.Configuration;
|
|||
using Roadie.Library.Imaging;
|
||||
using Roadie.Library.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.SearchEngines.Imaging
|
||||
|
@ -12,18 +13,26 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
{
|
||||
private readonly IImageSearchEngine _bingSearchEngine;
|
||||
private readonly IImageSearchEngine _itunesSearchEngine;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
private IRoadieSettings Configuration { get; }
|
||||
|
||||
private int DefaultResultsCount => 10;
|
||||
|
||||
public ImageSearchManager(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<ImageSearchManager> logger,
|
||||
IBingImageSearchEngine bingImageSearchEngine, IITunesSearchEngine iTunesSearchEngine,
|
||||
string requestIp = null, string referrer = null)
|
||||
public ImageSearchManager(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<ImageSearchManager> logger,
|
||||
IBingImageSearchEngine bingImageSearchEngine,
|
||||
IITunesSearchEngine iTunesSearchEngine,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
string requestIp = null,
|
||||
string referrer = null)
|
||||
{
|
||||
Configuration = configuration;
|
||||
_bingSearchEngine = bingImageSearchEngine;
|
||||
_itunesSearchEngine = iTunesSearchEngine;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ImageSearchResult>> ImageSearch(string query, int? resultsCount = null)
|
||||
|
@ -32,7 +41,7 @@ namespace Roadie.Library.SearchEngines.Imaging
|
|||
var result = new List<ImageSearchResult>();
|
||||
if (WebHelper.IsStringUrl(query))
|
||||
{
|
||||
var s = ImageHelper.ImageSearchResultForImageUrl(query);
|
||||
var s = await ImageHelper.ImageSearchResultForImageUrl(_httpClientFactory, query);
|
||||
if (s != null) result.Add(s);
|
||||
}
|
||||
if (Configuration.Integrations.BingImageSearchEngineEnabled)
|
||||
|
|
|
@ -9,6 +9,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Authentication;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -18,8 +19,12 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
{
|
||||
public override bool IsEnabled => Configuration.Integrations.DiscogsProviderEnabled;
|
||||
|
||||
public DiscogsHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<DiscogsHelper> logger) : base(
|
||||
configuration, cacheManager, logger)
|
||||
public DiscogsHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<DiscogsHelper> logger,
|
||||
IHttpClientFactory httpClientFactory) : base(
|
||||
configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
_apiKey = configuration.Integrations.ApiKeys.FirstOrDefault(x => x.ApiName == "DiscogsConsumerKey") ?? new ApiKey();
|
||||
}
|
||||
|
@ -35,11 +40,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
Logger.LogTrace("DiscogsHelper:PerformArtistSearch:{0}", query);
|
||||
var request = BuildSearchRequest(query, 1, "artist");
|
||||
|
||||
var client = new RestClient("https://api.discogs.com/database")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
};
|
||||
|
||||
var client = new RestClient(new RestClientOptions("https://api.discogs.com/database")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
});
|
||||
var response = await client.ExecuteAsync<DiscogsResult>(request).ConfigureAwait(false);
|
||||
|
||||
if (response.ResponseStatus == ResponseStatus.Error)
|
||||
|
@ -57,10 +61,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
if (responseData != null)
|
||||
{
|
||||
request = BuildArtistRequest(responseData.id);
|
||||
var c2 = new RestClient("https://api.discogs.com/")
|
||||
var c2 = new RestClient(new RestClientOptions("https://api.discogs.com/")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
};
|
||||
});
|
||||
var artistResponse = await c2.ExecuteAsync<DiscogArtistResponse>(request).ConfigureAwait(false);
|
||||
var artist = artistResponse.Data;
|
||||
if (artist != null)
|
||||
|
@ -123,8 +127,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
{
|
||||
var request = BuildSearchRequest(labelName, 1, "label");
|
||||
|
||||
var client = new RestClient("https://api.discogs.com/database");
|
||||
client.UserAgent = WebHelper.UserAgent;
|
||||
var client = new RestClient(new RestClientOptions("https://api.discogs.com/database")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
});
|
||||
|
||||
var response = await client.ExecuteAsync<DiscogsResult>(request).ConfigureAwait(false);
|
||||
|
||||
|
@ -142,8 +148,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
if (responseData != null)
|
||||
{
|
||||
request = BuildLabelRequest(responseData.id);
|
||||
var c2 = new RestClient("https://api.discogs.com/");
|
||||
c2.UserAgent = WebHelper.UserAgent;
|
||||
var c2 = new RestClient(new RestClientOptions("https://api.discogs.com/")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
});
|
||||
var labelResponse = await c2.ExecuteAsync<DiscogsLabelResult>(request).ConfigureAwait(false);
|
||||
var label = labelResponse.Data;
|
||||
if (label != null)
|
||||
|
@ -200,13 +208,12 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
{
|
||||
var request = BuildSearchRequest(query, 10, "release", artistName);
|
||||
|
||||
var client = new RestClient("https://api.discogs.com/database")
|
||||
var client = new RestClient(new RestClientOptions("https://api.discogs.com/database")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent,
|
||||
ReadWriteTimeout = SafeParser.ToNumber<int>(Configuration.Integrations.DiscogsReadWriteTimeout),
|
||||
UserAgent = WebHelper.UserAgent,
|
||||
Timeout = SafeParser.ToNumber<int>(Configuration.Integrations.DiscogsTimeout)
|
||||
};
|
||||
|
||||
});
|
||||
var response = await client.ExecuteAsync<DiscogsReleaseSearchResult>(request).ConfigureAwait(false);
|
||||
if (response?.ResponseStatus == null || response.ResponseStatus == ResponseStatus.Error)
|
||||
{
|
||||
|
@ -221,10 +228,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
if (responseData?.id != null)
|
||||
{
|
||||
request = BuildReleaseRequest(responseData.id);
|
||||
var c2 = new RestClient("https://api.discogs.com/")
|
||||
var c2 = new RestClient(new RestClientOptions("https://api.discogs.com/")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
};
|
||||
});
|
||||
var releaseResult = await c2.ExecuteAsync<DiscogReleaseDetail>(request).ConfigureAwait(false);
|
||||
var release = releaseResult?.Data;
|
||||
if (release != null)
|
||||
|
@ -324,7 +331,7 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "artists/{id}",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
request.AddUrlSegment("id", artistId.ToString());
|
||||
|
@ -338,7 +345,7 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "labels/{id}",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
request.AddUrlSegment("id", artistId.ToString());
|
||||
|
@ -352,7 +359,7 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "releases/{id}",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
request.AddUrlSegment("id", releaseId.ToString());
|
||||
|
@ -366,7 +373,7 @@ namespace Roadie.Library.SearchEngines.MetaData.Discogs
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "search",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
if (resultsCount > 0)
|
||||
|
|
|
@ -6,14 +6,19 @@ using Roadie.Library.MetaData.Audio;
|
|||
using Roadie.Library.Utility;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Roadie.Library.MetaData.FileName
|
||||
{
|
||||
public class FileNameHelper : MetaDataProviderBase, IFileNameHelper
|
||||
{
|
||||
public FileNameHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<FileNameHelper> logger)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public FileNameHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<FileNameHelper> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Roadie.Library.MetaData.ID3Tags
|
||||
|
@ -21,8 +22,12 @@ namespace Roadie.Library.MetaData.ID3Tags
|
|||
{
|
||||
public const int MaximumDiscNumber = 500; // Damnit Karajan
|
||||
|
||||
public ID3TagsHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<ID3TagsHelper> logger)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public ID3TagsHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<ID3TagsHelper> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -42,9 +43,14 @@ namespace Roadie.Library.MetaData.LastFm
|
|||
|
||||
private IHttpEncoder HttpEncoder { get; }
|
||||
|
||||
public LastFmHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<LastFmHelper> logger,
|
||||
IRoadieDbContext dbContext, IHttpEncoder httpEncoder)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public LastFmHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<LastFmHelper> logger,
|
||||
IRoadieDbContext dbContext,
|
||||
IHttpEncoder httpEncoder,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
_apiKey = configuration.Integrations.ApiKeys.FirstOrDefault(x => x.ApiName == "LastFMApiKey") ??
|
||||
new ApiKey();
|
||||
|
@ -84,7 +90,8 @@ namespace Roadie.Library.MetaData.LastFm
|
|||
{
|
||||
{"token", token}
|
||||
};
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
var client = new RestClient(BuildUrl("auth.getSession", parameters));
|
||||
var responseXML = await client.ExecuteAsync<string>(request).ConfigureAwait(false);
|
||||
var doc = new XmlDocument();
|
||||
|
@ -203,7 +210,8 @@ namespace Roadie.Library.MetaData.LastFm
|
|||
var cacheKey = $"uri:lastfm:releasesearch:{ artistName.ToAlphanumericName() }:{ query.ToAlphanumericName() }";
|
||||
var data = await CacheManager.GetAsync<ReleaseSearchResult>(cacheKey, async () =>
|
||||
{
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
var client = new RestClient(string.Format("http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key={0}&artist={1}&album={2}&format=xml", ApiKey.Key, artistName, query));
|
||||
var responseData = await client.ExecuteAsync<lfm>(request).ConfigureAwait(false);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Roadie.Library.MetaData
|
||||
{
|
||||
|
@ -10,6 +11,7 @@ namespace Roadie.Library.MetaData
|
|||
protected readonly ICacheManager _cacheManager;
|
||||
protected readonly IRoadieSettings _configuration;
|
||||
protected readonly ILogger _logger;
|
||||
protected readonly IHttpClientFactory _httpClientFactory;
|
||||
|
||||
protected IApiKey _apiKey = null;
|
||||
|
||||
|
@ -23,11 +25,16 @@ namespace Roadie.Library.MetaData
|
|||
|
||||
protected ILogger Logger => _logger;
|
||||
|
||||
public MetaDataProviderBase(IRoadieSettings configuration, ICacheManager cacheManager, ILogger logger)
|
||||
public MetaDataProviderBase(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_cacheManager = cacheManager;
|
||||
_logger = logger;
|
||||
_httpClientFactory = httpClientFactory;
|
||||
|
||||
ServicePointManager.ServerCertificateValidationCallback += delegate
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@ using Roadie.Library.Utility;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.MetaData.MusicBrainz
|
||||
|
@ -17,8 +18,12 @@ namespace Roadie.Library.MetaData.MusicBrainz
|
|||
public override bool IsEnabled => Configuration.Integrations.MusicBrainzProviderEnabled;
|
||||
private MusicBrainzRepository Repository { get; }
|
||||
|
||||
public MusicBrainzProvider(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<MusicBrainzProvider> logger)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public MusicBrainzProvider(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<MusicBrainzProvider> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
Repository = new MusicBrainzRepository(configuration, logger);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Roadie.Library.MetaData.MusicBrainz
|
|||
/// </summary>
|
||||
internal static string CreateSearchTemplate(string entity, string query, int limit, int offset)
|
||||
{
|
||||
query = Uri.EscapeUriString(query);
|
||||
query = Uri.EscapeDataString(query);
|
||||
|
||||
return string.Format("{0}{1}", WebServiceUrl, string.Format(SearchTemplate, entity, query, limit, offset));
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Authentication;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -18,8 +19,12 @@ namespace Roadie.Library.SearchEngines.MetaData.Spotify
|
|||
{
|
||||
public override bool IsEnabled => Configuration.Integrations.SpotifyProviderEnabled;
|
||||
|
||||
public SpotifyHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<SpotifyHelper> logger)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public SpotifyHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<SpotifyHelper> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,8 +39,10 @@ namespace Roadie.Library.SearchEngines.MetaData.Spotify
|
|||
Logger.LogTrace("SpotifyHelper:PerformArtistSearch:{0}", query);
|
||||
var request = BuildSearchRequest(query, 1, "artist");
|
||||
|
||||
var client = new RestClient("http://api.spotify.com/v1");
|
||||
client.UserAgent = WebHelper.UserAgent;
|
||||
var client = new RestClient(new RestClientOptions("http://api.spotify.com/v1")
|
||||
{
|
||||
UserAgent = WebHelper.UserAgent
|
||||
});
|
||||
|
||||
var response = await client.ExecuteAsync<SpotifyResult>(request).ConfigureAwait(false);
|
||||
|
||||
|
@ -84,7 +91,8 @@ namespace Roadie.Library.SearchEngines.MetaData.Spotify
|
|||
try
|
||||
{
|
||||
var tcs = new TaskCompletionSource<OperationResult<IEnumerable<ReleaseSearchResult>>>();
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
|
||||
ReleaseSearchResult result = null;
|
||||
|
||||
|
@ -209,7 +217,8 @@ namespace Roadie.Library.SearchEngines.MetaData.Spotify
|
|||
var result = CacheManager.Get<Albums>(cacheKey);
|
||||
if (result == null)
|
||||
{
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
var client = new RestClient(string.Format(
|
||||
"http://api.spotify.com/v1/artists/{0}/albums?offset=0&limit=25&album_type=album&market=US",
|
||||
spotifyId));
|
||||
|
@ -228,7 +237,7 @@ namespace Roadie.Library.SearchEngines.MetaData.Spotify
|
|||
var request = new RestRequest
|
||||
{
|
||||
Resource = "search",
|
||||
Method = Method.GET,
|
||||
Method = Method.Get,
|
||||
RequestFormat = DataFormat.Json
|
||||
};
|
||||
request.AddParameter("type", entityType, ParameterType.GetOrPost);
|
||||
|
|
|
@ -6,6 +6,7 @@ using Roadie.Library.Encoding;
|
|||
using Roadie.Library.MetaData;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.SearchEngines.MetaData.Wikipedia
|
||||
|
@ -14,9 +15,13 @@ namespace Roadie.Library.SearchEngines.MetaData.Wikipedia
|
|||
{
|
||||
private IHttpEncoder HttpEncoder { get; }
|
||||
|
||||
public WikipediaHelper(IRoadieSettings configuration, ICacheManager cacheManager, ILogger<WikipediaHelper> logger,
|
||||
IHttpEncoder httpEncoder)
|
||||
: base(configuration, cacheManager, logger)
|
||||
public WikipediaHelper(
|
||||
IRoadieSettings configuration,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<WikipediaHelper> logger,
|
||||
IHttpEncoder httpEncoder,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, cacheManager, logger, httpClientFactory)
|
||||
{
|
||||
HttpEncoder = httpEncoder;
|
||||
}
|
||||
|
@ -28,7 +33,8 @@ namespace Roadie.Library.SearchEngines.MetaData.Wikipedia
|
|||
return new OperationResult<IEnumerable<ArtistSearchResult>>();
|
||||
}
|
||||
var client = new RestClient("https://en.wikipedia.org/w/api.php?format=xml&action=query&redirects=1&prop=extracts&exintro=&explaintext=&titles=" + HttpEncoder.UrlEncode(query ?? string.Empty));
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
var response = await client.ExecuteAsync<api>(request).ConfigureAwait(false);
|
||||
ArtistSearchResult data = null;
|
||||
if (response?.Data?.query?.pages?.Any() ?? false)
|
||||
|
@ -52,7 +58,8 @@ namespace Roadie.Library.SearchEngines.MetaData.Wikipedia
|
|||
public async Task<OperationResult<IEnumerable<ReleaseSearchResult>>> PerformReleaseSearch(string artistName, string query, int resultsCount)
|
||||
{
|
||||
var client = new RestClient("https://en.wikipedia.org/w/api.php?format=xml&action=query&redirects=1&prop=extracts&exintro=&explaintext=&titles=" + HttpEncoder.UrlEncode(query ?? string.Empty) + " (album)");
|
||||
var request = new RestRequest(Method.GET);
|
||||
var request = new RestRequest();
|
||||
request.Method = Method.Get;
|
||||
var response = await client.ExecuteAsync<api>(request).ConfigureAwait(false);
|
||||
ReleaseSearchResult data = null;
|
||||
if (response?.Data?.query?.pages != null)
|
||||
|
|
|
@ -5,29 +5,29 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Library.Utility
|
||||
{
|
||||
public static class WebHelper
|
||||
{
|
||||
public const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36";
|
||||
public const string UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0";
|
||||
|
||||
public static byte[] BytesForImageUrl(string url)
|
||||
public static async Task<byte[]> BytesForImageUrl(IHttpClientFactory httpclientFactory, string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) return null;
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Referer = "http://www.roadie.rocks";
|
||||
request.UserAgent = UserAgent;
|
||||
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
var client = httpclientFactory.CreateClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, url);
|
||||
var response = await client.SendAsync(request).ConfigureAwait(false);
|
||||
if(response.IsSuccessStatusCode)
|
||||
{
|
||||
using (BinaryReader reader = new BinaryReader(response.GetResponseStream()))
|
||||
{
|
||||
return reader.ReadBytes(1 * 1024 * 1024 * 10);
|
||||
}
|
||||
return await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (WebException wex)
|
||||
|
|
|
@ -24,12 +24,13 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public class ArtistService : ServiceBase, IArtistService
|
||||
public class ArtistService : HttpFactoryServiceBase<ArtistService>, IArtistService
|
||||
{
|
||||
private IArtistLookupEngine ArtistLookupEngine { get; }
|
||||
|
||||
|
@ -57,9 +58,10 @@ namespace Roadie.Api.Services
|
|||
IReleaseService releaseService,
|
||||
IArtistLookupEngine artistLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper,
|
||||
IFileDirectoryProcessorService fileDirectoryProcessorService
|
||||
IFileDirectoryProcessorService fileDirectoryProcessorService,
|
||||
IHttpClientFactory httpClientFactory
|
||||
)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext, httpClientFactory)
|
||||
{
|
||||
CollectionService = collectionService;
|
||||
PlaylistService = playlistService;
|
||||
|
@ -1212,7 +1214,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public Task<OperationResult<Library.Models.Image>> SetReleaseImageByUrlAsync(Library.Identity.User user, Guid id, string imageUrl) => SaveImageBytes(user, id, WebHelper.BytesForImageUrl(imageUrl));
|
||||
public async Task<OperationResult<Library.Models.Image>> SetReleaseImageByUrlAsync(Library.Identity.User user, Guid id, string imageUrl) => await SaveImageBytes(user, id, await WebHelper.BytesForImageUrl(HttpClientFactory, imageUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
|
||||
public async Task<OperationResult<bool>> UpdateArtistAsync(Library.Identity.User user, Artist model)
|
||||
{
|
||||
|
|
|
@ -19,20 +19,22 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public class GenreService : ServiceBase, IGenreService
|
||||
public class GenreService : HttpFactoryServiceBase<GenreService>, IGenreService
|
||||
{
|
||||
public GenreService(IRoadieSettings configuration,
|
||||
IHttpEncoder httpEncoder,
|
||||
IHttpContext httpContext,
|
||||
IRoadieDbContext dbContext,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<GenreService> logger)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext)
|
||||
ILogger<GenreService> logger,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext, httpClientFactory)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -265,7 +267,7 @@ namespace Roadie.Api.Services
|
|||
});
|
||||
}
|
||||
|
||||
public Task<OperationResult<Library.Models.Image>> SetGenreImageByUrlAsync(Library.Models.Users.User user, Guid id, string imageUrl) => SaveImageBytes(user, id, WebHelper.BytesForImageUrl(imageUrl));
|
||||
public async Task<OperationResult<Library.Models.Image>> SetGenreImageByUrlAsync(Library.Models.Users.User user, Guid id, string imageUrl) => await SaveImageBytes(user, id, await WebHelper.BytesForImageUrl(HttpClientFactory, imageUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
|
||||
public async Task<OperationResult<bool>> UpdateGenreAsync(Library.Models.Users.User user, Genre model)
|
||||
{
|
||||
|
|
35
Roadie.Api.Services/HttpFactoryServiceBase.cs
Normal file
35
Roadie.Api.Services/HttpFactoryServiceBase.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Roadie.Library.Caching;
|
||||
using Roadie.Library.Configuration;
|
||||
using Roadie.Library.Data.Context;
|
||||
using Roadie.Library.Encoding;
|
||||
using Roadie.Library.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public abstract class HttpFactoryServiceBase<T> : ServiceBase
|
||||
{
|
||||
public IHttpClientFactory HttpClientFactory { get; }
|
||||
|
||||
public HttpFactoryServiceBase(
|
||||
IRoadieSettings configuration,
|
||||
IHttpEncoder httpEncoder,
|
||||
IRoadieDbContext dbContext,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<T> logger,
|
||||
IHttpContext httpContext,
|
||||
IHttpClientFactory httpClientFactory
|
||||
)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext)
|
||||
{
|
||||
HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -21,12 +21,13 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public class LabelService : ServiceBase, ILabelService
|
||||
public class LabelService : HttpFactoryServiceBase<LabelService>, ILabelService
|
||||
{
|
||||
private IBookmarkService BookmarkService { get; }
|
||||
|
||||
|
@ -36,8 +37,9 @@ namespace Roadie.Api.Services
|
|||
IRoadieDbContext context,
|
||||
ICacheManager cacheManager,
|
||||
ILogger<LabelService> logger,
|
||||
IBookmarkService bookmarkService)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext)
|
||||
IBookmarkService bookmarkService,
|
||||
IHttpClientFactory httpClientFactory)
|
||||
: base(configuration, httpEncoder, context, cacheManager, logger, httpContext, httpClientFactory)
|
||||
{
|
||||
BookmarkService = bookmarkService;
|
||||
}
|
||||
|
@ -398,7 +400,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public Task<OperationResult<Library.Models.Image>> SetLabelImageByUrlAsync(Library.Models.Users.User user, Guid id, string imageUrl) => SaveImageBytes(user, id, WebHelper.BytesForImageUrl(imageUrl));
|
||||
public async Task<OperationResult<Library.Models.Image>> SetLabelImageByUrlAsync(Library.Models.Users.User user, Guid id, string imageUrl) => await SaveImageBytes(user, id, await WebHelper.BytesForImageUrl(HttpClientFactory, imageUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
|
||||
public async Task<OperationResult<bool>> UpdateLabelAsync(Library.Models.Users.User user, Label model)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ using System.IO;
|
|||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using data = Roadie.Library.Data;
|
||||
using Image = Roadie.Library.Models.Image;
|
||||
|
@ -33,7 +34,7 @@ using Release = Roadie.Library.Models.Releases.Release;
|
|||
|
||||
namespace Roadie.Api.Services
|
||||
{
|
||||
public class ReleaseService : ServiceBase, IReleaseService
|
||||
public class ReleaseService : HttpFactoryServiceBase<ReleaseService>, IReleaseService
|
||||
{
|
||||
private IArtistLookupEngine ArtistLookupEngine { get; }
|
||||
|
||||
|
@ -56,9 +57,10 @@ namespace Roadie.Api.Services
|
|||
ILogger<ReleaseService> logger,
|
||||
IBookmarkService bookmarkService,
|
||||
IArtistLookupEngine artistLookupEngine,
|
||||
IAudioMetaDataHelper audioMetaDataHelper
|
||||
IAudioMetaDataHelper audioMetaDataHelper,
|
||||
IHttpClientFactory httpClientFactory
|
||||
)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext)
|
||||
: base(configuration, httpEncoder, dbContext, cacheManager, logger, httpContext, httpClientFactory)
|
||||
{
|
||||
PlaylistService = playlistService;
|
||||
BookmarkService = bookmarkService;
|
||||
|
@ -1982,7 +1984,7 @@ namespace Roadie.Api.Services
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<OperationResult<Image>> SetReleaseImageByUrlAsync(Library.Identity.User user, Guid id, string imageUrl) => await SaveImageBytes(user, id, WebHelper.BytesForImageUrl(imageUrl)).ConfigureAwait(false);
|
||||
public async Task<OperationResult<Image>> SetReleaseImageByUrlAsync(Library.Identity.User user, Guid id, string imageUrl) => await SaveImageBytes(user, id, await WebHelper.BytesForImageUrl(HttpClientFactory, imageUrl).ConfigureAwait(false)).ConfigureAwait(false);
|
||||
|
||||
public async Task<OperationResult<bool>> UpdateReleaseAsync(Library.Identity.User user, Release model, string originalReleaseFolder = null)
|
||||
{
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Hashids.net" Version="1.4.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.14" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -31,18 +31,19 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="BCrypt-Core" Version="2.0.0" />
|
||||
<PackageReference Include="Mapster" Version="7.2.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.19.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.1" />
|
||||
<PackageReference Include="Pastel" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
|
||||
|
@ -53,7 +54,7 @@
|
|||
<PackageReference Include="Serilog.Sinks.LiteDB.NetStandard" Version="1.0.14" />
|
||||
<PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.14" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -16,6 +16,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Polly;
|
||||
using Roadie.Api.Hubs;
|
||||
using Roadie.Api.ModelBinding;
|
||||
using Roadie.Api.Services;
|
||||
|
@ -45,6 +46,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
|
@ -347,6 +349,9 @@ namespace Roadie.Api
|
|||
});
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.AddHttpClient();
|
||||
|
||||
services.AddScoped<IHttpContext>(factory =>
|
||||
{
|
||||
var actionContext = factory.GetService<IActionContextAccessor>().ActionContext;
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace Roadie.Dlna.Server
|
|||
|
||||
listener = new TcpListener(new IPEndPoint(IPAddress.Any, port));
|
||||
listener.Server.Ttl = 32;
|
||||
listener.Server.UseOnlyOverlappedIO = true;
|
||||
listener.Start();
|
||||
|
||||
RealPort = ((IPEndPoint)listener.LocalEndpoint).Port;
|
||||
|
|
|
@ -133,7 +133,6 @@ namespace Roadie.Dlna.Server
|
|||
owner = aOwner;
|
||||
client = aClient;
|
||||
stream = client.GetStream();
|
||||
client.Client.UseOnlyOverlappedIO = true;
|
||||
|
||||
RemoteEndpoint = client.Client.RemoteEndPoint as IPEndPoint;
|
||||
LocalEndPoint = client.Client.LocalEndPoint as IPEndPoint;
|
||||
|
|
|
@ -69,7 +69,6 @@ namespace Roadie.Dlna.Server.Ssdp
|
|||
|
||||
queueTimer.Elapsed += ProcessQueue;
|
||||
|
||||
client.Client.UseOnlyOverlappedIO = true;
|
||||
client.Client.SetSocketOption(
|
||||
SocketOptionLevel.Socket,
|
||||
SocketOptionName.ReuseAddress,
|
||||
|
|
Loading…
Reference in a new issue