-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from skuill/feature/bundle_14_15
Bundle #14 #15 Ability to search for a specific provider. Added status codes and response message in a search result.
- Loading branch information
Showing
20 changed files
with
544 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace LyricsScraperNET.Common | ||
{ | ||
internal static class Constants | ||
{ | ||
internal static class ResponseMessages | ||
{ | ||
internal static readonly string ExternalProvidersListIsEmpty = "Empty external providers list! Please set any external provider first"; | ||
|
||
internal static readonly string ExternalProvidersAreDisabled = "All external providers are disabled. Searching lyrics is disabled"; | ||
|
||
internal static readonly string NotFoundLyric = "Can't find lyric for the search request"; | ||
|
||
internal static readonly string ExternalProviderForRequestNotSpecified = "The provider specified in the request is disabled or has not been configured for the client"; | ||
|
||
internal static readonly string SearchRequestIsEmpty = "Search request is empty"; | ||
|
||
internal static readonly string ArtistAndSongSearchRequestFieldsAreEmpty = "The ArtistAndSongSearchRequest not valid and contains one or more empty fields"; | ||
|
||
internal static readonly string UriSearchRequestFieldsAreEmpty = "The UriSearchRequest not valid and contains one or more empty fields"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
LyricsScraperNET/Extensions/ExternalProviderTypeExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using LyricsScraperNET.Providers.Models; | ||
|
||
namespace LyricsScraperNET.Extensions | ||
{ | ||
internal static class ExternalProviderTypeExtensions | ||
{ | ||
public static bool IsNoneProviderType(this ExternalProviderType providerType) | ||
=> providerType == ExternalProviderType.None; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using LyricsScraperNET.Models.Requests; | ||
using LyricsScraperNET.Providers.Models; | ||
|
||
namespace LyricsScraperNET.Extensions | ||
{ | ||
internal static class SearchRequestExtensions | ||
{ | ||
public static ExternalProviderType GetProviderTypeFromRequest(this SearchRequest searchRequest) | ||
{ | ||
switch (searchRequest) | ||
{ | ||
case ArtistAndSongSearchRequest artistAndSongSearchRequest: | ||
return artistAndSongSearchRequest.Provider; | ||
case UriSearchRequest uriSearchRequest: | ||
return uriSearchRequest.Provider; | ||
default: | ||
return ExternalProviderType.None; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using LyricsScraperNET.Models.Responses; | ||
|
||
namespace LyricsScraperNET.Extensions | ||
{ | ||
internal static class SearchResultExtensions | ||
{ | ||
internal static SearchResult AddErrorMessage(this SearchResult searchResult, string responseMessage) | ||
{ | ||
searchResult.ResponseStatusCode = ResponseStatusCode.Error; | ||
return searchResult.AppendResponseMessage(responseMessage); | ||
} | ||
|
||
internal static SearchResult AddNoDataFoundMessage(this SearchResult searchResult, string responseMessage) | ||
{ | ||
searchResult.ResponseStatusCode = ResponseStatusCode.NoDataFound; | ||
return searchResult.AppendResponseMessage(responseMessage); | ||
} | ||
|
||
internal static SearchResult AddBadRequestMessage(this SearchResult searchResult, string responseMessage) | ||
{ | ||
searchResult.ResponseStatusCode = ResponseStatusCode.BadRequest; | ||
return searchResult.AppendResponseMessage(responseMessage); | ||
} | ||
|
||
internal static SearchResult AppendResponseMessage(this SearchResult searchResult, string responseMessage) | ||
{ | ||
searchResult.ResponseMessage = !string.IsNullOrWhiteSpace(searchResult.ResponseMessage) | ||
? string.Join("; ", new[] { searchResult.ResponseMessage, responseMessage }) | ||
: responseMessage; | ||
return searchResult; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 24 additions & 1 deletion
25
LyricsScraperNET/Models/Requests/ArtistAndSongSearchRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
namespace LyricsScraperNET.Models.Requests | ||
using LyricsScraperNET.Providers.Models; | ||
|
||
namespace LyricsScraperNET.Models.Requests | ||
{ | ||
/// <summary> | ||
/// Query model for searching lyrics by artist/band name and song/track title. | ||
/// </summary> | ||
public sealed class ArtistAndSongSearchRequest : SearchRequest | ||
{ | ||
/// <summary> | ||
/// Artist or band name. | ||
/// </summary> | ||
public string Artist { get; } | ||
|
||
/// <summary> | ||
/// Song or track title. | ||
/// </summary> | ||
public string Song { get; } | ||
|
||
/// <summary> | ||
/// The type of external provider for which lyrics will be searched. | ||
/// By default, it is set to <see cref="ExternalProviderType.None"/> - the search will be performed across all available client providers. | ||
/// </summary> | ||
public ExternalProviderType Provider { get; } = ExternalProviderType.None; | ||
|
||
public ArtistAndSongSearchRequest(string artist, string song) | ||
{ | ||
Artist = artist; | ||
Song = song; | ||
} | ||
|
||
public ArtistAndSongSearchRequest(string artist, string song, ExternalProviderType provider) | ||
: this(artist, song) | ||
{ | ||
Provider = provider; | ||
} | ||
} | ||
} |
Oops, something went wrong.