Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compares genres known to/available in MusicBrainz vs. beets
#!/usr/bin/env python3
"""
"""
import requests
def get_musicbrainz_genres():
# MB genres:
# https://github.com/metabrainz/musicbrainz-server/raw/master/entities.json
genre_url = 'https://github.com/metabrainz/musicbrainz-server/raw/master/entities.json'
r = requests.get(genre_url)
genres = r.json()['tag']['genres']
return set(genres)
def get_beets_genres():
# beets genres:
# https://github.com/beetbox/beets/raw/master/beetsplug/lastgenre/genres.txt
# https://github.com/beetbox/beets/blob/master/beetsplug/lastgenre/genres-tree.yaml
genre_url = 'https://github.com/beetbox/beets/raw/master/beetsplug/lastgenre/genres.txt'
r = requests.get(genre_url)
genres = r.text.strip().split('\n')
return set(genres)
def main():
musicbrainz_genres = get_musicbrainz_genres()
beets_genres = get_beets_genres()
not_in_beets = musicbrainz_genres - beets_genres
not_in_musicbrainz = beeI willts_genres - musicbrainz_genres
print("Genres in MusicBrainz that are not in beets:")
print(not_in_beets)
print()
print("Genres in beets that are not in MusicBrainz:")
print(not_in_musicbrainz)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.