diff --git a/cmd/video/getRating.go b/cmd/video/getRating.go index 51eab60..84c5d88 100644 --- a/cmd/video/getRating.go +++ b/cmd/video/getRating.go @@ -13,6 +13,7 @@ var getRatingCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { v := yutuber.NewVideo( yutuber.WithVideoId(id), + yutuber.WithVideoOnBehalfOfContentOwner(onBehalfOfContentOwner), ) v.GetRating() }, @@ -22,5 +23,6 @@ func init() { videoCmd.AddCommand(getRatingCmd) getRatingCmd.Flags().StringVarP(&id, "id", "i", "", "ID of the video") + getRatingCmd.Flags().StringVarP(&onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "") getRatingCmd.MarkFlagRequired("id") } diff --git a/cmd/video/insert.go b/cmd/video/insert.go index 8102a49..ca1d1a1 100644 --- a/cmd/video/insert.go +++ b/cmd/video/insert.go @@ -22,7 +22,7 @@ var insertCmd = &cobra.Command{ yutuber.WithVideoThumbnail(thumbnail), yutuber.WithVideoChannelId(channelId), yutuber.WithVideoPlaylistId(playListId), - yutuber.WithVideoCategory(category), + yutuber.WithVideoCategory(categoryId), yutuber.WithVideoPrivacy(privacy), yutuber.WithVideoForKids(forKids), yutuber.WithVideoEmbeddable(embeddable), @@ -50,7 +50,7 @@ func init() { insertCmd.Flags().StringVarP(&thumbnail, "thumbnail", "u", "", "Path to the thumbnail") insertCmd.Flags().StringVarP(&channelId, "channelId", "c", "", "Channel ID of the video") insertCmd.Flags().StringVarP(&playListId, "playlistId", "y", "", "Playlist ID of the video") - insertCmd.Flags().StringVarP(&category, "category", "g", "", "Category of the video") + insertCmd.Flags().StringVarP(&categoryId, "categoryId", "g", "", "Category of the video") insertCmd.Flags().StringVarP( &privacy, "privacy", "p", "", "Privacy status of the video: public, private, or unlisted", ) @@ -70,6 +70,6 @@ func init() { insertCmd.MarkFlagRequired("file") insertCmd.MarkFlagRequired("title") - insertCmd.MarkFlagRequired("category") + insertCmd.MarkFlagRequired("categoryId") insertCmd.MarkFlagRequired("privacy") } diff --git a/cmd/video/list.go b/cmd/video/list.go index 1e9cc62..c0d2672 100644 --- a/cmd/video/list.go +++ b/cmd/video/list.go @@ -13,6 +13,15 @@ var listCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { v := yutuber.NewVideo( yutuber.WithVideoId(id), + yutuber.WithVideoChart(chart), + yutuber.WithVideoHl(hl), + yutuber.WithVideoLocale(locale), + yutuber.WithVideoCategory(categoryId), + yutuber.WithVideoRegionCode(regionCode), + yutuber.WithVideoMaxHeight(maxHeight), + yutuber.WithVideoMaxWidth(maxWidth), + yutuber.WithVideoMaxResults(maxResults), + yutuber.WithVideoOnBehalfOfContentOwner(onBehalfOfContentOwner), yutuber.WithVideoRating(rating), ) v.List(parts, output) @@ -24,7 +33,18 @@ func init() { parts := []string{"id", "snippet", "status"} listCmd.Flags().StringVarP(&id, "id", "i", "", "Return videos with the given ids") - listCmd.Flags().StringVarP(&rating, "rating", "r", "", "Return videos liked/disliked by the authenticated user") + listCmd.Flags().StringVarP(&chart, "chart", "c", "", "chartUnspecified or mostPopular") + listCmd.Flags().StringVarP(&hl, "hl", "L", "", "Specifies the localization language") + listCmd.Flags().StringVarP(&locale, "locale", "l", "", "") + listCmd.Flags().StringVarP(&categoryId, "videoCategoryId", "v", "", "Specific to the specified video category") + listCmd.Flags().StringVarP(®ionCode, "regionCode", "r", "", "Specific to the specified region") + listCmd.Flags().Int64VarP(&maxHeight, "maxHeight", "H", 0, "") + listCmd.Flags().Int64VarP(&maxWidth, "maxWidth", "W", 0, "") + listCmd.Flags().Int64VarP( + &maxResults, "maxResults", "n", 5, "Specifies the maximum number of items that should be returned", + ) + listCmd.Flags().StringVarP(&onBehalfOfContentOwner, "onBehalfOfContentOwner", "b", "", "") + listCmd.Flags().StringVarP(&rating, "myRating", "R", "", "Return videos liked/disliked by the authenticated user") listCmd.Flags().StringVarP(&output, "output", "o", "", "Output format: json or yaml") listCmd.Flags().StringArrayVarP(&parts, "parts", "p", parts, "Comma separated parts") } diff --git a/cmd/video/update.go b/cmd/video/update.go index f10023f..8c0e66c 100644 --- a/cmd/video/update.go +++ b/cmd/video/update.go @@ -19,7 +19,7 @@ var updateCmd = &cobra.Command{ yutuber.WithVideoLicense(license), yutuber.WithVideoPlaylistId(playListId), yutuber.WithVideoThumbnail(thumbnail), - yutuber.WithVideoCategory(category), + yutuber.WithVideoCategory(categoryId), yutuber.WithVideoPrivacy(privacy), yutuber.WithVideoEmbeddable(embeddable), ) @@ -38,7 +38,7 @@ func init() { updateCmd.Flags().StringVarP(&license, "license", "L", "youtube", "youtube(default) or creativeCommon") updateCmd.Flags().StringVarP(&thumbnail, "thumbnail", "h", "", "Path to the thumbnail") updateCmd.Flags().StringVarP(&playListId, "playlistId", "y", "", "Playlist ID of the video") - updateCmd.Flags().StringVarP(&category, "category", "g", "", "Category of the video") + updateCmd.Flags().StringVarP(&categoryId, "categoryId", "g", "", "Category of the video") updateCmd.Flags().StringVarP(&privacy, "privacy", "p", "", "Privacy status of the video: public, private or unlisted") updateCmd.Flags().BoolVarP(&embeddable, "embeddable", "e", true, "Whether the video is embeddable") diff --git a/cmd/video/video.go b/cmd/video/video.go index dd9acc8..d2ee079 100644 --- a/cmd/video/video.go +++ b/cmd/video/video.go @@ -12,22 +12,28 @@ var ( file string title string description string + hl string tags []string language string + locale string license string thumbnail string rating string chart string channelId string playListId string - category string + categoryId string privacy string forKids bool embeddable bool output string parts []string publishAt string + regionCode string stabilize string + maxHeight int64 + maxWidth int64 + maxResults int64 notifySubscribers bool publicStatsViewable bool diff --git a/pkg/yutuber/video.go b/pkg/yutuber/video.go index 029544f..083bc9e 100644 --- a/pkg/yutuber/video.go +++ b/pkg/yutuber/video.go @@ -27,20 +27,26 @@ type video struct { file string title string description string + hl string tags []string language string + locale string license string thumbnail string rating string chart string channelId string playlistId string - category string + categoryId string privacy string forKids bool embeddable bool publishAt string + regionCode string stabilize string + maxHeight int64 + maxWidth int64 + maxResults int64 notifySubscribers bool publicStatsViewable bool @@ -75,9 +81,36 @@ func (v *video) get(parts []string) []*youtube.Video { call := service.Videos.List(parts) if v.id != "" { call = call.Id(v.id) - } else if v.rating != "" { + } + if v.chart != "" { + call = call.Chart(v.chart) + } + if v.hl != "" { + call = call.Hl(v.hl) + } + if v.locale != "" { + call = call.Locale(v.locale) + } + if v.categoryId != "" { + call = call.VideoCategoryId(v.categoryId) + } + if v.rating != "" { call = call.MyRating(v.rating) } + if v.regionCode != "" { + call = call.RegionCode(v.regionCode) + } + if v.maxHeight != 0 { + call = call.MaxHeight(v.maxHeight) + } + if v.maxWidth != 0 { + call = call.MaxWidth(v.maxWidth) + } + if v.onBehalfOfContentOwner != "" { + call = call.OnBehalfOfContentOwner(v.onBehalfOfContentOwner) + } + call = call.MaxResults(v.maxResults) + response, err := call.Do() if err != nil { log.Fatalln(errors.Join(errGetVideo, err), v.id) @@ -113,7 +146,7 @@ func (v *video) Insert() { Title: v.title, Description: v.description, Tags: v.tags, - CategoryId: v.category, + CategoryId: v.categoryId, ChannelId: v.channelId, DefaultLanguage: v.language, DefaultAudioLanguage: v.language, @@ -192,8 +225,8 @@ func (v *video) Update() { if v.license != "" { video.Status.License = v.license } - if v.category != "" { - video.Snippet.CategoryId = v.category + if v.categoryId != "" { + video.Snippet.CategoryId = v.categoryId } if v.privacy != "" { video.Status.PrivacyStatus = v.privacy @@ -241,6 +274,9 @@ func (v *video) Rate() { func (v *video) GetRating() { call := service.Videos.GetRating([]string{v.id}) + if v.onBehalfOfContentOwner != "" { + call = call.OnBehalfOfContentOwner(v.onBehalfOfContentOwnerChannel) + } res, err := call.Do() if err != nil { log.Fatalln(errors.Join(errGetRating, err), v.id) @@ -291,6 +327,12 @@ func WithVideoDescription(description string) VideoOption { } } +func WithVideoHl(hl string) VideoOption { + return func(v *video) { + v.hl = hl + } +} + func WithVideoTags(tags []string) VideoOption { return func(v *video) { v.tags = tags @@ -303,6 +345,12 @@ func WithVideoLanguage(language string) VideoOption { } } +func WithVideoLocale(locale string) VideoOption { + return func(v *video) { + v.locale = locale + } +} + func WithVideoLicense(license string) VideoOption { return func(v *video) { v.license = license @@ -339,9 +387,9 @@ func WithVideoEmbeddable(embeddable bool) VideoOption { } } -func WithVideoCategory(category string) VideoOption { +func WithVideoCategory(categoryId string) VideoOption { return func(v *video) { - v.category = category + v.categoryId = categoryId } } @@ -375,12 +423,36 @@ func WithVideoPublishAt(publishAt string) VideoOption { } } +func WithVideoRegionCode(regionCode string) VideoOption { + return func(v *video) { + v.regionCode = regionCode + } +} + func WithVideoStabilize(stabilize string) VideoOption { return func(v *video) { v.stabilize = stabilize } } +func WithVideoMaxHeight(maxHeight int64) VideoOption { + return func(v *video) { + v.maxHeight = maxHeight + } +} + +func WithVideoMaxWidth(maxWidth int64) VideoOption { + return func(v *video) { + v.maxWidth = maxWidth + } +} + +func WithVideoMaxResults(maxResults int64) VideoOption { + return func(v *video) { + v.maxResults = maxResults + } +} + func WithVideoNotifySubscribers(notifySubscribers bool) VideoOption { return func(v *video) { v.notifySubscribers = notifySubscribers diff --git a/pkg/yutuber/videoCategory.go b/pkg/yutuber/videoCategory.go index 39903b2..be4d144 100644 --- a/pkg/yutuber/videoCategory.go +++ b/pkg/yutuber/videoCategory.go @@ -11,7 +11,7 @@ import ( ) var ( - errGetVideoCategory = errors.New("failed to get video category") + errGetVideoCategory = errors.New("failed to get video categoryId") ) type videoCategory struct {