Changeset 420
- Timestamp:
- 02-01-11 18:14:26 (2 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
morituri/common/program.py (modified) (1 diff)
-
morituri/image/table.py (modified) (3 diffs)
-
morituri/rip/cd.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r417 r420 1 2011-01-02 Thomas Vander Stichele <thomas at apestaart dot org> 2 3 * morituri/common/program.py: 4 * morituri/image/table.py: 5 * morituri/rip/cd.py: 6 Get CDDB disc id. Use it to print info when not found on 7 MusicBrainz. 8 1 9 2011-01-01 Thomas Vander Stichele <thomas at apestaart dot org> 2 10 -
trunk/morituri/common/program.py
r416 r420 301 301 302 302 return os.path.join(outdir, template % v) 303 304 def getCDDB(self, cddbdiscid): 305 """ 306 @param cddbdiscid: list of id, tracks, offsets, seconds 307 308 @rtype: str 309 """ 310 # FIXME: convert to nonblocking? 311 import CDDB 312 code, md = CDDB.query(cddbdiscid) 313 self.debug('CDDB query result: %r, %r', code, md) 314 if code == 200: 315 return md['title'] 316 317 return None 318 303 319 304 320 def getMusicBrainz(self, ittoc, mbdiscid): -
trunk/morituri/image/table.py
r369 r420 240 240 return ret 241 241 242 def getCDDBDiscId(self): 243 """ 244 Calculate the CDDB disc ID. 245 246 @rtype: str 247 @returns: the 8-character hexadecimal disc ID 248 """ 242 def _getCDDBValues(self): 243 """ 244 Get all CDDB values needed to calculate disc id and lookup URL. 245 246 This includes: 247 - CDDB disc id 248 - number of audio tracks 249 - offset of index 1 of each track 250 - length of disc in seconds 251 252 @rtype: list of int 253 """ 254 result = [] 255 256 # number of first track 257 result.append(1) 258 259 # number of last audio track 260 result.append(self.getAudioTracks()) 261 262 leadout = self.leadout 263 # if the disc is multi-session, last track is the data track, 264 # and we should subtract 11250 + 150 from the last track's offset 265 # for the leadout 266 if self.hasDataTracks(): 267 assert not self.tracks[-1].audio 268 leadout = self.tracks[-1].getIndex(1).absolute - 11250 - 150 269 270 # treat leadout offset as track 0 offset 271 result.append(150 + leadout) 272 273 # offsets of tracks 274 for i in range(1, 100): 275 try: 276 track = self.tracks[i - 1] 277 if not track.audio: 278 continue 279 offset = track.getIndex(1).absolute + 150 280 result.append(offset) 281 except IndexError: 282 pass 283 284 285 self.debug('CDDB values: %r', result) 286 return result 287 288 289 290 def getCDDBValues(self): 291 """ 292 Get all CDDB values needed to calculate disc id and lookup URL. 293 294 This includes: 295 - CDDB disc id 296 - number of audio tracks 297 - offset of index 1 of each track 298 - length of disc in seconds 299 300 @rtype: list of int 301 """ 302 result = [] 303 304 result.append(self.getAudioTracks()) 305 249 306 # cddb disc id takes into account data tracks 250 307 # last byte is the number of tracks on the CD … … 260 317 for track in self.tracks: 261 318 offset = self.getTrackStart(track.number) + delta 319 result.append(offset) 262 320 debug.append(str(offset)) 263 321 seconds = offset / common.FRAMES_PER_SECOND … … 273 331 t = leadoutSeconds - startSeconds 274 332 debug.append(str(leadoutSeconds + 2)) # 2 is the 150 frame cddb offset 333 result.append(leadoutSeconds) 275 334 276 335 value = (n % 0xff) << 24 | t << 8 | len(self.tracks) 336 result.insert(0, value) 277 337 278 338 # compare this debug line to cd-discid output 339 self.debug('cddb values: %r', result) 340 279 341 self.debug('cddb disc id debug: %s', 280 342 " ".join(["%08x" % value, ] + debug)) 281 343 282 return "%08x" % value 344 return result 345 346 347 def getCDDBDiscId(self): 348 """ 349 Calculate the CDDB disc ID. 350 351 @rtype: str 352 @returns: the 8-character hexadecimal disc ID 353 """ 354 values = self.getCDDBValues() 355 return "%08x" % values[0] 356 283 357 284 358 def getMusicBrainzDiscId(self): -
trunk/morituri/rip/cd.py
r419 r420 138 138 prog.metadata = prog.getMusicBrainz(ittoc, mbdiscid) 139 139 140 # stop if the cd is unknown and we don't want to continue 141 if not prog.metadata and not self.options.unknown: 142 prog.ejectDevice(device) 143 return -1 140 if not prog.metadata: 141 # fall back to FreeDB for lookup 142 cddbid = ittoc.getCDDBValues() 143 cddbmd = prog.getCDDB(cddbid) 144 if cddbmd: 145 print 'FreeDB identifies disc as %s' % cddbmd 146 147 if not self.options.unknown: 148 prog.ejectDevice(device) 149 return -1 144 150 145 151 # now, read the complete index table, which is slower
Note: See TracChangeset
for help on using the changeset viewer.
