Skip to content

Commit 1a05786

Browse files
2 parents b56cdd9 + 1a9642d commit 1a05786

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

README.md

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# DiscogsClient
22

33
[![Build status](https://img.shields.io/appveyor/ci/David-Desmaisons/DiscogsClient.svg?maxAge=2592000)](https://ci.appveyor.com/project/David-Desmaisons/DiscogsClient)
4-
[![NuGet Badge](https://buildstats.info/nuget/DiscogsClient)](https://www.nuget.org/packages/DiscogsClient/)
4+
[![NuGet Badge](https://img.shields.io/nuget/v/DiscogsClient.svg)](https://www.nuget.org/packages/DiscogsClient/)
55
[![MIT License](https://img.shields.io/github/license/David-Desmaisons/DiscogsClient.svg)](https://github.com/David-Desmaisons/DiscogsClient/blob/master/LICENSE)
66

77

88
C# Client library for [Discogs API v2.0](https://www.discogs.com/developers/)
99

10-
Nuget [here](https://www.nuget.org/packages/DiscogsClient/)
11-
1210
## Features
1311
* Include API to authorize user (generating OAuth1.0 token and token secret)
1412
* Full support to [DataBase API](https://www.discogs.com/developers/#page:database) including image download
@@ -19,81 +17,89 @@ Nuget [here](https://www.nuget.org/packages/DiscogsClient/)
1917

2018
## Sample usage
2119

22-
#### Create discogs client
20+
### Create discogs client
2321

22+
* Oauth authentication
2423
```C#
2524
//Create authentication object using private and public keys: you should fournish real keys here
2625
var oAuthCompleteInformation = new OAuthCompleteInformation("consumerKey",
2726
"consumerSecret", "token", "tokenSecret");
2827
//Create discogs client using the authentication
2928
var discogsClient = new DiscogsClient(oAuthCompleteInformation);
3029
```
30+
* Token based authentication
31+
```C#
32+
//Create authentication based on Discogs token
33+
var tokenInformation = new TokenAuthenticationInformation("my-token");
34+
//Create discogs client using the authentication
35+
var discogsClient = new DiscogsClient(tokenInformation);
36+
```
3137
#### Search The DataBase
3238

3339
Using IObservable:
3440
```C#
35-
var discogsSearch = new DiscogsSearch()
36-
{
37-
artist = "Ornette Coleman",
38-
release_title = "The Shape Of Jazz To Come"
39-
};
41+
var discogsSearch = new DiscogsSearch()
42+
{
43+
artist = "Ornette Coleman",
44+
release_title = "The Shape Of Jazz To Come"
45+
};
4046

41-
//Retrieve observable result from search
42-
var observable = _DiscogsClient.Search(discogsSearch);
47+
//Retrieve observable result from search
48+
var observable = _DiscogsClient.Search(discogsSearch);
4349
```
4450

4551
Using IEnumerable:
4652
```C#
47-
//Alternatively retreive same result as enumerable
48-
var enumerable = _DiscogsClient.SearchAsEnumerable(discogsSearch);
53+
//Alternatively retreive same result as enumerable
54+
var enumerable = _DiscogsClient.SearchAsEnumerable(discogsSearch);
4955
```
5056

5157
#### Get Release, Master, Artist or Label Information
5258
```C#
53-
var release = await _DiscogsClient.GetRelease(1704673);
59+
var release = await _DiscogsClient.GetReleaseAsync(1704673);
5460
```
5561

5662
```C#
57-
var master = await _DiscogsClient.GetMaster(47813);
63+
var master = await _DiscogsClient.GetMasterAsync(47813);
5864
```
5965

6066
```C#
61-
var artist = await _DiscogsClient.GetArtist(224506);
67+
var artist = await _DiscogsClient.GetArtistAsync(224506);
6268
```
6369

6470
```C#
65-
var label = await _DiscogsClient.GetLabel(125);
71+
var label = await _DiscogsClient.GetLabelAsync(125);
6672
```
6773

6874
#### Download Image
6975
```C#
70-
//Retrieve Release information
71-
var res = await _DiscogsClient.GetMaster(47813);
76+
//Retrieve Release information
77+
var res = await _DiscogsClient.GetMasterAsync(47813);
7278

73-
//Download the first image of the release
74-
await _DiscogsClient.SaveImage(res.images[0], Path.GetTempPath(), "Ornette-TSOAJTC");
79+
//Download the first image of the release
80+
await _DiscogsClient.SaveImageAsync(res.images[0], Path.GetTempPath(), "Ornette-TSOAJTC");
7581
```
7682

77-
#### Authorize new user
83+
#### OAuth: Authorize new user
7884
```C#
79-
//Create authentificator information: you should fournish real keys here
80-
var oAuthConsumerInformation = new OAuthConsumerInformation("consumerKey", "consumerSecret");
85+
//Create authentificator information: you should fournish real keys here
86+
var oAuthConsumerInformation = new OAuthConsumerInformation("consumerKey", "consumerSecret");
8187

82-
//Create Authentifier client
83-
var discogsAuthentifierClient = new DiscogsAuthentifierClient(oAuthConsumerInformation);
88+
//Create Authentifier client
89+
var discogsAuthentifierClient = new DiscogsAuthentifierClient(oAuthConsumerInformation);
8490

85-
//Retreive Token and Token secret
86-
var aouth = discogsClient.Authorize(s => Task.FromResult(GetToken(s))).Result;
91+
//Retreive Token and Token secret
92+
var oauth = discogsClient.Authorize(s => Task.FromResult(GetToken(s))).Result;
8793
```
8894

8995
Authorize takes a Func< string, Task< string>> as parameter, receiving the authentication url and returning the corresponding access key. Trivial implementation:
9096

9197
```C#
92-
private static string GetToken(string url)
93-
{
94-
Console.WriteLine("Please authorize the application and enter the final key in the console");
95-
Process.Start(url);
96-
return Console.ReadLine();
97-
}
98+
private static string GetToken(string url)
99+
{
100+
Console.WriteLine("Please authorize the application and enter the final key in the console");
101+
Process.Start(url);
102+
return Console.ReadLine();
103+
}
98104
```
99105
See [DiscogsClientTest](https://github.com/David-Desmaisons/DiscogsClient/blob/master/DiscogsClient.Test/DiscogsClientTest.cs) and [DiscogsAuthenticationConsole](https://github.com/David-Desmaisons/DiscogsClient/blob/master/DiscogsAuthenticationConsole/Program.cs) for full samples of available APIs.

0 commit comments

Comments
 (0)