예제 #1
0
    def reorder_tracks(self, indexes, new_index):
        """Move the tracks at the given ``indexes`` to a ``new_index`` in the
        playlist.

        ``indexes`` can be a single index or a list of indexes to move.

        ``new_index`` must be equal to or lower than the current playlist
        length.
        """
        if isinstance(indexes, int):
            indexes = [indexes]
        indexes = list(set(indexes))  # Remove duplicates
        spotify.Error.maybe_raise(lib.sp_playlist_reorder_tracks(
            self._sp_playlist, indexes, len(indexes), new_index))
예제 #2
0
    def reorder_tracks(self, tracks, new_index):
        """Move the given ``tracks`` to a ``new_index`` in the playlist.

        ``tracks`` can be a single :class:`~spotify.Track` or a list of
        :class:`~spotify.Track` objects.

        ``new_index`` must be equal to or lower than the current playlist
        length.
        """
        if isinstance(tracks, spotify.Track):
            tracks = [tracks]
        tracks = list(set(tracks))  # Remove duplicates
        spotify.Error.maybe_raise(lib.sp_playlist_reorder_tracks(
            self._sp_playlist, [t._sp_track for t in tracks], len(tracks),
            new_index))
예제 #3
0
    def reorder_tracks(self, tracks, new_index):
        """Move the given ``tracks`` to a ``new_index`` in the playlist.

        ``tracks`` can be a single :class:`~spotify.Track` or a list of
        :class:`~spotify.Track` objects.

        ``new_index`` must be equal to or lower than the current playlist
        length.
        """
        if isinstance(tracks, spotify.Track):
            tracks = [tracks]
        tracks = list(set(tracks))  # Remove duplicates
        spotify.Error.maybe_raise(
            lib.sp_playlist_reorder_tracks(self._sp_playlist,
                                           [t._sp_track for t in tracks],
                                           len(tracks), new_index))