'I need help getting video ids from a playlist in youtube
I'm trying to fetch all the video ids from a playlist on YouTube. Currently, I have things almost working, except the ids that YouTube is returning a much longer than usual and don't seem to work. Here's part of my code:
const requestUrl = `https://www.googleapis.com/youtube/v3/playlistItems?key=${process.env.KEY}&playlistId=${id}&part=id&maxResults=40`
The result under data.items looks like this:
[
{
kind: 'youtube#playlistItem',
etag: 'DxS1pY8G6dwZwfAUJeE8naJEvXM',
id: 'T0xBSzV1eV9uUHdpaDVQbWY3aEJWQ1Q2LU14bVFOTGFBSVAwellYVGsuRUVCNzhFRENBQzBENDM4MA'
},
{
kind: 'youtube#playlistItem',
etag: 'hi9WR5RovxYzHpBXddP__e5nFSA',
id: 'T0xBSzV1eV9uUHdpaDVQbWY3aEJWQ1Q2LU14bVFOTGFBSVAwellYVGsuQzVBOTAwNjQ1OTJFMTVBRg'
}
etc...
However those ids are much longer than normal and when I go to for example
youtube.com/watch?v=T0xBSzV1eV9uUHdpaDVQbWY3aEJWQ1Q2LU14bVFOTGFBSVAwellYVGsuRUVCNzhFRENBQzBENDM4MA
the url automatically gets shortened to https://www.youtube.com/watch?v=T0xBSzV1eV9 and I get a video unavailable screen. When I changed &part=id to &part=snippet, the same thing happened, I just got more video info.
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
