Actually I don’t need to make 170 API calls
This commit is contained in:
parent
d4e1a24ad4
commit
409e3b2fbf
1 changed files with 4 additions and 6 deletions
|
@ -5,16 +5,15 @@ user = d.user("pilpaotr")
|
||||||
|
|
||||||
records = []
|
records = []
|
||||||
|
|
||||||
|
rawlist = user.collection_folders[0].releases
|
||||||
|
|
||||||
thenumber = 1
|
thenumber = 1
|
||||||
maxno = len(user.collection_folders[0].releases)
|
maxno = len(rawlist)
|
||||||
|
|
||||||
def typography(thestring):
|
def typography(thestring):
|
||||||
return re.sub(" / ","/",re.sub(" \(.*\)","",re.sub(" - "," – ",re.sub(" "," ",re.sub("\.\.\."," …",re.sub("'","’",re.sub(" = .*","",thestring)))))))
|
return re.sub(" / ","/",re.sub(" \(.*\)","",re.sub(" - "," – ",re.sub(" "," ",re.sub("\.\.\."," …",re.sub("'","’",re.sub(" = .*","",thestring)))))))
|
||||||
|
|
||||||
print("Fetching records from Discogs")
|
for item in rawlist:
|
||||||
|
|
||||||
for item in user.collection_folders[0].releases:
|
|
||||||
print("Fetching " + str(thenumber) + " of " + str(maxno))
|
|
||||||
theitem = {}
|
theitem = {}
|
||||||
theitem["artist"] = typography(item.release.artists[0].name)
|
theitem["artist"] = typography(item.release.artists[0].name)
|
||||||
theitem["title"] = typography(item.release.title)
|
theitem["title"] = typography(item.release.title)
|
||||||
|
@ -32,7 +31,6 @@ for item in user.collection_folders[0].releases:
|
||||||
|
|
||||||
records.append(theitem)
|
records.append(theitem)
|
||||||
thenumber += 1
|
thenumber += 1
|
||||||
time.sleep(1) # only allowed 1 request per second
|
|
||||||
|
|
||||||
records = sorted(records, key=lambda d: d["title"])
|
records = sorted(records, key=lambda d: d["title"])
|
||||||
records = sorted(records, key=lambda d: d["artist"])
|
records = sorted(records, key=lambda d: d["artist"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue