'Calculate a new rating for a song based on play count, skip count,
old rating and the fact if it was skipped or not.'

def rating(self, play_count, skip_count, rating, skipped):

    if skipped:
        rolling = (rating - (rating / 2.0))
    else:
        rolling = (rating + ((1.0 - rating) / 2.0))
    stable = ((play_count + 1.0) / ((play_count + skip_count) + 2.0))
    return ((self.rating_mix * stable) + ((1.0 - self.rating_mix) * rolling))
