You can use DiscogsNet to query the online API, parse the Discogs data dumps or import the XML dumps into MySQL.Any support for the project will help it improve faster and become more feature-complete.
Importing data into MySQL
Read more about
DatabaseManagerCli.
Querying the API
Querying the Discogs online API is as easy as creating a class instance and calling the appropriate method.
The new Discogs API needs the userAgent so to avoid the 403 error you need to set the useragent like this: "YourApp/1.0.3 +http://example.com" do not copy this user agent create your own so Discogs won't block it...
Discogs3 discogs = new Discogs3("YourApp/1.0.3 +http://example.com");
Release release = discogs.GetRelease(12345); // Pass the ID of the desired release
// You can get whatever data you need from release here
Available methods in the Discogs3 class (non-static) are
Discogs3.GetArtist(int artistId);
Discogs3.GetArtistReleases(int artistId);
Discogs3.GetRelease(int releaseId);
Discogs3.GetMaster(int masterId);
Discogs3.GetLabel(int labelId);
Discogs3.Search(SearchQuery query);
Authenticate via OAuth
OAuth documentation now on a new page https://discogsnet.codeplex.com/wikipage?title=OAuth%20System
Reading data from the database dumps
Discogs offers it's data as XML data dumps, gunzipped. In order to use them, first extract the archives to get three .xml files - one for labels, one for artists and one for releases. The library also supports reading directly from the gunzipped file using for example GZipLabelReader2 instead of LabelReader2, but it is slower then extracting and reading from the XML directly.
Reading labels
LabelReader2 reader = new LabelReader2("discogs_20110107_labels.xml"); // Make sure to supply the correct filename here.
foreach (Label label in reader.Enumerate()) {
// Process label
}
Reading artists
ArtistReader2 reader = new ArtistReader2("discogs_20110107_artists.xml"); // Make sure to supply the correct filename here.
foreach (Artist artist in reader.Enumerate()) {
// Process artist
}
Reading releases
ReleaseReader2 reader = new ReleaseReader2("discogs_20110107_releases.xml"); // Make sure to supply the correct filename here.
foreach (Release release in reader.Enumerate()) {
// Process release
}
Aggregate properties
Throughout the model, e.g. in the Release class, are properties called Aggregate. They expose instances to property aggregators, that is objects that work with the data model and expose frequently used and/or more convenient form of the data. For example, the aggregator of releases (ReleaseAggregate) contains properties to retrieve the release year as an int, directly get the primary image and many other. When processing data, you should probably use the properties in the model. When displaying, it's much easier and visually appealing to use the aggregate properties where applicable.
Having problems getting images?
Some users are getting the image with "I (heart) Discogs" well if changing your IP and your App id does nothing here is a fix
This fix has not been applied to the DiscogsNet because it violates the ToS of discogs and it can result in your ip getting banned!
- When requesting an image use the replace function of VB.net or C# to replace api.discogs.com with "s.pixogs.com"
For example:
Dim PicByte As Byte() = discogs.GetImage(artist.Images(0).Uri150.Replace("api.discogs.com", "s.pixogs.com"))
Remember this fix violates the ToS of discogs! DiscogsNet developpers do not take any responsability if your IP gets banned from Discogs