Allow to move items within a playlist
Signed-off-by: Nikola Forró <nforro@redhat.com>
This commit is contained in:
parent
d2dd47aaa8
commit
7061ab69f8
1 changed files with 12 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ import json
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
import ntpath
|
import ntpath
|
||||||
import os
|
import os
|
||||||
from typing import List, Dict, Union
|
from typing import List, Dict, Union, Tuple
|
||||||
from ytmusicapi.helpers import *
|
from ytmusicapi.helpers import *
|
||||||
from ytmusicapi.parsers import *
|
from ytmusicapi.parsers import *
|
||||||
from ytmusicapi.setup import setup
|
from ytmusicapi.setup import setup
|
||||||
|
|
@ -786,14 +786,16 @@ class YTMusic:
|
||||||
playlistId: str,
|
playlistId: str,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
description: str = None,
|
description: str = None,
|
||||||
privacyStatus: str = None) -> Union[str, Dict]:
|
privacyStatus: str = None,
|
||||||
|
moveItem: Tuple[str, str] = None) -> Union[str, Dict]:
|
||||||
"""
|
"""
|
||||||
Edit title, description or privacyStatus of a playlist.
|
Edit title, description or privacyStatus of a playlist, or move an item within a playlist.
|
||||||
|
|
||||||
:param playlistId: Playlist id
|
:param playlistId: Playlist id
|
||||||
:param title: Optional. New title for the playlist
|
:param title: Optional. New title for the playlist
|
||||||
:param description: Optional. New description for the playlist
|
:param description: Optional. New description for the playlist
|
||||||
:param privacyStatus: Optional. New privacy status for the playlist
|
:param privacyStatus: Optional. New privacy status for the playlist
|
||||||
|
:param moveItem: Optional. Move one item before another. Items are specified by setVideoId, see :py:func:`get_playlist`
|
||||||
:return: Status String or full response
|
:return: Status String or full response
|
||||||
"""
|
"""
|
||||||
self.__check_auth()
|
self.__check_auth()
|
||||||
|
|
@ -814,6 +816,13 @@ class YTMusic:
|
||||||
'playlistPrivacy': privacyStatus
|
'playlistPrivacy': privacyStatus
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if moveItem:
|
||||||
|
actions.append({
|
||||||
|
'action': 'ACTION_MOVE_VIDEO_BEFORE',
|
||||||
|
'setVideoId': moveItem[0],
|
||||||
|
'movedSetVideoIdSuccessor': moveItem[1]
|
||||||
|
})
|
||||||
|
|
||||||
body['actions'] = actions
|
body['actions'] = actions
|
||||||
endpoint = 'browse/edit_playlist'
|
endpoint = 'browse/edit_playlist'
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue