Skip to content

Commit 104c2fe

Browse files
committed
"Updating samples to reflect recent changes."
1 parent 05e8907 commit 104c2fe

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

go/my_uploads.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ func main() {
2121
log.Fatalf("Error creating YouTube client: %v", err)
2222
}
2323

24-
// Starting making YouTube API calls
24+
// Start making YouTube API calls.
25+
// Call the channels.list method. Set the mine parameter to true to
26+
// retrieve the playlist ID for uploads to the authenticated user's
27+
// channel.
2528
call := service.Channels.List("contentDetails").Mine(true)
2629

2730
response, err := call.Do()
2831
if err != nil {
32+
// The channels.list method call returned an error.
2933
log.Fatalf("Error making API call to list channels: %v", err.Error())
3034
}
3135

3236
for _, channel := range response.Items {
3337
playlistId := channel.ContentDetails.RelatedPlaylists.Uploads
38+
// Print the playlist ID for the list of uploaded videos.
3439
fmt.Printf("Videos in list %s\r\n", playlistId)
3540

3641
nextPageToken := ""
3742
for {
43+
// Call the playlistItems.list method to retrieve the
44+
// list of uploaded videos. Each request retrieves 50
45+
// videos until all videos have been retrieved.
3846
playlistCall := service.PlaylistItems.List("snippet").
3947
PlaylistId(playlistId).
4048
MaxResults(50).
@@ -43,6 +51,7 @@ func main() {
4351
playlistResponse, err := playlistCall.Do()
4452

4553
if err != nil {
54+
// The playlistItems.list method call returned an error.
4655
log.Fatalf("Error fetching playlist items: %v", err.Error())
4756
}
4857

@@ -52,6 +61,8 @@ func main() {
5261
fmt.Printf("%v, (%v)\r\n", title, videoId)
5362
}
5463

64+
// Set the token to retrieve the next page of results
65+
// or exit the loop if all results have been retrieved.
5566
nextPageToken = playlistResponse.NextPageToken
5667
if nextPageToken == "" {
5768
break

0 commit comments

Comments
 (0)