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

Fails if playlist is deleted #25

Closed Fabian42 closed 4 years ago

Fabian42 commented 6 years ago

The last successful run on 1.8.2018 at 4:35, since then every hourly run gives this error message for the updatePlaylists function: TypeError: Cannot read property "items" from undefined. (line 169, file "Code") Sadly Google Sheets doesn't give any more output than that.

Elijas commented 6 years ago

Sadly, I currently don't have time available to investigate/fix, but I might check and merge a PR (while putting the person to a list of contributors, of course:))

Fabian42 commented 6 years ago

Sadly I'm not at all familiar with JavaScript and especially not with the YouTube API (and an API call seems to be what's wrong here, since apparently "YouTube.PlaylistItems.list" returns an empty response). I rely pretty much on this thing, but I have a backlog anyway, the biggest problem would probably be the 300 video limit as soon as it does work again. What do you think when you might be able to fix it? A week, a month, a year?

On Fri, 3 Aug 2018 at 21:37, Elijas Dapšauskas notifications@github.com wrote:

Sadly, I currently don't have time available to investigate/fix, but I might check and merge a PR (while putting the person to a list of contributors, of course:))

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Elijas/auto-youtube-subscription-playlist-2/issues/25#issuecomment-410355446, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_vYp5-VvmSKpuIRyXZQ8a-8tVrhvz_ks5uNKaLgaJpZM4Vt_3Z .

Elijas commented 6 years ago

I currently have to make my financial ends meet, so I have to work on other projects. Therefore, I really can't say. I'm sorry 😞

What are the options, then? Well, someone could post a bounty on Bountify.co. Alternatively, one could formulate a question on StackOverflow, like it was done here or here.

If you do post bounties/questions, related to this issue, please post the links in the comments below.

As for longer-term, if the community expresses a dire need for the project to be supported, I could set up a Patreon account and we could work this out together! 👍

Fabian42 commented 6 years ago

I found the problem!!! I basically know no JavaScript, no Google Apps scripts, no YouTube API, no Google Sheets API, not your code, but I still found the bug! I only discovered the logger when I was already done, until then I passed the "sheet" variable to other methods to be able to write something into a cell. This was to try to reduce the problem to a minimum example as good as I can, but then I found out that var results = YouTube.PlaylistItems.list('snippet', {playlistId: playlistId, maxResults: 50, order: "date", publishedAfter: lastTimestamp, pageToken: nextPageToken}); gives an error, so the catch block gets run. Then I wanted to look at all parameters of that individually, but putting playlistId into the table cell was already enough, because I saw the third playlist ID. I thought "hm, that's strange, why doesn't it fail at the first or second one", so I looked at the playlist on YouTube and what did I find? The playlist was deleted!

So apparently the script fails if the playlist it tries to get the items from does not exist. This could probably be solved by adding something to the catch block that just skips the playlist or maybe writes something into the table or whatever, so that the next time the user gets an automated failure summary from Google, the error is easier to find. Or at least an FAQ entry that says that this error means "check your playlist IDs". Because "TypeError: Cannot read property "items" from undefined. (line 169, file "Code")" isn't really a helpful error message.

On Sat, 4 Aug 2018 at 08:06, Elijas Dapšauskas notifications@github.com wrote:

I currently have to make my financial ends meet, so I have to work on other projects. Therefore, I really can't say. I'm sorry 😞

What are the options, then? Well, someone could post a bounty on Bountify.co https://bountify.co/ (If you do so, please post the link of it in a comment of this issue).

Alternatively you could formulate a question on StackOverflow, like it was done here https://stackoverflow.com/questions/48867365/google-script-auto-add-recently-uploaded-yt-videos-from-subscriptions-to-specior here https://stackoverflow.com/questions/31161293/deleting-a-video-from-a-playlist-with-youtube-data-api-v3-in-google-apps-script. (Same as above, please questions in the comments).

As for longer-term, if the community expresses a dire need for the project to be supported, I could set up a Patreon account and we could work this out together! 👍

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Elijas/auto-youtube-subscription-playlist-2/issues/25#issuecomment-410426615, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ_vYjwK4KoLZnMtKamnZHhH1p2ZWf57ks5uNTncgaJpZM4Vt_3Z .

Fabian42 commented 5 years ago

Since you didn't do any of the things I suggested, I at least made an edit suggestion for README.md that tells the user to fix their playlist IDs: https://github.com/Elijas/auto-youtube-subscription-playlist-2/compare/master...Fabian42:patch-3

victorjzsun commented 5 years ago

I can probably add a couple of checks to search YouTube for missing playlists (YouTube.Playlists.list) and channels (YouTube.Channel.list) and produce a proper error message.

JesperDramsch commented 4 years ago

Possibly adressed in #46

victorjzsun commented 4 years ago

Closing this after adding new logs to script