-1

I am attempting to get all the videos urls or ids of a particular youtube channel.The youtube data API is not supporting it anymore . https://developers.google.com/youtube/v3/docs/channels#invideoPromotion Referred to this link and came to know that it is depracated.Any help is appreciated.

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
Sweta
  • 63
  • 3
  • 13
  • 1
    If youtube changed its API due to ppl scaping all videos from it we won't be able to help you. We can not fix the API. – Patrick Artner Feb 27 '19 at 09:09
  • https://stackoverflow.com/questions/13358290/how-get-all-videos-from-a-playlist-using-youtube-api This gives videos by playlist id.It is not necessary that all videos are added under any playlist – Sweta Feb 27 '19 at 09:11
  • Possible duplicate of [youtube-api-to-fetch-all-videos-on-a-channel](https://stackoverflow.com/questions/18953499/youtube-api-to-fetch-all-videos-on-a-channel) - this [answer](https://stackoverflow.com/a/44533336/7505395) on it is for python – Patrick Artner Feb 27 '19 at 09:13
  • 1
    If boths duplicates do not fit your need - distinguish your question from those duplicates. Add a [mcve] , read [ask], use the [tour] and show what you did and what exactly does not work. We can not fix youtube - we can only help with your code. – Patrick Artner Feb 27 '19 at 09:16
  • 1
    I am not sure i understand the queston. If you want a list of all the videos in a channel why not just use videos.search what does invideopromotion have to do with anything? – Linda Lawton - DaImTo Feb 27 '19 at 09:30

1 Answers1

0

Firstly you need to get property 'contentDetails.relatedPlaylists.uploads' from channel's json object, it contains ID of playlist with all channel's videos: https://developers.google.com/youtube/v3/docs/channels#contentDetails.relatedPlaylists.uploads

Then next you have to call method 'playlistItems().list(your_options).execute()' with uploads ID and any other options you want: https://developers.google.com/youtube/v3/docs/playlistItems/list

In example, here we get ID of playlist with all uploaded videos:

channel = YOUR_YOUTUBE_KEY.channels().list(id=your_channel_id, part="contentOwnerDetails", maxResults=1).execute()
uploadsID = channel[0]["contentDetails"]["relatedPlaylists"]["uploads"]

And list of 50 uploaded video's:

videosList = YOUR_YOUTUBE_KEY.playlistItems().list(part='snippet', playlistId=uploadsID, maxResults=50).execute()

Keep in mind the fact that maximal value of maxResults option is 50, so you have to build cycle and get next page token from videosList["nextPageToken"] to send next request with "pageToken" option that will allow you to get next 50 videos (cycle must be stopped when videosList["nextPageToken"] == "")

Wishes
  • 51
  • 5