create_playlist: return error if unsuccessful (closes #19)
This commit is contained in:
parent
932827d44f
commit
396a76a40d
1 changed files with 9 additions and 6 deletions
|
|
@ -757,7 +757,7 @@ class YTMusic:
|
||||||
description: str,
|
description: str,
|
||||||
privacy_status: str = "PRIVATE",
|
privacy_status: str = "PRIVATE",
|
||||||
video_ids: List = None,
|
video_ids: List = None,
|
||||||
source_playlist: str = None) -> str:
|
source_playlist: str = None) -> Union[str, Dict]:
|
||||||
"""
|
"""
|
||||||
Creates a new empty playlist and returns its id.
|
Creates a new empty playlist and returns its id.
|
||||||
|
|
||||||
|
|
@ -766,7 +766,7 @@ class YTMusic:
|
||||||
:param privacy_status: Playlists can be 'PUBLIC', 'PRIVATE', or 'UNLISTED'. Default: 'PRIVATE'
|
:param privacy_status: Playlists can be 'PUBLIC', 'PRIVATE', or 'UNLISTED'. Default: 'PRIVATE'
|
||||||
:param video_ids: IDs of songs to create the playlist with
|
:param video_ids: IDs of songs to create the playlist with
|
||||||
:param source_playlist: Another playlist whose songs should be added to the new playlist
|
:param source_playlist: Another playlist whose songs should be added to the new playlist
|
||||||
:return: ID of the YouTube playlist
|
:return: ID of the YouTube playlist or full response if there was an error
|
||||||
"""
|
"""
|
||||||
self.__check_auth()
|
self.__check_auth()
|
||||||
body = {
|
body = {
|
||||||
|
|
@ -782,7 +782,7 @@ class YTMusic:
|
||||||
|
|
||||||
endpoint = 'playlist/create'
|
endpoint = 'playlist/create'
|
||||||
response = self.__send_request(endpoint, body)
|
response = self.__send_request(endpoint, body)
|
||||||
return response['playlistId']
|
return response['playlistId'] if 'playlistId' in response else response
|
||||||
|
|
||||||
def edit_playlist(self,
|
def edit_playlist(self,
|
||||||
playlistId: str,
|
playlistId: str,
|
||||||
|
|
@ -807,7 +807,10 @@ class YTMusic:
|
||||||
body = {'playlistId': playlistId}
|
body = {'playlistId': playlistId}
|
||||||
actions = []
|
actions = []
|
||||||
if title:
|
if title:
|
||||||
actions.append({'action': 'ACTION_SET_PLAYLIST_NAME', 'playlistName': title})
|
actions.append({
|
||||||
|
'action': 'ACTION_SET_PLAYLIST_NAME',
|
||||||
|
'playlistName': title
|
||||||
|
})
|
||||||
|
|
||||||
if description:
|
if description:
|
||||||
actions.append({
|
actions.append({
|
||||||
|
|
@ -831,8 +834,8 @@ class YTMusic:
|
||||||
if addPlaylistId:
|
if addPlaylistId:
|
||||||
actions.append({
|
actions.append({
|
||||||
'action': 'ACTION_ADD_PLAYLIST',
|
'action': 'ACTION_ADD_PLAYLIST',
|
||||||
'addedFullListId': addPlaylistId
|
'addedFullListId': addPlaylistId}
|
||||||
})
|
)
|
||||||
|
|
||||||
body['actions'] = actions
|
body['actions'] = actions
|
||||||
endpoint = 'browse/edit_playlist'
|
endpoint = 'browse/edit_playlist'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue