def recreate(self, playlist: Playlist, songs: Iterable[AudioFile]): """Keep a playlist but entirely replace its contents This is useful for applying new external sorting etc""" playlist._list.clear() playlist._list.extend(songs) playlist.finalize() playlist.write() self.changed([playlist])