It would be really useful to be able to add videos to playlists without first opening/playing the video. I briefly investigated this in YePpHa/YouTubeCenter/issues/1865 before discovering this project (see discussion there for further explanation and images).
Personally I would like to replace the WatchLater button with the old Add button. It would also be ok to create an Add To Playlist button in the triple-dot menu, but IMO that is an extra unnecessary click.
The WatchLater button still has styles to render a + icon if you simply strip it of the addto-watch-later-button class (although the sizing might need adjusting):
Investigation
Below I detail some of the useful ajax requests for adding a video to a playlist. Hopefully it is helpful.
For all requests youtube send a session_token, which appears to be unnecessary (I assume because auth headers are included by XHR anyway).
The response will be XML which has a node containing the HTML text to use in the menu.
Each menu item (<li>) will have an data-full-list-id attribute listing the playlist full-id.
There is also a a data-item-name attribute which contains the user readable playlist name - useful for notifications when the video is (un)successfully added/removed.
If the video is already in the playlist, the <li> will have the contains-all-selected-videos class and the <button> will have aria-checked="checked"
Otherwise the class will be absent and the <button> will have aria-checked="unchecked"
Adding the video to a clicked playlist
To add the video to one of the playlists, send a POST request to https://www.youtube.com/playlist_video_ajax?action_add_to_playlist=1 with url encoded form data video_ids (same as action_get_dropdown) and full_list_id (the playlist full-id). Youtube also send plid which appears to be a short form of the playlist id, not sure if this is needed.
The response will be json either {"code":"SUCCESS"} or some error.
Summary
It would be really useful to be able to add videos to playlists without first opening/playing the video. I briefly investigated this in YePpHa/YouTubeCenter/issues/1865 before discovering this project (see discussion there for further explanation and images).
Personally I would like to replace the WatchLater button with the old Add button. It would also be ok to create an Add To Playlist button in the triple-dot menu, but IMO that is an extra unnecessary click.
The WatchLater button still has styles to render a
+
icon if you simply strip it of theaddto-watch-later-button
class (although the sizing might need adjusting):Investigation
Below I detail some of the useful ajax requests for adding a video to a playlist. Hopefully it is helpful.
For all requests youtube send a
session_token
, which appears to be unnecessary (I assume because auth headers are included by XHR anyway).Getting the dropdown menu source code
To get the html send a POST request to
https://www.youtube.com/addto_ajax?action_get_dropdown=1&hide_watch_later=false
with url-encoded form datavideo_ids
(the video id).The response will be XML which has a node containing the HTML text to use in the menu.
<li>
) will have andata-full-list-id
attribute listing the playlist full-id.data-item-name
attribute which contains the user readable playlist name - useful for notifications when the video is (un)successfully added/removed.<li>
will have thecontains-all-selected-videos
class and the<button>
will havearia-checked="checked"
<button>
will havearia-checked="unchecked"
Adding the video to a clicked playlist
To add the video to one of the playlists, send a POST request to
https://www.youtube.com/playlist_video_ajax?action_add_to_playlist=1
with url encoded form datavideo_ids
(same asaction_get_dropdown
) andfull_list_id
(the playlist full-id). Youtube also sendplid
which appears to be a short form of the playlist id, not sure if this is needed.The response will be json either
{"code":"SUCCESS"}
or some error.Removing the video from a clicked playlist
To remove the video from one of the playlists, send a POST request to
https://www.youtube.com/playlist_video_ajax?action_delete_from_playlist=1
with everything the same asaction_add_to_playlist
above.