Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin/
lib/
pyvenv.cfg
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ Loaded with OpenEMU v1.03

usage:

ccd2cue.py convert --ccd CCDSHEET

requared arguments:

--ccd CCDSHEET ccd file name
ccd2cue.py --ccd [path_to_ccd]


55 changes: 32 additions & 23 deletions ccd2cue.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
https://github.com/crumpx/ccd2cue.git
'''

import ConfigParser
import configparser
import os
from datetime import timedelta

def ConfigSectionMap(Config, section):
dict1 = {}
Expand All @@ -26,19 +27,21 @@ def CCD2CUE(ccdsheet):
cuesheet = os.path.join(filename[0]+'.cue')
imagetype=('.img','.bin','.iso')
imgfile = ''
files = [f for f in os.listdir('.') if os.path.isfile(f)]
basedir = os.path.dirname(ccdsheet)
files = list(filter(lambda f: os.path.isfile(os.path.join(basedir,f)), os.listdir(basedir)))
for f in files:
if os.path.splitext(f)[1] in imagetype:

if os.path.splitext(f)[1].casefold() in map(str.casefold, imagetype):
imgfile = f

Config = ConfigParser.ConfigParser()
Config = configparser.ConfigParser()
Config.read(ccdsheet)
cuefile = open(cuesheet, 'wb')
cuefile = open(cuesheet, 'w')

track_counter = 0
BEGIN = False

cuefile.write("FILE \"%s\" BINARY\r\n" % (imgfile))
cuefile.write("FILE \"%s\" BINARY\n" % (imgfile))
for item in Config.sections():
if 'Entry' not in item:
continue
Expand All @@ -49,27 +52,33 @@ def CCD2CUE(ccdsheet):
trackinfo['minute'] = int(ConfigSectionMap(Config, item)['pmin'])
trackinfo['second'] = int(ConfigSectionMap(Config,item)['psec'])
trackinfo['frame'] = int(ConfigSectionMap(Config,item)['pframe'])



if int(ConfigSectionMap(Config,item)['plba']) == 0:
BEGIN = True

if BEGIN is True:
if BEGIN:

track_counter += 1
if trackinfo['second'] == 0:
if trackinfo['minute'] >= 1:
trackinfo['minute'] -= 1
trackinfo['second'] = 60
else:
trackinfo['minute'] = 0
trackinfo['second'] = 0
trackinfo['second'] -= 2
cuefile.write(" TRACK %02d %s\r\n" \
" INDEX %02d %02d:%02d:%02d\r\n" % (track_counter,
"MODE1/2352" if tracktype == '0x04' else 'AUDIO',
trackindex,
trackinfo['minute'],
trackinfo['second'],
trackinfo['frame'],))

if track_counter == 1:
cuefile.write(" TRACK 01 MODE1/2352\n" \
" INDEX 01 00:00:00\n")
else:
index0 = timedelta(minutes=trackinfo['minute'],seconds=trackinfo['second']) - timedelta(seconds=4)
index0_m = int(index0.seconds/60)
index0_s = int(index0.seconds - index0_m*60)

index1 = timedelta(minutes=trackinfo['minute'],seconds=trackinfo['second']) - timedelta(seconds=2)
index1_m = int(index1.seconds/60)
index1_s = int(index1.seconds - index1_m*60)

cuefile.write(
f""" TRACK {track_counter} AUDIO\n"""
f""" INDEX 00 {index0_m:02}:{index0_s:02}:{trackinfo['frame']:0>2}\n"""
f""" INDEX 01 {index1_m:02}:{index1_s:02}:{trackinfo['frame']:0>2}\n"""
)

cuefile.close()
if __name__ == '__main__':
Expand Down