Created
December 16, 2022 11:05
-
-
Save aricooperdavis/6ac17583c5f3e44e6b0b069aae25a3ae to your computer and use it in GitHub Desktop.
Parse Chordify.net loadUrl to text
This file contains 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
import requests | |
loadUrl = 'https://chordify.net/api/v2/songs/youtube:JZtIF0wpi5g/chords?vocabulary=extended_inversions' | |
r = requests.get(loadUrl) | |
json = r.json() | |
chords = [chord.split(';') for chord in json['chords'].split('\n')] | |
i = 0 | |
while i<len(chords): | |
# Loop over chords in bar | |
for j in range(json['barLength']): | |
# Only process valid entries | |
if len(chords[i]) != 4: | |
i += 1 | |
break | |
# Wait until a new chord or print '_' | |
if int(chords[i][0]) == j+1: | |
if i>0 and chords[i-1][1] == chords[i][1]: | |
print('_', end=' ') | |
else: | |
print(chords[i][1], end=' ') | |
i += 1 | |
else: | |
print('_', end=' ') | |
# Print bar ends | |
print('|', end=' ') | |
# _ _ D:maj _ | _ D:min _ _ | _ _ _ _ | E:min7 _ _ _ | A:7 _ _ _ | D:min7 _ _ _ | _ _ _ _ | G:7 _ _ _ | _ _ _ _ | _ _ _ _ | _ _ _ _ | G:maj _ _ _ | N _ _ _ | D:min7 _ G:7 _ | C:maj _ A:min7 _ | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | D:maj _ _ _ | E:min7 _ A:7 _ | D:min7 _ G:7 _ | _ _ _ _ | C:maj _ _ A:min7 | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | _ _ _ _ | D:min7 _ G:7 _ | C:maj7 _ _ _ | D:min7 _ G:7 _ | C:maj _ A:min7 _ | D:min7 _ G:7 _ | C:maj _ _ _ | D:min7 _ G:7 _ | C:maj _ A:min7 _ | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | D:maj _ _ _ | E:min7 _ A:7 _ | D:min7 _ G:7 _ | _ _ _ _ | C:maj _ _ _ | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | _ _ _ _ | D:min7 _ G:7 _ | C:maj _ _ _ | D:min7 _ G:7 _ | C:maj _ A:min _ | D:min7 _ G:7 _ | C:maj _ _ _ | D:min7 _ G:7 _ | E:min7 _ A:7 _ | D:min7 _ _ _ | G:7 _ _ _ | _ _ _ _ | C:maj _ A:min7 _ | D:min7 _ G:7 _ | C:maj _ _ A:min | D:min7 _ G:7 _ | E:7 _ A:min7 _ | D:min7 _ G:7 _ | C:maj7 _ C:maj A:min7 | D:min7 _ G:7 _ | C:maj _ A:min _ | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | D:maj _ _ _ | E:min7 _ A:7 _ | D:min7 _ G:7 _ | _ _ _ _ | C:maj _ _ _ | D:min7 _ G:7 _ | C:maj _ _ _ | A:7 _ _ _ | _ _ _ _ | D:min7 _ G:7 _ | C:maj _ A:min _ | D:min7 _ G:7 _ | G:maj _ A:min7 _ | D:min7 _ D:7 _ | G:7 _ _ _ | C:maj _ _ _ | _ _ _ _ | _ _ _ _ | _ _ _ _ | _ _ _ _ | _ _ _ N | _ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment