code review fixes
This commit is contained in:
parent
a7aa3291c5
commit
755eed2753
1 changed files with 9 additions and 18 deletions
|
|
@ -233,7 +233,7 @@ class PlaylistsMixin:
|
||||||
body['actions'].append(action)
|
body['actions'].append(action)
|
||||||
|
|
||||||
# add an empty ACTION_ADD_VIDEO because otherwise YTM doesn't return the dict that maps videoIds to their new setVideoIds
|
# add an empty ACTION_ADD_VIDEO because otherwise YTM doesn't return the dict that maps videoIds to their new setVideoIds
|
||||||
if not videoIds:
|
if source_playlist and not videoIds:
|
||||||
body['actions'].append({'action': 'ACTION_ADD_VIDEO', 'addedVideoId': None})
|
body['actions'].append({'action': 'ACTION_ADD_VIDEO', 'addedVideoId': None})
|
||||||
|
|
||||||
if source_playlist:
|
if source_playlist:
|
||||||
|
|
@ -244,9 +244,14 @@ class PlaylistsMixin:
|
||||||
|
|
||||||
endpoint = 'browse/edit_playlist'
|
endpoint = 'browse/edit_playlist'
|
||||||
response = self._send_request(endpoint, body)
|
response = self._send_request(endpoint, body)
|
||||||
return get_add_to_playlist_results(response) \
|
if 'status' in response and 'SUCCEEDED' in response['status']:
|
||||||
if 'status' in response and 'SUCCEEDED' in response['status'] \
|
result_dict = [
|
||||||
else response
|
result_data.get("playlistEditVideoAddedResultData")
|
||||||
|
for result_data in response.get("playlistEditResults", [])
|
||||||
|
]
|
||||||
|
return {"status": response["status"], "playlistEditResults": result_dict}
|
||||||
|
else:
|
||||||
|
return response
|
||||||
|
|
||||||
def remove_playlist_items(self, playlistId: str, videos: List[Dict]) -> Union[str, Dict]:
|
def remove_playlist_items(self, playlistId: str, videos: List[Dict]) -> Union[str, Dict]:
|
||||||
"""
|
"""
|
||||||
|
|
@ -274,17 +279,3 @@ class PlaylistsMixin:
|
||||||
endpoint = 'browse/edit_playlist'
|
endpoint = 'browse/edit_playlist'
|
||||||
response = self._send_request(endpoint, body)
|
response = self._send_request(endpoint, body)
|
||||||
return response['status'] if 'status' in response else response
|
return response['status'] if 'status' in response else response
|
||||||
|
|
||||||
|
|
||||||
def get_add_to_playlist_results(response):
|
|
||||||
"""
|
|
||||||
Get the response data after adding songs to a playlist
|
|
||||||
|
|
||||||
:param response: the response from add_playlist_items
|
|
||||||
:return: the response status and a dict that maps the videoIds to their new setVideoIds
|
|
||||||
"""
|
|
||||||
resp = [
|
|
||||||
resultData.get("playlistEditVideoAddedResultData")
|
|
||||||
for resultData in response.get("playlistEditResults", [])
|
|
||||||
]
|
|
||||||
return {"status": response["status"], "playlistEditResults": resp}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue