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< 문자열, Task< 문자열>>을 매개변수로 사용하여 인증 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을 참조하세요.