Search code examples
youtubeyoutube-apiyoutube-data-api

YouTube API to get videos from an account


There is an answer that describes how to fetch all videos from a YouTube channel here. However, in many cases, the parent account is not a channel per se, but something similar (like this is a channel, as evidenced by the "channel" word in the URL, while this one is not, since it has a keyword "c" in the URL, and not "channel"). I can still get playlists from it, and get all videos from individual playlist in that WWE account, but there are many videos in that account that are not part of any playlist listed in the account, like this).

Question - Is there a way to get all videos from an account, not just a channel or a playlist? Or is there any way to get default playlist/channel from an account where all unlisted videos such as above can be found?


Solution

  • Edit (15/03/2022):

    I've found that the video_id = eJjbnFZ6yA8 is on the "uploads" playlist and it's in the position # 7765.

    You can try to get the position in the given playlist by making this query:

    https://content-youtube.googleapis.com/youtube/v3/playlistItems?maxResults=50&playlistId=<UPLOADS_PLAYLIST_ID>&videoId=<VIDEO_ID_YOU_WANT_TO_GET>&part=id,snippet,contentDetails,status&key=[YOUR_API_KEY]

    These are the results of the video_id = eJjbnFZ6yA8:

    URL:

    https://content-youtube.googleapis.com/youtube/v3/playlistItems?maxResults=50&playlistId=UUJ5v_MCY6GNUBTO8-D3XoAg&videoId=eJjbnFZ6yA8&key=[YOUR_API_KEY]&part=id,snippet,contentDetails,status

    Response:

    {
        "kind": "youtube#playlistItemListResponse",
        "etag": "SyO-_mevTIc8xX7G8QA0JKcgwTE",
        "items": [
            {
                "kind": "youtube#playlistItem",
                "etag": "70IgC85z_68I9jCkp4Jwuwo_pO8",
                "id": "VVVKNXZfTUNZNkdOVUJUTzgtRDNYb0FnLmVKamJuRlo2eUE4",
                "snippet": {
                    "publishedAt": "2020-12-27T21:05:54Z",
                    "channelId": "UCJ5v_MCY6GNUBTO8-D3XoAg",
                    "title": "FULL MATCH - The Rock vs. Mankind – WWE Championship Match: Raw, Jan. 4, 1999",
                    "description": "Mankind looks to make his dream come true when he challenges The Rock for the WWE Championship on the first Raw of 1999: Courtesy of WWE Network.\nWWE Network | Subscribe now: http://wwe.yt/wwenetwork\r\n---------------------------------------------------------------------\r\nFollow WWE on YouTube for more exciting action!\r\n---------------------------------------------------------------------\r\nSubscribe to WWE on YouTube: http://wwe.yt/\r\nCheck out WWE.com for news and updates: http://goo[.]gl/akf0J4\r\nWatch WWE on Sony in India: http://www.wwe.com/SonySportsNetwork\r\nFind the latest Superstar gear at WWEShop: http://shop.wwe.com\r\n---------------------------------------------\r\nCheck out our other channels!\r\n---------------------------------------------\r\nThe Bella Twins: https://www.youtube.com/thebellatwins\r\nUpUpDownDown: https://www.youtube.com/upupdowndown\r\nWWEMusic: https://www.youtube.com/wwemusic\r\nTotal Divas: https://www.youtube.com/wwetotaldivas\r\n------------------------------------\r\nWWE on Social Media\r\n------------------------------------\r\nTwitter: https://twitter.com/wwe\r\nFacebook: https://www.facebook.com/wwe\r\nInstagram: https://www.instagram.com/wwe/\r\nReddit: https://www.reddit.com/user/RealWWE\r\nGiphy: https://giphy.com/wwe\r\n------------------------------------\r\nWWE Podcasts\r\n------------------------------------\r\nAfter the Bell with Corey Graves: https://wwe.com/afterthebell\r\nThe New Day: Feel the Power: https://wwe.com/feelthepower\r\nUncool with Alexa Bliss: https://wwe.com/uncoolwithalexa",
                    "thumbnails": {
                        "default": {
                            "url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/default.jpg",
                            "width": 120,
                            "height": 90
                        },
                        "medium": {
                            "url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/mqdefault.jpg",
                            "width": 320,
                            "height": 180
                        },
                        "high": {
                            "url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/hqdefault.jpg",
                            "width": 480,
                            "height": 360
                        },
                        "standard": {
                            "url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/sddefault.jpg",
                            "width": 640,
                            "height": 480
                        },
                        "maxres": {
                            "url": "https://i.ytimg.com/vi/eJjbnFZ6yA8/maxresdefault.jpg",
                            "width": 1280,
                            "height": 720
                        }
                    },
                    "channelTitle": "WWE",
                    "playlistId": "UUJ5v_MCY6GNUBTO8-D3XoAg",
                    "position": 7765,
                    "resourceId": {
                        "kind": "youtube#video",
                        "videoId": "eJjbnFZ6yA8"
                    },
                    "videoOwnerChannelTitle": "WWE",
                    "videoOwnerChannelId": "UCJ5v_MCY6GNUBTO8-D3XoAg"
                },
                "contentDetails": {
                    "videoId": "eJjbnFZ6yA8",
                    "videoPublishedAt": "2021-01-04T16:00:08Z"
                },
                "status": {
                    "privacyStatus": "public"
                }
            }
        ],
        "pageInfo": {
            "totalResults": 1,
            "resultsPerPage": 50
        }
    }
    

    Initial response (17/02/2022):

    That's a odd result, IMHO. You can follow any of these steps:

    • Get all playlists from a given channel and loop every video in every playlist obtained and compare to the video_id you want to check if it belongs to any playlist found.
    • If the video is not found in any playlist, probably is due the video itself does not belong to any created playlist, but, rather, to the "Uploads" playlist of the owner channel.

    For check the last point I mentioned in my comment and in this answer, you can follow these steps:

    1. Replace the second character of the channel_id from "C" to "U". Example: channel_id: UCJ5v_MCY6GNUBTO8-D3XoAg - once modified, the result is: UUJ5v_MCY6GNUBTO8-D3XoAg = this is the "Upload" playlist_id of the channel UCJ5v_MCY6GNUBTO8-D3XoAg.
    2. With the upload playlist_id, paste it in this URL: https://www.youtube.com/playlist?list=<UPLOAD_PLAYLIST_ID_OF_THE_CHANNEL>

    Result:

    https://www.youtube.com/playlist?list=UUJ5v_MCY6GNUBTO8-D3XoAg
    

    Then, you can yield the default "uploads" playlist of the given channel and their videos in it.


    N.B that some videos (including probably the video_id you supplied) might not appear in any playlist, for example, when entering to the "upload playlist" sample (i.e. https://www.youtube.com/playlist?list=UUJ5v_MCY6GNUBTO8-D3XoAg), you might get this message above the playlist itself:

    Unavailable videos are hidden.

    In this case, might be worth it use the YouTube Data API to query the videos in UUJ5v_MCY6GNUBTO8-D3XoAg playlist or double-check if the video in subject in you region is available - in my case, Colombia, I got the message mentioned above, but, probably this wont happen in the US or UK.