Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get images of Discogs releases?

I want to get images of Discogs releases. Can I do it without Discogs API? They don't have links to the images in their db dumps.

like image 515
user5869792 Avatar asked Feb 01 '16 21:02

user5869792


People also ask

Does Discogs have an API?

The Discogs API v2. 0 is a RESTful interface to Discogs data. You can access JSON-formatted information about Database objects such as Artists, Releases, and Labels. Your application can also manage User Collections and Wantlists, create Marketplace Listings, and more.

How do I add photos to Discogs?

Navigate to your account settings. Under Profile settings, use the Upload Photo button to upload your own image to your profile. Use an avatar that is at least 150px wide and less than 1MB. Click "Save Settings" to save the changes.

Can you send photos through Discogs?

You cannot send attachments via Discogs... Just ask the enquirer to send you their email address so that you can email them over. Most people who contact me for images supply their email address on the initial message, but others occasionally need a nudge.


1 Answers

To do this without the API, you would have to load a web page and extract the image from the html source code. You can find the relevant page by loading https://www.discogs.com/release/xxxx where xxxx is the release number. Since html is just a text file, you can now extract the jpeg URL.

I don't know what your programming language is, but I'm sure it can handle String functions, like indexOf and subString. You could extract the html's OG:Image content for picture.

So taking an example: https://www.discogs.com/release/8140515

  • Find the .indexOf("og:image\" content=\"); save as startPos to some integer.
  • That's 19 chars so next do a .indexOf(".jpg", startPos + 19); into a endPos.
    This gets the first occurence of .jpg after index of startPos + 19 any other chars.
  • Now extract a subString from html text img_URL = myHtmlStr.substring(startPos+19, endPos);

  • You should end up with a string reading like this below (extracted URL):
    https://img.discogs.com/_zHBK73yJ5oON197YTDXM7JoBjA=/fit-in/600x600/filters:strip_icc():format(jpeg):mode_rgb():quality(90)/discogs-images/R-8140515-1460073064-5890.jpeg.jpg

  • The process can be shortened to finding the startPos index of https://img., then find first occurrence of .jpg when searching from after that startPos index. Extract within that length range. This is because the image URL is only mentioned in the html source at https://img.

Compare page at : https://www.discogs.com/release/8140515 with extracted URL image below.

like image 92
VC.One Avatar answered Nov 15 '22 08:11

VC.One