Skip to content

Commit

Permalink
Fix removing item from playlist #570
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Feb 1, 2024
1 parent 95ee895 commit 3716d53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
14 changes: 8 additions & 6 deletions resources/lib/youtube_plugin/youtube/client/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def remove_video_from_playlist(self,
return self.api_request(method='DELETE',
path='playlistItems',
params=params,
no_content=True,
**kwargs)

def unsubscribe(self, subscription_id, **kwargs):
Expand Down Expand Up @@ -1581,6 +1582,8 @@ def _response_hook(self, **kwargs):
response = kwargs['response']
self._context.log_debug('API response: |{0.status_code}|\n'
'headers: |{0.headers}|'.format(response))
if response.status_code == 204 and 'no_content' in kwargs:
return True
try:
json_data = response.json()
if 'error' in json_data:
Expand Down Expand Up @@ -1707,9 +1710,8 @@ def api_request(self,
params=log_params,
data=client.get('json'),
headers=log_headers))

json_data = self.request(response_hook=self._response_hook,
response_hook_kwargs=kwargs,
error_hook=self._error_hook,
**client)
return json_data
response = self.request(response_hook=self._response_hook,
response_hook_kwargs=kwargs,
error_hook=self._error_hook,
**client)
return response
5 changes: 4 additions & 1 deletion resources/lib/youtube_plugin/youtube/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,10 @@ def update_video_infos(provider, context, video_id_dict,
video_item.set_playlist_item_id(playlist_item_id)
context_menu.append(
menu_items.remove_video_from_playlist(
context, playlist_id, video_id, video_item.get_name()
context,
playlist_id=playlist_id,
video_id=playlist_item_id,
video_name=video_item.get_name(),
)
)

Expand Down
8 changes: 5 additions & 3 deletions resources/lib/youtube_plugin/youtube/helper/yt_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ def _process_remove_video(provider, context):

if playlist_id.strip().lower() not in ('wl', 'hl'):
if context.get_ui().on_remove_content(video_name):
json_data = provider.get_client(context).remove_video_from_playlist(playlist_id=playlist_id,
playlist_item_id=video_id)
if not json_data:
success = provider.get_client(context).remove_video_from_playlist(
playlist_id=playlist_id,
playlist_item_id=video_id,
)
if not success:
return False

context.get_ui().refresh_container()
Expand Down

0 comments on commit 3716d53

Please sign in to comment.