Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions examples/apis/get_all_videos_id_with_channel_by_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@

def get_all_videos_id_by_channel(channel_id, limit=50, count=50):
api = pyyoutube.Api(api_key=API_KEY)
res = api.search(channel_id=channel_id, limit=limit, count=count)
next_page = res.nextPageToken
videos = []

while next_page:
next_page = res.nextPageToken
for item in res.items:
if item.id.videoId:
videos.append(item.id.videoId)
videos = []
next_page = None

while True:
res = api.search(
channel_id=channel_id,
limit=limit,
count=count,
page_token=res.nextPageToken,
page_token=next_page,
)

next_page = res.nextPageToken

for item in res.items:
if item.id.videoId:
videos.append(item.id.videoId)

if not next_page:
break

return videos