Skip to content

Instantly share code, notes, and snippets.

@andybest
Created September 4, 2022 17:16
Show Gist options
  • Save andybest/445477a150ecb149c786991abd4263c8 to your computer and use it in GitHub Desktop.
Save andybest/445477a150ecb149c786991abd4263c8 to your computer and use it in GitHub Desktop.
Export Rekordbox cue sheets to a human readable form
#!/usr/bin/env python3
import argparse
import re
import sys
def read_cues(input_path, output_path):
if output_path is not None:
sys.stdout = open(output_path, 'w')
with open(input_path, 'r') as f:
found_tracks = False
for line in f.readlines():
line = line.strip()
if line.startswith('TRACK'):
found_tracks = True
if not found_tracks:
continue
if line.startswith('TITLE'):
title = re.match(r'.*\"(.*)\"', line)[1]
elif line.startswith('PERFORMER'):
performer = re.match(r'.*\"(.*)\"', line)[1]
elif line.startswith('INDEX'):
time = re.match(r'.*(\d\d:\d\d:\d\d)', line)[1]
print(f'{time} {title} - {performer}')
if output_path is not None:
sys.stdout.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Convert a CUE sheet to a human readable list')
parser.add_argument('input', type=str, help='The CUE sheet to convert')
parser.add_argument('--output', type=str, help='The name of the file to output to. (If ommitted, the list will be sent to STDOUT)')
args = parser.parse_args()
read_cues(args.input, args.output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment