MusixmatchClientLib 1.0.0
See the version list below for details.
dotnet add package MusixmatchClientLib --version 1.0.0
NuGet\Install-Package MusixmatchClientLib -Version 1.0.0
<PackageReference Include="MusixmatchClientLib" Version="1.0.0" />
paket add MusixmatchClientLib --version 1.0.0
#r "nuget: MusixmatchClientLib, 1.0.0"
// Install MusixmatchClientLib as a Cake Addin #addin nuget:?package=MusixmatchClientLib&version=1.0.0 // Install MusixmatchClientLib as a Cake Tool #tool nuget:?package=MusixmatchClientLib&version=1.0.0
Usage
Using the library is quite simple. A complete list of samples is under development, until it's ready I'll leave some usage examples:
Tokens
MusixmatchToken
class represents the Musixmatch client token, that is used in all the client requests.
It can be requested from Musixmatch:
MusixmatchToken token = new MusixmatchToken();
Or it can be extracted from Musixmatch desktop application and used in the library:
MusixmatchToken token = new MusixmatchToken("MyToken");
A token could be created with a different API context, such as Musixmatch Community or Musixmatch iOS (more coming soon):
MusixmatchToken token = new MusixmatchToken("MyToken", API.Contexts.ApiContext.iOS);
Currently, you cannot create a token with a context other than Desktop
.
Also, a token requested from Musixmatch has limited capabilities (let's call it guest token) until you log in through the browser:
MusixmatchToken token = new MusixmatchToken();
Process.Start(token.GetAuthUrl()); // Open a browser with auth link
Client class
To create a MusixmatchClient
class you have to pass a MusixmatchToken
to its constructor:
MusixmatchToken token = new MusixmatchToken("MyToken");
MusixmatchClient client = new MusixmatchClient(token);
You may also create a client without creating a token:
MusixmatchClient client = new MusixmatchClient("MyToken", API.Contexts.ApiContext.iOS);
Other examples
Song search:
// Search by query
List<Track> tracks = client.SongSearch("Hommarju - Universe");
// Search by artist and track name
List<Track> tracks = client.SongSearch("Kobaryo", "Speed Complexxx");
// Search by the lyrics part
List<Track> tracks = client.SongSearchByLyrics("Watchin' you every night, to cast a small spell of fright");
// It is also possible to separate lines with '\n'
List<Track> tracks = client.SongSearchByLyrics("Just like you never ruined my heart\nLike you never said the words");
// Advanced search by parameters
List<Track> tracks = client.SongSearch(new TrackSearchParameters
{
Album = "Heartache Debug", // Album name
Artist = "t+pazolite", // Artist name
Title = "Messed Up Gravity", // Track name
LyricsQuery = "", // Search by the given part of lyrics
Query = "t+pazolite - Messed Up Gravity", // Search query, covers all the search parameters above
HasLyrics = false, // Only search for tracks with lyrics
HasSubtitles = false, // Only search for tracks with synced lyrics
Language = "", // Only search for tracks with lyrics in specified language
Sort = TrackSearchParameters.SortStrategy.TrackRatingDesc // List sorting strategy
});
Get song lyrics:
// Search for the track and get lyrics
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
Lyrics lyrics = client.GetTrackLyrics(trackId);
string lyricsBody = lyrics.Instrumental != 1 ? lyrics.LyricsBody : "This track is instrumental"; // lyrics.LyricsBody is null when the track is instrumental
Submit song lyrics:
// Submit track lyrics by id
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
client.SubmitTrackLyrics(trackId, "You make me feel alright\nYou make me feel alive...");
Get track by id:
// Get track by its Musixmatch id
Track track = client.GetTrackById(206481521);
string trackName = track.TrackName;
Get track snippet:
// Get track snippet (short line of lyrics to define the song)
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
string snippet = client.GetTrackSnippet(trackId);
Submit synced song lyrics:
// Submit track lyrics with time sync
Subtitles subtitles = new Subtitles();
subtitles.Lines.Add(new LyricsLine
{
Text = "You make me feel alive",
LyricsTime = TimeSpan.FromMilliseconds(1448)
});
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
client.SubmitTrackSubtitles(trackId, subtitles);
Get synced song lyrics:
// Search for the track and get synced lyrics
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
Subtitles subtitles = client.GetTrackSubtitles(trackId); // Throws ResourceNotFound if the track has no subtitles, check that first
List<LyricsLine> lines = subtitles.Lines;
string lineContent = lines.First().Text; // Line content
TimeSpan lineTime = lines.First().LyricsTime; // Line time (from the beginning of the song)
Submit raw synced song lyrics:
// Submit track lyrics with time sync (in Musixmatch format)
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
client.SubmitTrackSubtitlesRaw(trackId, "[{\"text\":\"You make me feel alive\",\"time\":{\"total\":17.33,\"minutes\":0,\"seconds\":17,\"hundredths\":33}}]");
Get raw synced song lyrics:
// Get raw track lyrics with time sync
int trackId = client.SongSearch("REDALiCE - Alive").First().TrackId;
string mxm = client.GetTrackSubtitlesRaw(trackId, MusixmatchClient.SubtitleFormat.Musixmatch);
Submit track mood:
int trackId = client.SongSearch("Camellia - AREA 52").First().TrackId;
client.SubmitTrackMood(trackId, 100 /* energy */, 69 /* mood */);
Get lyrics translation:
int trackId = client.SongSearch("Camellia - Nasty * Nasty * Spell").First().TrackId;
string translated = client.GetLyricsTranslation(trackId, "ru");
Get top weekly contributors:
List<User> coolGuysFromBelarus = client.GetUserWeeklyTop("BY");
List<User> theCoolestGuys = client.GetUserWeeklyTop();
Get spotify token (LOL):
string spotifyToken = client.GetSpotifyOauthToken().OauthRefreshtokenReply.AccessToken;
string refreshToken = client.GetSpotifyOauthToken().OauthRefreshtokenReply.RefreshToken;
string scope = client.GetSpotifyOauthToken().OauthRefreshtokenReply.Scope;
Get your statistics:
User you = client.GetUserScore();
int score = you.Score; // Cannot implicitly convert type 'long' to 'int' (joke, it works)
Your data:
var user = client.GetUserInfo();
string yourAge = user.UserData.Profile.AgeRange; // Not for everyone
Profile data update:
client.UpdateUserProfileCountry("BY"); // Set country by ISO code
client.UpdateUserProfileFavouriteArtists(new List<int>() { client.ArtistSearch("Camellia").First().ArtistId }); // Set favourite artists
client.UpdateUserProfileFavouriteGenres(new List<int>() { client.GetMusicGenres().Where(genre => genre.MusicGenreName.ToLower() == "hardcore").First().MusicGenreId }); // Set favourite genres
Exception handling
Currently this library supports only MusixmatchRequestException
. It has a StatusCode
property to understand the problem better.
By default, MusixmatchClient
would throw these if it runs into a problem during request. To ignore some problems, you could set AssertOnRequestException
parameter to false
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Data.DataSetExtensions (>= 4.5.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MusixmatchClientLib:
Package | Downloads |
---|---|
LyricsScraperNET
A library that provides an API for searching song lyrics from the web written in C# for .NET. For more infos, visit https://github.com/skuill/LyricsScraperNET |
GitHub repositories
This package is not used by any popular GitHub repositories.