0

discogs_client is a module for working with the vinyl-trading platform discogs. In my code I am trying to retrieve the data for a particular release.

This is the code:

d = discogs_client.Client(
    "Vinyl-Helper",
    consumer_key=consumer_key,
    consumer_secret=consumer_secret,
    token=access_token['oauth_token'],
    secret=access_token['oauth_token_secret']
    )

releaseId = 12698907

release = d.release(releaseId)
records.append(
    Record(
        release.data['artists_sort'],
        release.data["title"],
        release.data["labels"][0]["catno"],
        "M",
        "M",
        UPLOADER_CODE,
        releaseId
    )
)

The code works in the shell, or if I put a breakpoint before, but not when I run it normally, or with a sleep(10) command before. The exception always spits out "KeyError: 'artists_sort'"

Max
  • 15
  • 6

1 Answers1

0

Solved.

The data is more easily fetched like this:

import urllib, json
releaseId = 12698907
url = f"https://api.discogs.com/releases/{releaseId}"
response = urllib.urlopen(url)
data = json.loads(response.read())
...
Max
  • 15
  • 6