mirror of
https://github.com/simon987/music-graph-scripts.git
synced 2025-04-04 06:52:58 +00:00
Add spotify album name
This commit is contained in:
parent
7f901cdd9d
commit
63df9f30d2
@ -5,7 +5,7 @@ config = {
|
||||
"USER": "musicbrainz",
|
||||
"PASSWORD": "musicbrainz",
|
||||
"HOST": "127.0.0.1",
|
||||
"PORT": 5433,
|
||||
"PORT": 5432,
|
||||
|
||||
"LASTFM_APIKEY": os.environ.get("LASTFM_APIKEY"),
|
||||
"LASTFM_USER": os.environ.get("LASTFM_USER"),
|
||||
|
@ -131,8 +131,8 @@ SELECT gid as "id:ID(Artist)",
|
||||
fn_sortname(artist.name, sort_name) as sortname,
|
||||
COALESCE(begin_date_year, 0) as "year:int",
|
||||
comment,
|
||||
COALESCE(lfm.listeners, 0) as "listeners",
|
||||
COALESCE(lfm.playcount, 0) as "playcount",
|
||||
COALESCE(lfm.listeners, 0) as "listeners:int",
|
||||
COALESCE(lfm.playcount, 0) as "playcount:int",
|
||||
(CASE WHEN type = 2 THEN 'Group' ELSE 'Artist' END) as ":LABEL"
|
||||
FROM artist
|
||||
LEFT JOIN mg.lastfm_artist lfa ON lfa.mbid = artist.gid
|
||||
@ -417,6 +417,7 @@ CREATE TABLE mg.spotify_artist_track
|
||||
(
|
||||
spotid TEXT,
|
||||
track TEXT,
|
||||
album TEXT,
|
||||
url TEXT,
|
||||
PRIMARY KEY (spotid, track)
|
||||
);
|
||||
|
@ -79,13 +79,13 @@ def get_tracks(conn, spotify, spotid):
|
||||
for track in data["tracks"]:
|
||||
if track["name"] in done:
|
||||
continue
|
||||
unique_tracks.append((track["name"], track["preview_url"]))
|
||||
unique_tracks.append((track["name"], track["album"]["name"], track["preview_url"]))
|
||||
done.add(track["name"])
|
||||
|
||||
if unique_tracks:
|
||||
cur.execute(
|
||||
"INSERT INTO mg.spotify_artist_track (spotid, track, url) VALUES %s" %
|
||||
",".join("('%s', '%s', '%s')" % (i, t[0].replace("'", "''"), t[1])
|
||||
"INSERT INTO mg.spotify_artist_track (spotid, track, album, url) VALUES %s" %
|
||||
",".join("('%s', '%s', '%s', '%s')" % (i, t[0].replace("'", "''"), t[1].replace("'", "''"), t[2])
|
||||
for (i, t) in zip(repeat(spotid), unique_tracks))
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user