From 7f37cf2d60843c95ab3bde766b15e5548279a931 Mon Sep 17 00:00:00 2001 From: Al Grimes Date: Thu, 16 Jan 2025 15:51:11 +0000 Subject: [PATCH 1/5] Fix for when track would decrement the minute. Fixes #3 . Upgrade to python 3 --- ccd2cue.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ccd2cue.py b/ccd2cue.py index f86c69a..b7e5dfa 100755 --- a/ccd2cue.py +++ b/ccd2cue.py @@ -1,11 +1,11 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- ''' https://github.com/crumpx/ccd2cue.git ''' -import ConfigParser +import configparser import os def ConfigSectionMap(Config, section): @@ -31,9 +31,9 @@ def CCD2CUE(ccdsheet): if os.path.splitext(f)[1] in 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 @@ -55,10 +55,10 @@ def CCD2CUE(ccdsheet): if BEGIN is True: track_counter += 1 - if trackinfo['second'] == 0: + if trackinfo['second'] in [0,1]: if trackinfo['minute'] >= 1: trackinfo['minute'] -= 1 - trackinfo['second'] = 60 + trackinfo['second'] = 60 + trackinfo['second'] else: trackinfo['minute'] = 0 trackinfo['second'] = 0 From 9d20a6a33551a04be20de61b378ce63bf7bff1a6 Mon Sep 17 00:00:00 2001 From: Al Grimes Date: Thu, 16 Jan 2025 15:54:50 +0000 Subject: [PATCH 2/5] Tidyup README --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index b491173..5d4ed30 100644 --- a/README.md +++ b/README.md @@ -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] From 2bef6c64b7101d692e011c00f32ea227a905d7e5 Mon Sep 17 00:00:00 2001 From: Al Grimes Date: Thu, 16 Jan 2025 16:36:35 +0000 Subject: [PATCH 3/5] Set binary filename correctly, case insensitive --- ccd2cue.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ccd2cue.py b/ccd2cue.py index b7e5dfa..480db2c 100755 --- a/ccd2cue.py +++ b/ccd2cue.py @@ -26,9 +26,11 @@ 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() From 09e9031c891bd391db1c9bb148e316c126e92ec4 Mon Sep 17 00:00:00 2001 From: Al Grimes Date: Wed, 5 Feb 2025 13:45:19 +0000 Subject: [PATCH 4/5] Add gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..681a17b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +lib/ +pyvenv.cfg From 19a5bcfb942f80178ee92c8d548c23cfc40dac33 Mon Sep 17 00:00:00 2001 From: Al Grimes Date: Wed, 5 Feb 2025 13:51:03 +0000 Subject: [PATCH 5/5] Add pregap to create valid cuesheet. Rewrote cuesheet writing and time logic. Fixes #2 --- ccd2cue.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/ccd2cue.py b/ccd2cue.py index 480db2c..4cfa6a5 100755 --- a/ccd2cue.py +++ b/ccd2cue.py @@ -7,6 +7,7 @@ import configparser import os +from datetime import timedelta def ConfigSectionMap(Config, section): dict1 = {} @@ -40,7 +41,7 @@ def CCD2CUE(ccdsheet): 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 @@ -51,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'] in [0,1]: - if trackinfo['minute'] >= 1: - trackinfo['minute'] -= 1 - trackinfo['second'] = 60 + trackinfo['second'] - 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__':