Skip to content

Instantly share code, notes, and snippets.

@ikwyl6
Created November 20, 2020 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikwyl6/63289cdfb9ebcda4c04f9afd0f7f4086 to your computer and use it in GitHub Desktop.
Save ikwyl6/63289cdfb9ebcda4c04f9afd0f7f4086 to your computer and use it in GitHub Desktop.
python discogs script that gives a link to an album cover
#!/usr/bin/python
# https://gist.github.com/ikwyl6
# discogs script to get the url of the discogs for a album
import discogs_client
import argparse
"""
discogs_client objects:
https://github.com/discogs/discogs_client/blob/master/discogs_client/models.py#L691
"""
query = {} # dictionary for search terms passed to discogs object
parser = argparse.ArgumentParser(prog='discogs_albums',
description='Find url link for an album')
parser.add_argument('search', nargs='*', help='Search terms to look for an album')
parser.add_argument('-a', '--artist', nargs=1, help='Search for artist')
args = parser.parse_args()
# Default is to have type = master
query.update({'type':'master'})
if (args.artist):
query.update({'artist':args.artist})
if (args.search):
search_terms = " ".join(args.search)
query.update({'release_title':search_terms})
d = discogs_client.Client('ExampleApplication/0.1', user_token="YOUR_TOKEN_HERE")
list = d.search(**query)
for i in list:
print (i.main_release.thumb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment