-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
7,661 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,102 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using IF.Lastfm.Core.Api.Commands.Album; | ||
using IF.Lastfm.Core.Api.Helpers; | ||
using IF.Lastfm.Core.Helpers; | ||
using IF.Lastfm.Core.Objects; | ||
|
||
namespace IF.Lastfm.Core.Api | ||
{ | ||
public class AlbumApi : ApiBase, IAlbumApi | ||
{ | ||
public AlbumApi(ILastAuth auth, HttpClient httpClient = null) | ||
: base(httpClient) | ||
{ | ||
Auth = auth; | ||
} | ||
|
||
public async Task<LastResponse<LastAlbum>> GetInfoAsync(string artistname, string albumname, bool autocorrect = false, string username = null) | ||
{ | ||
var command = new GetInfoCommand(Auth, albumname, artistname) | ||
{ | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient, | ||
UserName = username | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<LastResponse<LastAlbum>> GetInfoByMbidAsync(string albumMbid, bool autocorrect = false, string username = null) | ||
{ | ||
var command = new GetInfoCommand(Auth) | ||
{ | ||
AlbumMbid = albumMbid, | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
//public Task<PageResponse<BuyLink>> GetBuyLinksForAlbumAsync(string artist, string album, CountryCode country, bool autocorrect = false) | ||
//{ | ||
// throw new NotImplementedException(); | ||
//} | ||
|
||
public Task<PageResponse<LastTag>> GetTagsByUserAsync(string artist, string album, string username, bool autocorrect = false) | ||
{ | ||
var command = new GetTagsByUserCommand(Auth, artist, album, username) | ||
{ | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastTag>> GetTopTagsAsync(string artist, string album, bool autocorrect = false) | ||
{ | ||
var command = new GetTopTagsCommand(Auth) | ||
{ | ||
ArtistName = artist, | ||
AlbumName = album, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastAlbum>> SearchAsync(string albumname, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new SearchCommand(Auth, albumname) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastShout>> GetShoutsAsync(string albumname, string artistname, bool autocorrect = false, int page = 1, int count = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetShoutsCommand(Auth, albumname, artistname) | ||
{ | ||
Page = page, | ||
Autocorrect = autocorrect, | ||
Count = count, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
//public async Task<LastResponse> AddShoutAsync(string albumname, string artistname, string message) | ||
//{ | ||
// var command = new AddShoutCommand(Auth, albumname, artistname, message); | ||
|
||
// return await command.ExecuteAsync(); | ||
//} | ||
} | ||
} |
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,177 @@ | ||
using System.Net.Http; | ||
using IF.Lastfm.Core.Api.Helpers; | ||
using IF.Lastfm.Core.Objects; | ||
using System.Threading.Tasks; | ||
using IF.Lastfm.Core.Api.Commands.Artist; | ||
using IF.Lastfm.Core.Helpers; | ||
|
||
namespace IF.Lastfm.Core.Api | ||
{ | ||
public class ArtistApi : ApiBase, IArtistApi | ||
{ | ||
public ArtistApi(ILastAuth auth, HttpClient httpClient = null) | ||
: base(httpClient) | ||
{ | ||
Auth = auth; | ||
} | ||
|
||
|
||
|
||
public async Task<LastResponse<LastArtist>> GetInfoAsync(string artist, string bioLang = LastFm.DefaultLanguageCode, bool autocorrect = false) | ||
{ | ||
var command = new GetInfoCommand(Auth) | ||
{ | ||
ArtistName = artist, | ||
BioLanguage = bioLang, | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<LastResponse<LastArtist>> GetInfoByMbidAsync(string mbid, string bioLang = LastFm.DefaultLanguageCode, bool autocorrect = false) | ||
{ | ||
var command = new GetInfoCommand(Auth) | ||
{ | ||
ArtistMbid = mbid, | ||
BioLanguage = bioLang, | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastAlbum>> GetTopAlbumsAsync(string artist, bool autocorrect = false, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopAlbumsCommand(Auth) | ||
{ | ||
ArtistName = artist, | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastAlbum>> GetTopAlbumsByMbidAsync(string mbid, bool autocorrect = false, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopAlbumsCommand(Auth) | ||
{ | ||
ArtistMbid = mbid, | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastTrack>> GetTopTracksAsync(string artist, bool autocorrect = false, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopTracksCommand(Auth, artist) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastArtist>> GetSimilarAsync(string artistname, bool autocorrect = false, int limit = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetSimilarCommand(Auth) | ||
{ | ||
ArtistName = artistname, | ||
Autocorrect = autocorrect, | ||
Limit = limit, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastArtist>> GetSimilarByMbidAsync(string mbid, bool autocorrect = false, int limit = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetSimilarCommand(Auth) | ||
{ | ||
ArtistMbid = mbid, | ||
Autocorrect = autocorrect, | ||
Limit = limit, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public Task<PageResponse<LastTag>> GetTagsByUserAsync(string artist, string username, bool autocorrect = false, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTagsByUserCommand(Auth, artist, username) | ||
{ | ||
Autocorrect = autocorrect, | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return command.ExecuteAsync(); | ||
} | ||
|
||
public Task<PageResponse<LastTag>> GetTopTagsAsync(string artist, bool autocorrect = false) | ||
{ | ||
var command = new GetTopTagsCommand(Auth) | ||
{ | ||
ArtistName = artist, | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return command.ExecuteAsync(); | ||
} | ||
|
||
public Task<PageResponse<LastTag>> GetTopTagsByMbidAsync(string mbid, bool autocorrect = false) | ||
{ | ||
var command = new GetTopTagsCommand(Auth) | ||
{ | ||
ArtistMbid = mbid, | ||
Autocorrect = autocorrect, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return command.ExecuteAsync(); | ||
} | ||
|
||
|
||
public async Task<PageResponse<LastShout>> GetShoutsAsync(string artist, int page = 0, int count = LastFm.DefaultPageLength, bool autocorrect = false) | ||
{ | ||
var command = new GetShoutsCommand(Auth, artist) | ||
{ | ||
Autocorrect = autocorrect, | ||
Page = page, | ||
Count = count, | ||
HttpClient = HttpClient | ||
}; | ||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<LastResponse> AddShoutAsync(string artistname, string message) | ||
{ | ||
var command = new AddShoutCommand(Auth, artistname, message) | ||
{ | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
|
||
public async Task<PageResponse<LastArtist>> SearchAsync(string artistname, int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new SearchCommand(Auth, artistname) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
|
||
return await command.ExecuteAsync(); | ||
} | ||
} | ||
} |
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,70 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using IF.Lastfm.Core.Api.Commands.Chart; | ||
using IF.Lastfm.Core.Api.Helpers; | ||
using IF.Lastfm.Core.Helpers; | ||
using IF.Lastfm.Core.Objects; | ||
|
||
namespace IF.Lastfm.Core.Api | ||
{ | ||
public class ChartApi : ApiBase, IChartApi | ||
{ | ||
|
||
public ChartApi(ILastAuth auth, HttpClient httpClient = null) | ||
: base(httpClient) | ||
{ | ||
Auth = auth; | ||
} | ||
|
||
/// <summary> | ||
/// Get a list of the most-scrobbled artists on Last.fm. | ||
/// </summary> | ||
/// <remarks> | ||
/// Bug 28/05/16 - itemsPerPage parameter doesn't seem to work all the time; certain values cause more or fewer items to be returned | ||
/// </remarks> | ||
public Task<PageResponse<LastArtist>> GetTopArtistsAsync(int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopArtistsCommand(Auth) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return command.ExecuteAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Get a list of the most-scrobbled tracks on Last.fm. | ||
/// </summary> | ||
/// <remarks> | ||
/// Bug 28/05/16 - itemsPerPage parameter doesn't seem to work all the time; certain values cause more or fewer items to be returned | ||
/// </remarks> | ||
public Task<PageResponse<LastTrack>> GetTopTracksAsync(int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopTracksCommand(Auth) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return command.ExecuteAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Get a list of the most frequently used tags by Last.fm users | ||
/// </summary> | ||
/// <remarks> | ||
/// Bug 28/05/16 - page and itemsPerPage parameters do not actually affect the number of or selection of tags returned | ||
/// </remarks> | ||
public Task<PageResponse<LastTag>> GetTopTagsAsync(int page = 1, int itemsPerPage = LastFm.DefaultPageLength) | ||
{ | ||
var command = new GetTopTagsCommand(Auth) | ||
{ | ||
Page = page, | ||
Count = itemsPerPage, | ||
HttpClient = HttpClient | ||
}; | ||
return command.ExecuteAsync(); | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using IF.Lastfm.Core.Api.Helpers; | ||
|
||
namespace IF.Lastfm.Core.Api.Commands.Album | ||
{ | ||
[ApiMethodName("album.shout")] | ||
internal class AddShoutCommand : PostAsyncCommandBase<LastResponse> | ||
{ | ||
public string Album { get; set; } | ||
|
||
public string Artist { get; set; } | ||
|
||
public string Message { get; set; } | ||
|
||
public AddShoutCommand(ILastAuth auth, string album, string artist, string message) | ||
: base(auth) | ||
{ | ||
Album = album; | ||
Artist = artist; | ||
Message = message; | ||
} | ||
|
||
public override void SetParameters() | ||
{ | ||
Parameters.Add("album", Album); | ||
Parameters.Add("artist", Artist); | ||
Parameters.Add("message", Message); | ||
} | ||
|
||
public override async Task<LastResponse> HandleResponse(HttpResponseMessage response) | ||
{ | ||
return await LastResponse.HandleResponse(response); | ||
} | ||
} | ||
} |
Oops, something went wrong.