Python script to fetch metadata from


So, I got a bit annoyed with the semi-random nature of the release dates on most tracks from Beatsource. They were pretty much all from 2016->2022, even though a lot of my library is 80s onwards.

Basically, it’s a python script, which will:

  • Connect to the Lexicon API (be sure to enable it)
  • Fetch a track list from Lexicon (max 1000 tracks at a time due to an API limit
  • Connect to to get the release year from either the track itself, or its corresponding album (sometimes the track itself doesn’t have a date)
  • For added fun, it also fetches a list of “samples” and “sampled in” and adds to the extra1 field

It will try to sanity-check the best it can (compare artist and track-names to Genius before updating anything, to try and ensure that its not falling victim to some search-guess-optimization).
It will also log any updates it does to the file updates.txt in the same directory.

So - prereqs:
The pypi packages of: lyricsgenius, requests, json, sys, re

pip install lyricsgenius requests

A genius API token (you can read a bit about it here Setup — lyricsgenius documentation)

And, in the top of the file, you add your token in the “token” varibale, and adjust how many tracks it should fetch from Lexicon:

# Insert your genius token here:
token = ""
# limit and offset passed to lexicon
fetchlimit = 50  
fetchoffset = 50

DO make a backup first, and try it out in a safe manner.
This WILL update your library - and it might go wrong, so test a bit and be sure you know what you’re doing, before you destroy it all :slight_smile: (10.0 KB)