DiscogsClient
v2.7.1
ไลบรารีไคลเอ็นต์ C# สำหรับ Discogs API v2.0
ตรวจสอบแอปพลิเคชั่นสาธิต 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 ( ) ;
}
ดู DiscogsClientTest และ DiscogsAuthenticationConsole สำหรับตัวอย่าง API ที่มีอยู่ทั้งหมด