From 52eadd93917b0c81f5497e94f107e4f3d7aa0263 Mon Sep 17 00:00:00 2001 From: raishid <67575679+raishid@users.noreply.github.com> Date: Wed, 3 Mar 2021 13:05:39 -0400 Subject: [PATCH] get all videos in channel method --- youtube3/youtube_client.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/youtube3/youtube_client.py b/youtube3/youtube_client.py index 8c3103d..cdf7b41 100644 --- a/youtube3/youtube_client.py +++ b/youtube3/youtube_client.py @@ -230,5 +230,27 @@ def verify_video(self, video_id, country='DE'): except: traceback.print_exc() return False + + def Get_all_video_in_channel(self, id_channel): + base_video_url = 'https://www.youtube.com/watch?v=' + video_links = list() + page_token = None + while True: + videos = self.youtube.search().list( + channelId=id_channel, + part='snippet, id', + order='date', + maxResults=25, + pageToken=page_token + ).execute() + + for video in videos['items']: + if video['id']['kind'] == "youtube#video": + video_links.append(base_video_url + video['id']['videoId']) + try: + page_token = videos['nextPageToken'] + except: + break + return video_links