/usr/share/doc/abcde/examples/cue2discid is in abcde 2.4.2-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #!/usr/bin/python
"""Outputs a long-form cddb discid given a cue file as input"""
import fileinput
import re
FRAMES_PER_SECOND = 75
SAMPLES_PER_SECOND = 44100
SAMPLES_PER_FRAME = SAMPLES_PER_SECOND // FRAMES_PER_SECOND
pregap = 0
currentTrackFrame = 0
pregapRegex = re.compile(r'PREGAP (?P<min>\d+):(?P<sec>\d\d):(?P<frame>\d\d)')
startTrackRegex = re.compile(r'INDEX 01 (?P<min>\d+):(?P<sec>\d\d):(?P<frame>\d\d)')
leadInRegex = re.compile(r'REM FLAC__lead-in (?P<sample>\d+)')
leadOutRegex = re.compile(r'REM FLAC__lead-out 170 (?P<sample>\d+)')
raw_framelist = list()
numTracks = 0
def cddb_sum(trackseconds):
def digits(number):
tmp = number
while tmp:
yield tmp % 10
tmp = tmp // 10
return sum(digits(trackseconds))
for line in fileinput.input():
pregapMatch = pregapRegex.search(line)
if pregapMatch:
pregap = (int((pregapMatch.group('min')) * 60) + int(pregapMatch.group('sec'))) * FRAMES_PER_SECOND + int(pregapMatch.group('frame'))
continue
startTrackMatch = startTrackRegex.search(line)
if startTrackMatch:
numTracks += 1
currentTrackFrame = ((int(startTrackMatch.group('min')) * 60) + int(startTrackMatch.group('sec'))) * FRAMES_PER_SECOND + int(startTrackMatch.group('frame'))
raw_framelist.append(currentTrackFrame)
continue
leadInMatch = leadInRegex.search(line)
if leadInMatch:
leadInFrame = long(leadInMatch.group('sample')) // SAMPLES_PER_FRAME
continue
leadOutMatch = leadOutRegex.search(line)
if leadOutMatch:
leadOutFrame_raw = long(leadOutMatch.group('sample')) // SAMPLES_PER_FRAME
continue
leadOutFrame = leadOutFrame_raw + leadInFrame
framelist = [i + leadInFrame + pregap for i in raw_framelist]
secondslist = [i//FRAMES_PER_SECOND for i in framelist]
n = long(sum(map(cddb_sum, secondslist)))
t = leadOutFrame/FRAMES_PER_SECOND - framelist[0]/FRAMES_PER_SECOND
print "%08x" % (((n % 0xff) << 24) | (t << 8) | numTracks), numTracks,
print " ".join([str(i) for i in framelist]), leadOutFrame/FRAMES_PER_SECOND
|