edit_playlist: change addToTop function parameter to Optional[bool] (#444)
This commit is contained in:
parent
6f7dfce572
commit
369ac9323f
2 changed files with 9 additions and 4 deletions
|
|
@ -480,6 +480,7 @@ class TestYTMusic(unittest.TestCase):
|
||||||
self.assertEqual(response["status"], "STATUS_SUCCEEDED", "Adding playlist item failed")
|
self.assertEqual(response["status"], "STATUS_SUCCEEDED", "Adding playlist item failed")
|
||||||
self.assertGreater(len(response["playlistEditResults"]), 0, "Adding playlist item failed")
|
self.assertGreater(len(response["playlistEditResults"]), 0, "Adding playlist item failed")
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
self.yt_brand.edit_playlist(playlistId, addToTop=False)
|
||||||
playlist = self.yt_brand.get_playlist(playlistId, related=True)
|
playlist = self.yt_brand.get_playlist(playlistId, related=True)
|
||||||
self.assertEqual(len(playlist["tracks"]), 46, "Getting playlist items failed")
|
self.assertEqual(len(playlist["tracks"]), 46, "Getting playlist items failed")
|
||||||
response = self.yt_brand.remove_playlist_items(playlistId, playlist["tracks"])
|
response = self.yt_brand.remove_playlist_items(playlistId, playlist["tracks"])
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Dict, Union, Tuple
|
from typing import Dict, Union, Tuple, Optional
|
||||||
from ._utils import *
|
from ._utils import *
|
||||||
|
|
||||||
from ytmusicapi.continuations import *
|
from ytmusicapi.continuations import *
|
||||||
|
|
@ -233,7 +233,7 @@ class PlaylistsMixin:
|
||||||
privacyStatus: str = None,
|
privacyStatus: str = None,
|
||||||
moveItem: Tuple[str, str] = None,
|
moveItem: Tuple[str, str] = None,
|
||||||
addPlaylistId: str = None,
|
addPlaylistId: str = None,
|
||||||
addToTop: bool = False) -> Union[str, Dict]:
|
addToTop: Optional[bool] = None) -> Union[str, Dict]:
|
||||||
"""
|
"""
|
||||||
Edit title, description or privacyStatus of a playlist.
|
Edit title, description or privacyStatus of a playlist.
|
||||||
You may also move an item within a playlist or append another playlist to this playlist.
|
You may also move an item within a playlist or append another playlist to this playlist.
|
||||||
|
|
@ -244,8 +244,9 @@ class PlaylistsMixin:
|
||||||
: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`
|
:param moveItem: Optional. Move one item before another. Items are specified by setVideoId, see :py:func:`get_playlist`
|
||||||
:param addPlaylistId: Optional. Id of another playlist to add to this playlist
|
:param addPlaylistId: Optional. Id of another playlist to add to this playlist
|
||||||
:param addToTop: Optional. Change the state of this playlist to add items to the top of the playlist by default.
|
:param addToTop: Optional. Change the state of this playlist to add items to the top of the playlist (if True)
|
||||||
:return: Status String or full responwwwse
|
or the bottom of the playlist (if False - this is also the default of a new playlist).
|
||||||
|
:return: Status String or full response
|
||||||
"""
|
"""
|
||||||
self._check_auth()
|
self._check_auth()
|
||||||
body = {'playlistId': validate_playlist_id(playlistId)}
|
body = {'playlistId': validate_playlist_id(playlistId)}
|
||||||
|
|
@ -278,6 +279,9 @@ class PlaylistsMixin:
|
||||||
if addToTop:
|
if addToTop:
|
||||||
actions.append({'action': 'ACTION_SET_ADD_TO_TOP', 'addToTop': 'true'})
|
actions.append({'action': 'ACTION_SET_ADD_TO_TOP', 'addToTop': 'true'})
|
||||||
|
|
||||||
|
if addToTop is not None:
|
||||||
|
actions.append({'action': 'ACTION_SET_ADD_TO_TOP', 'addToTop': str(addToTop)})
|
||||||
|
|
||||||
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