Giter VIP home page Giter VIP logo

discogsclient's Introduction

DiscogsClient

Build status NuGet Badge MIT License

C# Client library for Discogs API v2.0

Check demo application Music.Cover.Finder

Features

  • Include API to authorize user (generating OAuth1.0 token and token secret)
  • Full support to DataBase API including image download
  • Support of identity API
  • Transparent support of rate limit
  • Asynchroneous and cancellable API using Tasks
  • Transparent management of pagination using none blocking API (Reactive IObservable) or IEnumerable

Sample usage

Create discogs client

Oauth authentication

  //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);

Token based authentication

  //Create authentication based on Discogs token
  var tokenInformation = new TokenAuthenticationInformation("my-token");
  //Create discogs client using the authentication
  var discogsClient = new DiscogsClient(tokenInformation);

Search The DataBase

Using 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);

Using IEnumerable:

//Alternatively retreive same result as enumerable 
var enumerable = _DiscogsClient.SearchAsEnumerable(discogsSearch);

Get Release, Master, Artist or Label Information

var release = await _DiscogsClient.GetReleaseAsync(1704673);
var master = await _DiscogsClient.GetMasterAsync(47813);
var artist = await _DiscogsClient.GetArtistAsync(224506);
var label = await _DiscogsClient.GetLabelAsync(125);

Download Image

//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");

OAuth: Authorize new user

//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 takes a Func< string, Task< string>> as parameter, receiving the authentication url and returning the corresponding access key. Trivial implementation:

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();
}

See DiscogsClientTest and DiscogsAuthenticationConsole for full samples of available APIs.

discogsclient's People

Contributors

blackboxlogic avatar david-desmaisons avatar steven-r avatar syndicateofswing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discogsclient's Issues

New info extracted from your library

Hi, I wanted to ask if you were willing to integrate some information that I found in the DiscoGS DB and that are not currently extracted from your library.

For now I can not give you a precise list (in testing my applications sometimes I find something) but for now I could give you two / three that I found.

Thanks in advance,
   Traponto

Support Marketplace endpoint

It looks like your project doesn't support calls to the Discogs marketplace endpoint (I'm specifically looking for /marketplace/price_suggestions/{release_id})

  • Am I wrong, and it's here, and I just couldn't find it?
  • Do you have plans to add it?
  • Hypothetically, if I had time, would you consider a PR to add it?

Update RestSharp dependency

Because RestSharp has some breaking changes in newer versions this library currently only works if you use version 106.

If you have a higher version of RestSharp in your solution installed the package will return errors.

There are two possible solutions to fix this issue:

  • Change package so it always uses the 106 version.
  • Update RestSharp to a newer version and fix the code for the new changes

If you update the package a different dependency (from the same author) also has to be updated since it has the same issue: https://github.com/David-Desmaisons/RestSharpHelper

Missing ForEachAsync

I must be missing something as I am unable to build with DiscogsClient. I am receiving a compilation error related to ForEachAsync.

        var observable = _DiscogsClient.Search(discogsSearch);
        return observable.ForEachAsync(OnResult);

Exact error is below:
'IObservable' does not contain a definition for 'ForEachAsync' and no accessible extension method 'ForEachAsync' accepting a first argument of type 'IObservable' could be found (are you missing a using directive or an assembly reference?)

Latest version (2.3.0) is installed. Any idea what I might be missing? Any suggestions?

Add Images

Hi,

Can u add images? Like cover_image?

at var observable = await discogsClient.SearchAsync(discogsSearch);

Error Code

I ran the project, put in my token, and get this error: C:\Program Files\dotnet\dotnet.exe (process 18648) exited with code 0.

Subtrack in tracklist

Is there a way to get subtracks of an 'Index' track?
For example: in Pink Floyd Atom Heart Mother I have the track 'Atom Heart Mother' ('Index' track) with subtracks 1.a / 1.f

Sample.zip

How to get artist master id using this API?

Is it possible to get a master id of an album using this API; I would like to know because I'd like to search the cover art according to an artist the user enters and I couldn't find a documentation or something to solve my issue.

Requesting OAuth Token and TokenSecret

Hey there :-)

