Skip to content

Commit

Permalink
"Updating samples to reflect recent changes."
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffposnick committed Apr 8, 2014
1 parent 15f01a0 commit 9ed8b79
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions go/my_uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,20 @@ func main() {
log.Fatalf("Error creating YouTube client: %v", err)
}

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

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

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

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

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

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

// Set the token to retrieve the next page of results
// or exit the loop if all results have been retrieved.
nextPageToken = playlistResponse.NextPageToken
if nextPageToken == "" {
break
Expand Down

0 comments on commit 9ed8b79

Please sign in to comment.