def parseDisc(self, device): type = None if self.is_disc(device) != 2: raise core.ParseError() f = open(device) try: # read CD-XA001 at byte 1024 in sector 16 f.seek(2048*16 + 1024, 0) if f.read(8) != 'CD-XA001': raise core.ParseError() # read VIDEO_CD at sector 150 f.seek(2048*150, 0) typebuffer = f.read(8) if typebuffer != 'VIDEO_CD' and typebuffer != 'SUPERVCD': raise core.ParseError() # Read some bytes of the ISO9660 part to better guess VCD or SVCD. # Maybe this code is not needed and VIDEO_CD and SUPERVCD are enough. f.seek(2048*16, 0) iso9660 = f.read(2048*16) if typebuffer == 'VIDEO_CD' and iso9660.find('MPEGAV') > 0: type = 'VCD' elif typebuffer == 'SUPERVCD' and \ (iso9660.find('SVCD') > 0 or iso9660.find('MPEG2') > 0): type = 'SVCD' else: raise core.ParseError() finally: f.close() # read the tracks to generate the title list device = open(device) (first, last) = cdrom.audiocd_toc_header(device) lmin = 0 lsec = 0 num = 0 for i in range(first, last + 2): if i == last + 1: min, sec, frames = cdrom.audiocd_leadout(device) else: min, sec, frames = cdrom.audiocd_toc_entry(device, i) if num: vi = core.VideoStream() # XXX add more static information here, it's also possible # XXX to scan for more informations like fps # XXX Settings to MPEG1/2 is a wild guess, maybe the track # XXX isn't playable at all (e.g. the menu) if type == 'VCD': vi.codec = 'MPEG1' else: vi.codec = 'MPEG2' vi.length = (min-lmin) * 60 + (sec-lsec) self.tracks.append(vi) num += 1 lmin, lsec = min, sec device.close()
def parseDisc(self, device): type = None if self.is_disc(device) != 2: raise core.ParseError() f = open(device) try: # read CD-XA001 at byte 1024 in sector 16 f.seek(2048 * 16 + 1024, 0) if f.read(8) != 'CD-XA001': raise core.ParseError() # read VIDEO_CD at sector 150 f.seek(2048 * 150, 0) typebuffer = f.read(8) if typebuffer != 'VIDEO_CD' and typebuffer != 'SUPERVCD': raise core.ParseError() # Read some bytes of the ISO9660 part to better guess VCD or SVCD. # Maybe this code is not needed and VIDEO_CD and SUPERVCD are enough. f.seek(2048 * 16, 0) iso9660 = f.read(2048 * 16) if typebuffer == 'VIDEO_CD' and iso9660.find('MPEGAV') > 0: type = 'VCD' elif typebuffer == 'SUPERVCD' and \ (iso9660.find('SVCD') > 0 or iso9660.find('MPEG2') > 0): type = 'SVCD' else: raise core.ParseError() finally: f.close() # read the tracks to generate the title list device = open(device) (first, last) = cdrom.audiocd_toc_header(device) lmin = 0 lsec = 0 num = 0 for i in range(first, last + 2): if i == last + 1: min, sec, frames = cdrom.audiocd_leadout(device) else: min, sec, frames = cdrom.audiocd_toc_entry(device, i) if num: vi = core.VideoStream() # XXX add more static information here, it's also possible # XXX to scan for more informations like fps # XXX Settings to MPEG1/2 is a wild guess, maybe the track # XXX isn't playable at all (e.g. the menu) if type == 'VCD': vi.codec = 'MPEG1' else: vi.codec = 'MPEG2' vi.length = (min - lmin) * 60 + (sec - lsec) self.tracks.append(vi) num += 1 lmin, lsec = min, sec device.close()
if query_stat != 200: log.error("failure getting disc info, status %i" % query_stat) self.no_caching = 1 for i in range(0, disc_id[1]): mi = AudioTrack() mi.title = 'Track %s' % (i+1) mi.codec = 'PCM' mi.samplerate = 44100 mi.trackno = i+1 mi.trackof = disc_id[1] self.tracks.append(mi) # read the tracks to generate the title list (first, last) = cdrom.audiocd_toc_header(cdromfd) lmin = 0 lsec = 0 num = 0 for i in range(first, last + 2): if i == last + 1: min, sec, frames = cdrom.audiocd_leadout(cdromfd) else: min, sec, frames = cdrom.audiocd_toc_entry(cdromfd, i) if num: self.tracks[num-1].length = (min-lmin)*60 + (sec-lsec) num += 1 lmin, lsec = min, sec
query_stat = 400 if query_stat != 200: log.error("failure getting disc info, status %i" % query_stat) self.no_caching = 1 for i in range(0, disc_id[1]): mi = AudioTrack() mi.title = "Track %s" % (i + 1) mi.codec = "PCM" mi.samplerate = 44100 mi.trackno = i + 1 mi.trackof = disc_id[1] self.tracks.append(mi) # read the tracks to generate the title list (first, last) = cdrom.audiocd_toc_header(cdromfd) lmin = 0 lsec = 0 num = 0 for i in range(first, last + 2): if i == last + 1: min, sec, frames = cdrom.audiocd_leadout(cdromfd) else: min, sec, frames = cdrom.audiocd_toc_entry(cdromfd, i) if num: self.tracks[num - 1].length = (min - lmin) * 60 + (sec - lsec) num += 1 lmin, lsec = min, sec