I am a WPF VB.NET Framework 4.8 programmer and I have some trouble requesting Token and TokenSecret with OAuth programmatically. This is my code (I used an online converter to translate this from C#):

Dim OAuthConsumerInformation = New OAuthConsumerInformation("MyConsumerKey", "MyConsumerSecret")
Dim discogsClient = New DiscogsAuthentifierClient(OAuthConsumerInformation)
Dim aouth = discogsClient.Authorize(Function(s) Task.FromResult(GetToken(s))).Result
Dim successString As String = ""
If aouth IsNot Nothing Then successString = "successful." Else successString = "not sucessful."

However, the problem occurs in line 3: My app submits the request, at least my virus scanner shows a message, that my app is trying to connect. But when I hit the button to grant the connection, nothing happens, I could just wait forever...

When I use the provided demo code in C#, everything works fine:

namespace DiscogsAuthenticationConsole
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var oAuthConsumerInformation = new OAuthConsumerInformation("MeinConsumerKey", "MeinConsumerSecret");
            var discogsClient = new DiscogsAuthentifierClient(oAuthConsumerInformation);
            var aouth = discogsClient.Authorize(s => Task.FromResult(GetToken(s))).Result;
            Console.WriteLine($"{((aouth != null) ? "Success" : "Fail")}");
            Console.WriteLine($"Token:{aouth?.TokenInformation?.Token}, TokenSecret:{aouth?.TokenInformation?.TokenSecret}");
            Console.ReadLine();
        }
        private static string GetToken(string url)
        {
            Console.WriteLine("Please authourize the application and enter the final key in the console");
            Process.Start(url);
            string tokenKey = Console.ReadLine();
            tokenKey = string.IsNullOrEmpty(tokenKey) ? null : tokenKey;
            return tokenKey;
        }
    }
}

Maybe it's just a translation issue? I can't really figure it out as I am not that familiar with C#...

Authorize Requests - QueryString / Token Route

Hi,
I want to use this package to do some server-side API calls on my site. I don't want to authorise users on my site. I'm just having trouble filling in one seeming gap in the docs.

I have my Discogs App Consumer Key and Secret.
I will be searching for an artist then retrieving the artist info.

I can see from your documentation that the option I might want to take is the Token Auth route...e.g.

var tokenInformation = new TokenAuthenticationInformation("my-token");
var discogsClient = new DiscogsClient.DiscogsClient(tokenInformation);

What i'm wondering is how I get my-token with only my consumer key and secret?

Alternative:
I can see on the discogs dev site that they also offer a QueryString method of authorising requests:

curl "https://api.discogs.com/database/search?q=Nirvana&key=foo123&secret=bar456"
(see: https://www.discogs.com/developers#page:authentication,header:authentication-discogs-auth-flow)

Am I right in thinking this isn't an option with this package?

Thanks for any help you can give.

Artist for each track in tracklist

This package is working perfectly.
But some releases are compilations and each track has a different artist.
It would be nice to add an artist property in the "DiscogsTrack" class.

Thank you.

Program.cs it doesn't go over

Hi,
Your script:

            var oAuthConsumerInformation = new OAuthConsumerInformation("aaa", "bbb");
            var discogsClient = new DiscogsAuthentifierClient(oAuthConsumerInformation);

            var aouth = discogsClient.Authorize(s => Task.FromResult(GetToken(s))).Result;

            Console.WriteLine($"{((aouth != null)? "Success": "Fail")}");
            Console.WriteLine($"Token:{aouth?.TokenInformation?.Token}, Token:{aouth?.TokenInformation?.TokenSecret}");

Print Fail and exit. I am sure that user key and secret key is correct.

Why this script not respond success?
How i can execute some request in discogs DB?

Thank you so much.

GetAllLabelReleases does not return all the releases from a Label

Fetching releases from a label that contains a huge amount of them seems we hit the rate limit.

Here 2 labels to test with:
Label Id=1967
Label Id=10663

And perhaps this can help a bit too:

DiscogsClient.GenerateFromPaginable

var res = await _Client.Execute(request, cancel);
var elements = res?.GetResults();
if (elements == null)
return; //If we hit the limit, response is empty but all pages have not being retrieved.

Authorize new user

I'm having trouble activating the authorize procedure inside my WinForm application, it seems that the 'GetToken' function is not invoked and the program goes in loop in the 'Authorize' procedure. I took the same instructions in the sample application 'DiscogsAuthenticationConsole' where instead everything is fine.

How to authorize?

All I want to do is search using the database api.
I don't want to authorize users or anything the like.
I got an consumer key and a consumer secret but all examples I find require an user to click "Authorize".
I just want to do a quit authorization with my own key and search the database.
How?

Empty image url

noimage

The client search is good for all other fields but I get empty urls on images? This release id was tested as well as your existing releaseId.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.