2023-11-16 20:15:30 -05:00
|
|
|
package youtube
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"google.golang.org/api/youtube/v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
STATUS_PRIVATE = "private"
|
2023-11-16 20:45:48 -05:00
|
|
|
STATUS_PUBLIC = "public"
|
2023-11-23 12:17:20 -05:00
|
|
|
ISO_8601 = "2006-01-02T15:04:05.000Z"
|
2023-11-16 20:15:30 -05:00
|
|
|
)
|
|
|
|
|
2023-11-16 20:45:48 -05:00
|
|
|
// Inserts Broadcast into youtube
|
2023-11-16 20:15:30 -05:00
|
|
|
func InsertBroadcast(service *youtube.Service, title string, startTime time.Time, privacyStatus string) (*youtube.LiveBroadcast, error) {
|
|
|
|
liveBroadcast := &youtube.LiveBroadcast{
|
|
|
|
Snippet: &youtube.LiveBroadcastSnippet{
|
|
|
|
Title: title,
|
2023-11-23 12:17:20 -05:00
|
|
|
ScheduledStartTime: startTime.Format(ISO_8601),
|
2023-11-16 20:15:30 -05:00
|
|
|
},
|
|
|
|
Status: &youtube.LiveBroadcastStatus{
|
|
|
|
PrivacyStatus: privacyStatus,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return service.LiveBroadcasts.Insert([]string{"snippet", "status"}, liveBroadcast).Do()
|
|
|
|
}
|
2023-11-23 12:17:20 -05:00
|
|
|
|
|
|
|
//given a broadcast ID update the broadcast
|
|
|
|
func UpdateBroadcast(service *youtube.Service, id, title string, startTime time.Time, privacyStatus string) (*youtube.LiveBroadcast, error) {
|
|
|
|
liveBroadcast := &youtube.LiveBroadcast{
|
|
|
|
Id: id,
|
|
|
|
Snippet: &youtube.LiveBroadcastSnippet{
|
|
|
|
Title: title,
|
|
|
|
ScheduledStartTime: startTime.Format(ISO_8601),
|
|
|
|
},
|
|
|
|
Status: &youtube.LiveBroadcastStatus{
|
|
|
|
PrivacyStatus: privacyStatus,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return service.LiveBroadcasts.Update([]string{"snippet", "status"}, liveBroadcast).Do()
|
|
|
|
}
|
|
|
|
|
|
|
|
func DeleteBroadcast(service *youtube.Service, id string) error {
|
|
|
|
return service.LiveBroadcasts.Delete(id).Do()
|
|
|
|
}
|