def from_tracks(cls, tracks): """given a sorted list of tracks, returns DiscID for those tracks as if they were a CD""" from audiotools import has_pre_gap_track if not has_pre_gap_track(tracks): offsets = [150] for track in tracks[0:-1]: offsets.append(offsets[-1] + track.cd_frames()) return cls( first_track_number=1, last_track_number=len(tracks), lead_out_offset=sum([t.cd_frames() for t in tracks]) + 150, offsets=offsets) else: offsets = [150 + tracks[0].cd_frames()] for track in tracks[1:-1]: offsets.append(offsets[-1] + track.cd_frames()) return cls( first_track_number=1, last_track_number=len(tracks) - 1, lead_out_offset=sum([t.cd_frames() for t in tracks]) + 150, offsets=offsets)
def from_tracks(cls, tracks): """given a sorted list of AudioFile objects, returns DiscID for those tracks as if they were a CD""" from audiotools import has_pre_gap_track from audiotools.freedb import DiscID as FDiscID if not has_pre_gap_track(tracks): offsets = [0] for track in tracks[0:-1]: offsets.append(offsets[-1] + track.cd_frames()) return cls(track_numbers=range(1, len(tracks) + 1), track_offsets=offsets, lead_out_offset=sum(t.cd_frames() for t in tracks), freedb_disc_id=FDiscID.from_tracks(tracks)) else: offsets = [tracks[0].cd_frames()] for track in tracks[1:-1]: offsets.append(offsets[-1] + track.cd_frames()) return cls(track_numbers=range(1, len(tracks)), track_offsets=offsets, lead_out_offset=sum(t.cd_frames() for t in tracks), freedb_disc_id=FDiscID.from_tracks(tracks))
def from_tracks(cls, tracks): """given a sorted list of tracks, returns DiscID for those tracks as if they were a CD""" from audiotools import has_pre_gap_track if not has_pre_gap_track(tracks): offsets = [150] for track in tracks[0:-1]: offsets.append(offsets[-1] + track.cd_frames()) #track_lengths = sum(t.cd_frames() for t in tracks) // 75 total_length = sum(t.seconds_length() for t in tracks) return cls(offsets=offsets, total_length=int(total_length), track_count=len(tracks), playable_length=int(total_length + 2)) else: offsets = [150 + tracks[0].cd_frames()] for track in tracks[1:-1]: offsets.append(offsets[-1] + track.cd_frames()) total_length = sum(t.seconds_length() for t in tracks[1:]) return cls( offsets=offsets, total_length=int(total_length), track_count=len(tracks) - 1, playable_length=int(total_length + 2))
def from_tracks(cls, tracks): """given a sorted list of tracks, returns DiscID for those tracks as if they were a CD""" from audiotools import has_pre_gap_track if not has_pre_gap_track(tracks): offsets = [150] for track in tracks[0:-1]: offsets.append(offsets[-1] + track.cd_frames()) #track_lengths = sum(t.cd_frames() for t in tracks) // 75 total_length = sum(t.seconds_length() for t in tracks) return cls(offsets=offsets, total_length=int(total_length), track_count=len(tracks), playable_length=int(total_length + 2)) else: offsets = [150 + tracks[0].cd_frames()] for track in tracks[1:-1]: offsets.append(offsets[-1] + track.cd_frames()) total_length = sum(t.seconds_length() for t in tracks[1:]) return cls(offsets=offsets, total_length=int(total_length), track_count=len(tracks) - 1, playable_length=int(total_length + 2))