Beispiel #1
0
func findPlaylist(service *youtube.Service, title string) string {
	playlists := youtube.NewPlaylistsService(service)
	playListsCall := playlists.List("snippet")
	playListsCall.Mine(true)
	playlistsResult, err := playListsCall.Do()
	if err != nil {
		log.Fatalf("Error listing playlists: %v", err)
	}

	for _, item := range playlistsResult.Items {
		mlib.DebugDump(item)
		if item.Snippet.Title == title {
			return item.Id
		}
	}
	return ""
}
Beispiel #2
0
func createPlaylist(service *youtube.Service, title string) string {
	playlists := youtube.NewPlaylistsService(service)

	playlist := youtube.Playlist{
		Snippet: &youtube.PlaylistSnippet{
			Title: title,
		},
		Status: &youtube.PlaylistStatus{
			PrivacyStatus: *privacy,
		},
	}

	playListsCall := playlists.Insert("snippet,status", &playlist)
	playlistsResult, err := playListsCall.Do()
	if err != nil {
		log.Fatalf("Error inserting playlist: %v", err)
	}
	mlib.DebugDump(playlistsResult)

	return playlistsResult.Id
}