Elijas / auto-youtube-subscription-playlist-2

Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
MIT License
248 stars 54 forks source link

Exclude error when video is already in playlist. #57

Closed JesperDramsch closed 4 years ago

JesperDramsch commented 4 years ago

Error 409 is the youtube error for existing items. If an item exists, it's technically an error and results in the script consistently failing.

This skips the error flag for existing items to avoid compounding errors and triggering the Timestamp update regardless of the video being in the playlist.

Fabian42 commented 4 years ago

I currently use an older version of this script and it simply adds a video to a playlist regardless of whether it's already there or not, meaning it can create duplicates. This is rarely needed, but when it is, it's the only tool that actually does it. I've done extensive searches and found no other (properly working) tool that can actually create duplicates in YouTube playlists. So it would be nice to keep this functionality (or get it back, if it's currently broken). Removing duplicates is very easy in various ways anyway.

JesperDramsch commented 4 years ago

@fabian42 the current version is broken without this change. Never adds duplicates

JesperDramsch commented 4 years ago

@fabian42 the current version is broken without this change. Never adds duplicates

Fabian42 commented 4 years ago

But you apparently do. ;)

Is it still possible to create duplicates or has YouTube removed that feature from the API?

JesperDramsch commented 4 years ago

Or do I? ;)

JesperDramsch commented 4 years ago

If you would like to do a code review, please do. But maybe try to seek to understand first.

Fabian42 commented 4 years ago

I didn't say anything about a code review.

victorjzsun commented 4 years ago

@JesperDramsch I'm using the updated version and it still adds duplicates, can you screenshot an example of an execution that doesn't add duplicates?

JesperDramsch commented 4 years ago

This is from the email, just counting up every hour of execution.

You may also notice that this only changes that this checks for one error (409) which is the existing item error. If and only if that error happens, the error flag is not set, so the timestamp is updated despite the item already existing in the playlist.

It does not skip the addition, it only escapes error 409 specifically.


Error MessageCount Error: 10 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")1 Error: 12 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")4 Error: 13 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")8 Error: 15 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")2 Error: 16 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")1 Error: 17 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")1 Error: 18 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")1 Error: 19 videos were not added to playlist correctly, please check Debug sheet. Timestamp has not been updated. (line 151, file "Code")1

JesperDramsch commented 4 years ago

It is a generally implemented error in the Google APIs you can find here. We're talking about error 409.

https://developers.google.com/youtube/v3/docs/core_errors#CONFLICT

JesperDramsch commented 4 years ago

Decided to implement it via code number to prevent breaking upon changes in name/description.

The change is tested against the reproducible behaviour on my subList and resolves the error stack.

Fabian42 commented 4 years ago

So it does successfully add the video, but still returns an error code?

JesperDramsch commented 4 years ago

I have an inkling!

Are you using the WL (watch later) playlist?

I am, don't think it allows duplicates.

victorjzsun commented 4 years ago

True, that makes sense.

I'll merge it.