'Returns a list of TrackInfo objects for a discogs tracklist.'

def get_tracks(self, tracklist):

    try:
        clean_tracklist = self.coalesce_tracks(tracklist)
    except Exception as exc:
        self._log.debug(u'{}', traceback.format_exc())
        self._log.error(u'uncaught    exception    in    coalesce_tracks:    {}', exc)
        clean_tracklist = tracklist
    tracks = []
    index_tracks = {}
    index = 0
    for track in clean_tracklist:
        if track['position']:
            index += 1
            track_info = self.get_track_info(track, index)
            track_info.track_alt = track['position']
            tracks.append(track_info)
        else:
            index_tracks[(index + 1)] = track['title']
    medium = None
    (medium_count, index_count, side_count) = (0, 0, 0)
    sides_per_medium = 1
    if all([(track.medium is not None) for track in tracks]):
        m = sorted(set([track.medium.lower() for track in tracks]))
        if (''.join(m) in ascii_lowercase):
            sides_per_medium = 2
            side_count = 1
    for track in tracks:
        medium_is_index = (track.medium and (not track.medium_index) and ((len(track.medium) != 1) or ((ord(track.medium) - 64) != (medium_count + 1))))
        if ((not medium_is_index) and (medium != track.medium)):
            if (side_count < (sides_per_medium - 1)):
                side_count += 1
                medium = track.medium
            else:
                medium = track.medium
                medium_count += 1
                index_count = 0
                side_count = 0
        index_count += 1
        medium_count = (1 if (medium_count == 0) else medium_count)
        (track.medium, track.medium_index) = (medium_count, index_count)
    for track in tracks:
        if (track.medium_index == 1):
            if (track.index in index_tracks):
                disctitle = index_tracks[track.index]
            else:
                disctitle = None
        track.disctitle = disctitle
    return tracks
