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 Feb 12, 2014
1 parent 2b48835 commit 4f89d9c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions go/search_by_keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {
log.Fatalf("Error creating new YouTube client: %v", err)
}

// Make the API call to YouTube
// Make the API call to YouTube.
call := service.Search.List("id,snippet").
Q(*query).
MaxResults(*maxResults)
Expand All @@ -38,11 +38,12 @@ func main() {
log.Fatalf("Error making search API call: %v", err)
}

// Group video, channel, and playlist results in separate lists.
videos := make(map[string]string)
channels := make(map[string]string)
playlists := make(map[string]string)

// Iterate through each item and add it to its respective list
// Iterate through each item and add it to the correct list.
for _, item := range response.Items {
switch item.Id.Kind {
case "youtube#video":
Expand All @@ -59,8 +60,10 @@ func main() {
printIDs("Playlists", playlists)
}

// Given a string section name and list, prints the section name
// and IDs separated by commas
// Print the ID and title of each result in a list as well as a name that
// identifies the list. For example, print the word section name "Videos"
// above a list of video search results, followed by the video ID and title
// of each matching video.
func printIDs(sectionName string, matches map[string]string) {
fmt.Printf("%v:\n", sectionName)
for id, title := range matches {
Expand Down

0 comments on commit 4f89d9c

Please sign in to comment.