0

I'm attempting to download videos from a particular YouTube channel. I am starting with the video_id and trying to work back unsuccessfully to get to the channel_id, and then eventually a listing of videos on the channel.

Here is my code:

def gather_videos(api_key):
    youtube = build('youtube', 'v3', developerKey=api_key)

    video_id = [video_id]
    request = youtube.videos().list(
        part=['statistics', 'contentDetails', 'snippet', 'id'],
        id=video_id
    )
    response = request.execute()

From this, I am able to retrieve the channel_id in the response (json), but I cannot seem to make the link to an API call to retrive the full listing. I have reviewed the API documentation here (https://developers.google.com/youtube/v3/docs/channels/list), but I am a novice at interpreting the details. Is it even possible to go this route? Or will I need to conduct a search? Or perhaps use the fact I am subscribed to the channel and try to obtain the listing this way?

C. Cooney
  • 471
  • 5
  • 19
  • If this question is about *how to write the code*, then please read [mre] and try to explain clearly: what happens when you try the code? What is supposed to happen instead, and how is that different? If your question is purely about *what the API supports*, then instead please try reading the documentation or posting on a more appropriate Stack Exchange site - perhaps [webapps.se]. – Karl Knechtel Jul 05 '22 at 22:06

2 Answers2

1

To download videos of a given YouTube channel use YouTube DL this way:

youtube-dl -i https://www.youtube.com/channel/CHANNEL_ID

If you are interested to have the playlist video metadata through the YouTube Data API v3 then this answer will meet your needs.

-i, --ignore-errors

Continue on download errors, for example to skip unavailable videos in a playlist

Source: https://github.com/ytdl-org/youtube-dl/blob/master/README.md#options

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
0

I utilized the following code to obtain a search list containing videos hosted on the channel:

request = youtube.search().list(
        part=['snippet'],
        channelId=channel_id,
    )
C. Cooney
  • 471
  • 5
  • 19
  • 1
    FYI your method costs 100 quota while [mine](https://stackoverflow.com/a/72876665/7123660) costs only 2 quota (knowing that you have 10,000 quota per day by default). – Benjamin Loison Jul 06 '22 at 09:22