Skip to content

Instantly share code, notes, and snippets.

@retrography
Last active August 2, 2019 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retrography/3a0de783a78a71777d35937ed324b6fb to your computer and use it in GitHub Desktop.
Save retrography/3a0de783a78a71777d35937ed324b6fb to your computer and use it in GitHub Desktop.
Create cue sheet for a list of id3-tagged audio files
#!/usr/bin/env python3
from sys import argv
from mediafile import MediaFile
def main():
args = argv[1:]
first_file = True
lines = []
for filename in args:
tags = MediaFile(filename)
cuefile = tags.albumartist + " - " + tags.album + ".cue"
if first_file:
lines.append('REM DATE ' + str(tags.year))
lines.append('REM GENRE ' + tags.genre)
lines.append('PERFORMER "' + tags.albumartist + '"')
lines.append('TITLE "' + tags.album + '"')
first_file = False
lines.append('FILE "' + filename + '" WAVE')
lines.append('\tTRACK ' + format(tags.track, '02') + " AUDIO")
lines.append('\t\tTITLE "' + tags.title + '"')
lines.append('\t\tPERFORMER "' + tags.artist + '"')
lines.append('\t\tINDEX 01 00:00:00')
cue = open(cuefile,"w+")
cue.write("\n".join(lines))
cue.close()
if __name__ == "__main__":
main()
@retrography
Copy link
Author

retrography commented Aug 2, 2019

Thanks, @klizas! I rewrote it using Mutagen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment