DiscogsClient
v2.7.1
Biblioteca cliente C# para Discogs API v2.0
Verifique la aplicación de demostración 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 ) ;
Usando 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 ) ;
Usando 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 toma una Func<cadena, Task<cadena>> como parámetro, recibe la URL de autenticación y devuelve la clave de acceso correspondiente. Implementación trivial:
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 ( ) ;
}
Consulte DiscogsClientTest y DiscogsAuthenticationConsole para obtener ejemplos completos de las API disponibles.