mirror of
https://github.com/beetbox/beets.git
synced 2026-01-10 18:07:00 +01:00
acousticbrainz: Avoid re-parsing the JSON
This commit is contained in:
parent
18e5b30d19
commit
878161bb4f
1 changed files with 16 additions and 13 deletions
|
|
@ -59,22 +59,25 @@ def fetch_info(log, lib):
|
|||
|
||||
# Parse the JSON response.
|
||||
try:
|
||||
rs.json()
|
||||
data = rs.json()
|
||||
except ValueError:
|
||||
log.debug('Invalid Response: {}', rs.text)
|
||||
|
||||
item.danceable = get_value(log, rs.json(), ["highlevel",
|
||||
"danceability",
|
||||
"all",
|
||||
"danceable"])
|
||||
item.mood_happy = get_value(log, rs.json(), ["highlevel",
|
||||
"mood_happy",
|
||||
"all",
|
||||
"happy"])
|
||||
item.mood_party = get_value(log, rs.json(), ["highlevel",
|
||||
"mood_party",
|
||||
"all",
|
||||
"party"])
|
||||
item.danceable = get_value(
|
||||
log,
|
||||
data,
|
||||
["highlevel", "danceability", "all", "danceable"],
|
||||
)
|
||||
item.mood_happy = get_value(
|
||||
log,
|
||||
data,
|
||||
["highlevel", "mood_happy", "all", "happy"],
|
||||
)
|
||||
item.mood_party = get_value(
|
||||
log,
|
||||
data,
|
||||
["highlevel", "mood_party", "all", "party"],
|
||||
)
|
||||
|
||||
item.write()
|
||||
item.store()
|
||||
|
|
|
|||
Loading…
Reference in a new issue