DiscogsClient
v2.7.1
Discogs API v2.0 用の C# クライアント ライブラリ
デモアプリケーション Music.Cover.Finder を確認する
//Create authentication object using private and public keys: you should fournish real keys here
var oAuthCompleteInformation = new OAuthCompleteInformation ( " consumerKey " ,
" consumerSecret " , " token " , " tokenSecret " ) ;
//Create discogs client using the authentication
var discogsClient = new DiscogsClient ( oAuthCompleteInformation ) ;
//Create authentication based on Discogs token
var tokenInformation = new TokenAuthenticationInformation ( " my-token " ) ;
//Create discogs client using the authentication
var discogsClient = new DiscogsClient ( tokenInformation ) ;
IObservable の使用:
var discogsSearch = new DiscogsSearch ( )
{
artist = " Ornette Coleman " ,
release_title = " The Shape Of Jazz To Come "
} ;
//Retrieve observable result from search
var observable = _DiscogsClient . Search ( discogsSearch ) ;
IEnumerable の使用:
//Alternatively retreive same result as enumerable
var enumerable = _DiscogsClient . SearchAsEnumerable ( discogsSearch ) ;
var release = await _DiscogsClient . GetReleaseAsync ( 1704673 ) ;
var master = await _DiscogsClient . GetMasterAsync ( 47813 ) ;
var artist = await _DiscogsClient . GetArtistAsync ( 224506 ) ;
var label = await _DiscogsClient . GetLabelAsync ( 125 ) ;
//Retrieve Release information
var res = await _DiscogsClient . GetMasterAsync ( 47813 ) ;
//Download the first image of the release
await _DiscogsClient . SaveImageAsync ( res . images [ 0 ] , Path . GetTempPath ( ) , " Ornette-TSOAJTC " ) ;
//Create authentificator information: you should fournish real keys here
var oAuthConsumerInformation = new OAuthConsumerInformation ( " consumerKey " , " consumerSecret " ) ;
//Create Authentifier client
var discogsAuthentifierClient = new DiscogsAuthentifierClient ( oAuthConsumerInformation ) ;
//Retreive Token and Token secret
var oauth = discogsClient . Authorize ( s => Task . FromResult ( GetToken ( s ) ) ) . Result ;
Authorize は Func< string, Task< string>> をパラメータとして受け取り、認証 URL を受け取り、対応するアクセス キーを返します。簡単な実装:
private static string GetToken ( string url )
{
Console . WriteLine ( " Please authorize the application and enter the final key in the console " ) ;
Process . Start ( url ) ;
return Console . ReadLine ( ) ;
}
利用可能な API の完全なサンプルについては、DiscogsClientTest および DiscogsAuthenticationConsole を参照してください。