diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml
index 5f3fdc4..20b8388 100644
--- a/.github/workflows/cicd.yaml
+++ b/.github/workflows/cicd.yaml
@@ -35,13 +35,13 @@ jobs:
run: dotnet build --configuration Release --verbosity minimal
- name: Test (Unit) with Coverage
run: |
- dotnet test Tests/LyricsScraperNET.UnitTest --configuration Release --collect:"XPlat Code Coverage" --results-directory ./TestResults
+ dotnet test Tests/LyricsScraperNET.UnitTest \
+ --configuration Release \
+ --collect:"XPlat Code Coverage" \
+ --results-directory ./TestResults
env:
COVERLET_OUTPUT_FORMAT: cobertura
- - name: List Coverage Files
- run: |
- echo "Checking TestResults directory..."
- ls -R ./TestResults
+ COVERLET_EXCLUDE: "[LyricsScraperNET.TestShared*]*,[LyricsScraperNET.Client*]*"
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
with:
diff --git a/LyricsScraperNET.Client/ConsoleExtensions.cs b/LyricsScraperNET.Client/ConsoleExtensions.cs
index 9e04889..9d4ae3f 100644
--- a/LyricsScraperNET.Client/ConsoleExtensions.cs
+++ b/LyricsScraperNET.Client/ConsoleExtensions.cs
@@ -1,6 +1,6 @@
using System;
-namespace LyricsScraperNET
+namespace LyricsScraperNET.Client
{
public static class ConsoleExtensions
{
diff --git a/LyricsScraperNET.Client/Program.cs b/LyricsScraperNET.Client/Program.cs
index 082ce1a..6e28c4c 100644
--- a/LyricsScraperNET.Client/Program.cs
+++ b/LyricsScraperNET.Client/Program.cs
@@ -17,158 +17,161 @@
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
-class Program
+namespace LyricsScraperNET.Client
{
- static async Task Main()
+ class Program
{
- //// Input parameters to search:
- string artistToSearch = "Parkway Drive";
- string songToSearch = "Idols And Anchors";
+ static async Task Main()
+ {
+ //// Input parameters to search:
+ string artistToSearch = "Parkway Drive";
+ string songToSearch = "Idols And Anchors";
- //// Uncomment this block to test for instrumental songs (without vocals):
- //string artistToSearch = "Rush";
- //string songToSearch = "YYZ";
+ //// Uncomment this block to test for instrumental songs (without vocals):
+ //string artistToSearch = "Rush";
+ //string songToSearch = "YYZ";
- //// How to configure for ASP.NET applications:
- var result = ExampleWithHostConfiguration(artistToSearch, songToSearch);
+ //// How to configure for ASP.NET applications:
+ var result = ExampleWithHostConfiguration(artistToSearch, songToSearch);
- //// How to configure for a certain external provider using explicit instantiation:
- //var result = ExampleWithExplicitInstantiation(artistToSearch, songToSearch);
+ //// How to configure for a certain external provider using explicit instantiation:
+ //var result = ExampleWithExplicitInstantiation(artistToSearch, songToSearch);
- //// Checking that something was found. The response can be empty in two cases:
- //// 1) A search error occurred. Detailed information can be found in the logs or in response fields like 'ResponseStatusCode' and 'ResponseMessage'.
- //// 2) The requested song contains only the instrumental, no lyrics. In this case the flag 'Instrumental' will be true.
- if (result.IsEmpty())
- {
- ConsoleExtensions.WriteLineDelimeter();
- if (result.Instrumental)
+ //// Checking that something was found. The response can be empty in two cases:
+ //// 1) A search error occurred. Detailed information can be found in the logs or in response fields like 'ResponseStatusCode' and 'ResponseMessage'.
+ //// 2) The requested song contains only the instrumental, no lyrics. In this case the flag 'Instrumental' will be true.
+ if (result.IsEmpty())
{
- $"This song [{artistToSearch} - {songToSearch}] is instrumental.\r\nIt does not contain any lyrics"
- .WriteLineColored(ConsoleColor.Gray);
- }
- else
- {
- ($"Can't find lyrics for: [{artistToSearch} - {songToSearch}]. " +
- $"Status code: [{result.ResponseStatusCode}]. " +
- $"Response message: [{result.ResponseMessage}].").WriteLineColored(ConsoleColor.Red);
+ ConsoleExtensions.WriteLineDelimeter();
+ if (result.Instrumental)
+ {
+ $"This song [{artistToSearch} - {songToSearch}] is instrumental.\r\nIt does not contain any lyrics"
+ .WriteLineColored(ConsoleColor.Gray);
+ }
+ else
+ {
+ ($"Can't find lyrics for: [{artistToSearch} - {songToSearch}]. " +
+ $"Status code: [{result.ResponseStatusCode}]. " +
+ $"Response message: [{result.ResponseMessage}].").WriteLineColored(ConsoleColor.Red);
+ }
+ ConsoleExtensions.WriteLineDelimeter();
+
+ "Press any key to exit..".WriteLineColored(ConsoleColor.DarkGray);
+ Console.ReadLine();
+ return;
}
+
+ //// Output result to console
+ //// Artist and song information
+ $"[{artistToSearch} - {songToSearch}]".WriteLineColored(ConsoleColor.Yellow);
+
ConsoleExtensions.WriteLineDelimeter();
+ //// Lyric text
+ result.LyricText.WriteLineColored();
+ ConsoleExtensions.WriteLineDelimeter();
+
+ //// Lyrics provider information
+ $"This lyric was found by [{result.ExternalProviderType}]\r\n".WriteLineColored(ConsoleColor.Magenta);
"Press any key to exit..".WriteLineColored(ConsoleColor.DarkGray);
Console.ReadLine();
return;
}
- //// Output result to console
- //// Artist and song information
- $"[{artistToSearch} - {songToSearch}]".WriteLineColored(ConsoleColor.Yellow);
-
- ConsoleExtensions.WriteLineDelimeter();
- //// Lyric text
- result.LyricText.WriteLineColored();
- ConsoleExtensions.WriteLineDelimeter();
-
- //// Lyrics provider information
- $"This lyric was found by [{result.ExternalProviderType}]\r\n".WriteLineColored(ConsoleColor.Magenta);
-
- "Press any key to exit..".WriteLineColored(ConsoleColor.DarkGray);
- Console.ReadLine();
- return;
- }
-
- ///
- /// How to configure LyricScraperClient and search lyrics for ASP.NET applications:
- ///
- /// artist name to search
- /// song name to search
- /// lyrics text
- private static SearchResult ExampleWithHostConfiguration(string artistToSearch, string songToSearch)
- {
- //// Application Configuration section.
- //// LyricScraperClient configuration could be found in appsettings.json file in section with related name.
- IConfiguration configuration = new ConfigurationBuilder()
- .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
- .AddEnvironmentVariables()
- .Build();
-
- //// Host creation with LyricScraperClient service configuration
- using IHost host = Host.CreateDefaultBuilder()
- .ConfigureServices(services =>
- {
- // Setting up LyricScraperClient from configuration that stored in appsettings.json.
- // Only supported output type as string at the moment.
- services.AddLyricScraperClientService(configuration: configuration);
- })
- .Build();
-
- //// Get instance of LyricScraperClient service
- var lyricsScraperClient = host.Services.GetRequiredService();
-
- //// Create request and search
- var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch);
- CancellationToken cancellationToken = new CancellationToken();
- var result = lyricsScraperClient.SearchLyric(searchRequest, cancellationToken);
-
- return result;
- }
+ ///
+ /// How to configure LyricScraperClient and search lyrics for ASP.NET applications:
+ ///
+ /// artist name to search
+ /// song name to search
+ /// lyrics text
+ private static SearchResult ExampleWithHostConfiguration(string artistToSearch, string songToSearch)
+ {
+ //// Application Configuration section.
+ //// LyricScraperClient configuration could be found in appsettings.json file in section with related name.
+ IConfiguration configuration = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .AddEnvironmentVariables()
+ .Build();
+
+ //// Host creation with LyricScraperClient service configuration
+ using IHost host = Host.CreateDefaultBuilder()
+ .ConfigureServices(services =>
+ {
+ // Setting up LyricScraperClient from configuration that stored in appsettings.json.
+ // Only supported output type as string at the moment.
+ services.AddLyricScraperClientService(configuration: configuration);
+ })
+ .Build();
+
+ //// Get instance of LyricScraperClient service
+ var lyricsScraperClient = host.Services.GetRequiredService();
+
+ //// Create request and search
+ var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch);
+ CancellationToken cancellationToken = new CancellationToken();
+ var result = lyricsScraperClient.SearchLyric(searchRequest, cancellationToken);
+
+ return result;
+ }
- ///
- /// How to configure LyricScraperClient and search lyrics for a certain external provider:
- ///
- /// artist name to search
- /// song name to search
- /// lyrics text
- private static SearchResult ExampleWithExplicitInstantiation(string artistToSearch, string songToSearch)
- {
- //// Create instance of LyricScraperClient with all available lyrics providers
- ILyricsScraperClient lyricsScraperClient
- = new LyricsScraperClient()
- .WithAllProviders();
-
- //// To configure a specific provider, use a method like With[ProviderName]()
- // ILyricsScraperClient lyricsScraperClient
- // = new LyricsScraperClient()
- // .WithGenius()
- // .WithAZLyrics()
- // .WithMusixmatch()
- // .WithSongLyrics()
- // .WithLyricFind();
-
- //// To perform parallel searches across multiple external providers, enable the following option:
- // lyricsScraperClient.UseParallelSearch = true;
-
- // To enable library logging, the LoggerFactory must be configured and passed to the client.
- var loggerFactory = LoggerFactory.Create(builder =>
+ ///
+ /// How to configure LyricScraperClient and search lyrics for a certain external provider:
+ ///
+ /// artist name to search
+ /// song name to search
+ /// lyrics text
+ private static SearchResult ExampleWithExplicitInstantiation(string artistToSearch, string songToSearch)
{
- builder.AddFilter("Microsoft", LogLevel.Warning)
- .AddFilter("System", LogLevel.Warning)
- .AddFilter("LyricsScraperNET", LogLevel.Trace)
- .AddConsole();
- });
- lyricsScraperClient.WithLogger(loggerFactory);
-
- //// Another way to configure:
- //// 1. First create instance of LyricScraperClient.
- // ILyricsScraperClient lyricsScraperClient = new LyricsScraperClient();
- //// 2. Create some external provider instanse with default settings. For example Genius:
- // IExternalProvider externalProvider = new GeniusProvider();
- //// 2. Or create provider with custom settings like:
- // GeniusOptions geniusOptions = new GeniusOptions()
- // {
- // Enabled = true,
- // SearchPriority = 1 // If there are multiple external providers, then the search will start from the provider with the highest priority.
- // };
- // IExternalProvider externalProvider = new GeniusProvider(geniusOptions);
- //// 3. Add external provider to client:
- // lyricsScraperClient.AddProvider(externalProvider);
-
- //// Create request and search
- var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch);
- CancellationToken cancellationToken = new CancellationToken();
- var result = lyricsScraperClient.SearchLyric(searchRequest, cancellationToken);
-
- return result;
+ //// Create instance of LyricScraperClient with all available lyrics providers
+ ILyricsScraperClient lyricsScraperClient
+ = new LyricsScraperClient()
+ .WithAllProviders();
+
+ //// To configure a specific provider, use a method like With[ProviderName]()
+ // ILyricsScraperClient lyricsScraperClient
+ // = new LyricsScraperClient()
+ // .WithGenius()
+ // .WithAZLyrics()
+ // .WithMusixmatch()
+ // .WithSongLyrics()
+ // .WithLyricFind();
+
+ //// To perform parallel searches across multiple external providers, enable the following option:
+ // lyricsScraperClient.UseParallelSearch = true;
+
+ // To enable library logging, the LoggerFactory must be configured and passed to the client.
+ var loggerFactory = LoggerFactory.Create(builder =>
+ {
+ builder.AddFilter("Microsoft", LogLevel.Warning)
+ .AddFilter("System", LogLevel.Warning)
+ .AddFilter("LyricsScraperNET", LogLevel.Trace)
+ .AddConsole();
+ });
+ lyricsScraperClient.WithLogger(loggerFactory);
+
+ //// Another way to configure:
+ //// 1. First create instance of LyricScraperClient.
+ // ILyricsScraperClient lyricsScraperClient = new LyricsScraperClient();
+ //// 2. Create some external provider instanse with default settings. For example Genius:
+ // IExternalProvider externalProvider = new GeniusProvider();
+ //// 2. Or create provider with custom settings like:
+ // GeniusOptions geniusOptions = new GeniusOptions()
+ // {
+ // Enabled = true,
+ // SearchPriority = 1 // If there are multiple external providers, then the search will start from the provider with the highest priority.
+ // };
+ // IExternalProvider externalProvider = new GeniusProvider(geniusOptions);
+ //// 3. Add external provider to client:
+ // lyricsScraperClient.AddProvider(externalProvider);
+
+ //// Create request and search
+ var searchRequest = new ArtistAndSongSearchRequest(artistToSearch, songToSearch);
+ CancellationToken cancellationToken = new CancellationToken();
+ var result = lyricsScraperClient.SearchLyric(searchRequest, cancellationToken);
+
+ return result;
+ }
}
+}
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
-}