Closed thomasgassmann closed 6 years ago
Hi @ThomasGassmann, thanks for the contribution!
I'm happy to include this feature but it doesn't seem to be working for me. I've tried the following:
channel_to_playlist
*-added-videos
filechannel_to_playlist
with --skip_existing True
I find that the videos are just added a second time to the playlist. Could there be some setting you have turned on for your playlist to reject duplicates?
Hi @RobbieClarken, I've just tried to reproduce your error. And according to my investigation, it seems as if YouTube treats the watch later playlist (ID being "WL") differently than all the other playlists. While it is adding the videos twice on a regular playlist, it is throwing the 409 conflict error in the WL playlist. Can you reproduce this behaviour in your WL playlist?
Right now I am even getting the following response from my WL playlist, which seems kind of weird:
<HttpError 500 when requesting https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&alt=json returned "Backend Error">
I will try to investigate that a little further this weekend and will follow up on this PR.
Can you reproduce this behaviour in your WL playlist?
Aha! I do get 409 when adding to my Watch Later playlist and your --skip-existing
flag then works as expected.
If we are to add a --skip-existing
flag it should work for both Watch Later and regular playlists. So the options are:
--skip-existing
option but retain the exception handling of 409's. Perhaps just log the exception as it contains the helpful explanation "Video already in playlist.".--skip-existing
option and query youtube for which videos are already in the playlist and skip adding them for all types of playlists. If we go down this route I think the default for --skip-existing
should be True
.I'm happy with either approach. What do you think?
I've decided to implement approach 2, because it avoids a 409 response and seems like a cleaner solution to me. See 2dcb31a for these changes.
Thanks @ThomasGassmann! I made a few changes before merging (hope you don't mind):
--skip_existing
to --allow-duplicates
and used the action="store_true"
argument so you don't need to specify a value for this option (leaving it off defaults to False
)
Adds a switch to the command line, to skip videos, which already exist in the playlist.