I'm trying to retrieve videos related to "Auto-generated" youtube channel.
While it works some time ago (at least in 2023),
recently I been faced issue — there are no more playlists like "Popular", or "Recent" returned by channels
API, only "Uploads".
But even "Uploads" playlist doesn't have valid playlistId —
playlistItems
api throws error "The playlist identified with the request's playlistId parameter cannot be found."
Here's the sample code:
const YT_KEY = ""; // put your google api key here
const YT_AUTO_CHANNEL_ID = "UCNXJk0T4LRLpWS5XlVSg4uQ";
fetch(`https://youtube.googleapis.com/youtube/v3/channels?part=contentDetails&id=${YT_AUTO_CHANNEL_ID}&key=${YT_KEY}`)
.then((response) => response.json())
.then((json) => {
console.log("Channel's related \"Uploads\" playlistId", json.items[0]?.contentDetails.relatedPlaylists.uploads);
if (json.items[0]?.contentDetails.relatedPlaylists.uploads) {
fetch(`https://youtube.googleapis.com/youtube/v3/playlistItems?part=id%2CcontentDetails%2Csnippet&playlistId=${json.items[0].contentDetails.relatedPlaylists.uploads}&maxResults=50&key=${YT_KEY}`)
.then((response) => response.json())
.then((json) => {
console.log("\"Uploads\" playlist videos response", json);
});
}
});
What can be solution for that?
One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source web-scraping based YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?part=popular,recent&id=CHANNEL_ID, you will get the videos you are looking for in item
.
With the channel id UCNXJk0T4LRLpWS5XlVSg4uQ
you provided you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UCNXJk0T4LRLpWS5XlVSg4uQ",
"nextPageToken": "4qmFsgL8AhIYVUNOWEprMFQ0TFJMcFdTNVhsVlNnNHVRGrACRWdaeVpXTmxiblFZQXlBQU1BRTRBZW9EeXdGSGNGVkNWMjlaUWtOdlRVSkRhWFExWkVZNWQxbFhaR3hZTTA1MVdWaENlbUZIT1RCWU1rNTJZbTVTYkdKdVVtWmtiVlo1WkVkc2FsbFhlSHBZTTBwc1dqSnNkbUp0Um5ORmFEa3pUbGMxUlZKdVRqRmxiVVkyVmxaR00xTXdUalpSVnpGRVZVaE9lVnB0Y0ZWWk1GWlZVa2hvY2tkcVRVRkJSMVoxUVVGR1IxVm5RVUpTYkVsQlFWRkNWbEV3TlZsVGJYTjNWa1JTVFZWcmVIZFdNVTB4VjBkNFYxVXlZekJrVmtWQlFWRkZRa0ZCUVVKQlFVRkNRVkZFZVRKeVQzRkRaMXBCUVVWbmVWVkVTUSUzRCUzRJoCLGJyb3dzZS1mZWVkVUNOWEprMFQ0TFJMcFdTNVhsVlNnNHVRcmVjZW50ODAx,Cgs0NTJ5cVNRNlpZMCj0z5C1BjIiCgJGUhIcEhgSFhMLFBUWFwwYGRobHB0eHw4PIBAREiEgTA%3D%3D",
"popular": [
{
"videoId": "zzNLHZ-PKW4",
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/zzNLHZ-PKW4\/hqdefault.jpg?sqp=-oaymwE8CKgBEF5IWvKriqkDLwgBFQAAAAAYASUAAMhCPQCAokN4AfABAfgBtgiAAoAPigIMCAAQARhCIFAoZTAP&rs=AOn4CLAZVpCyE7i9nzWclrmE7UMZTHc4DA",
"width": 168,
"height": 94
},
...
],
"title": "Ranking DIAMOND CAMO in Every CALL OF DUTY",
"publishedAt": 1690930118,
"views": 3225420,
"channelTitle": "BOOM YT",
"channelId": "UCKnbXodUoiLVjTR1UGDpMHg",
"channelHandle": "@BoomTheGrinder",
"duration": 46,
"approval": "Verified"
},
...
],
"recent": [
{
"videoId": "Sissi8vHE-k",
"thumbnails": [
{
"url": "https:\/\/i.ytimg.com\/vi\/Sissi8vHE-k\/hqdefault.jpg?sqp=-oaymwEiCKgBEF5IWvKriqkDFQgBFQAAAAAYASUAAMhCPQCAokN4AQ==&rs=AOn4CLChI5dNVjrJmJxHSZF0hmR6eJwGHw",
"width": 168,
"height": 94
},
...
],
"title": "\u0628\u0631\u06cc\u0645 \u0628\u0631\u0627\u06cc 18k \u0634\u062f\u0646 \u0633\u0627\u0628 \u0647\u0627\u0645\u0648\u0646\u061f!Call of duty mobile with new iPad m4(:",
"publishedAt": 1721751745,
"views": 152898,
"channelTitle": "mehtiyt",
"channelId": "UCzpy5rDkscnvJd3ywklrPQA",
"channelHandle": "@mehtiyt",
"duration": 23239,
"approval": null
},
...
]
}
]
}