Created
November 20, 2020 00:27
-
-
Save ikwyl6/63289cdfb9ebcda4c04f9afd0f7f4086 to your computer and use it in GitHub Desktop.
python discogs script that gives a link to an album cover
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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