Skip to content

Commit

Permalink
Merge pull request #183 from SevereCloud/dev-v2.14.0
Browse files Browse the repository at this point in the history
v2.14.0
  • Loading branch information
SevereCloud authored Apr 8, 2022
2 parents 75a7348 + 69e9790 commit 10f505f
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 1 deletion.
102 changes: 102 additions & 0 deletions api/params/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,3 +1142,105 @@ func (b *VideoSearchBuilder) LegalOwner(v int) *VideoSearchBuilder {
b.Params["legal_owner"] = v
return b
}

// VideoStartStreamingBuilder builder.
//
// https://vk.com/dev/video.startStreaming
type VideoStartStreamingBuilder struct {
api.Params
}

// NewVideoStartStreamingBuilder func.
func NewVideoStartStreamingBuilder() *VideoStartStreamingBuilder {
return &VideoStartStreamingBuilder{api.Params{}}
}

// VideoID parameter.
func (b *VideoStartStreamingBuilder) VideoID(v int) *VideoStartStreamingBuilder {
b.Params["video_id"] = v
return b
}

// Name parameter.
func (b *VideoStartStreamingBuilder) Name(v string) *VideoStartStreamingBuilder {
b.Params["name"] = v
return b
}

// Description parameter.
func (b *VideoStartStreamingBuilder) Description(v string) *VideoStartStreamingBuilder {
b.Params["description"] = v
return b
}

// Wallpost parameter.
func (b *VideoStartStreamingBuilder) Wallpost(v bool) *VideoStartStreamingBuilder {
b.Params["wallpost"] = v
return b
}

// GroupID parameter.
func (b *VideoStartStreamingBuilder) GroupID(v int) *VideoStartStreamingBuilder {
b.Params["group_id"] = v
return b
}

// PrivacyView parameter.
func (b *VideoStartStreamingBuilder) PrivacyView(v []string) *VideoStartStreamingBuilder {
b.Params["privacy_view"] = v
return b
}

// PrivacyComment parameter.
func (b *VideoStartStreamingBuilder) PrivacyComment(v []string) *VideoStartStreamingBuilder {
b.Params["privacy_comment"] = v
return b
}

// NoComments parameter.
func (b *VideoStartStreamingBuilder) NoComments(v bool) *VideoStartStreamingBuilder {
b.Params["no_comments"] = v
return b
}

// CategoryID parameter.
func (b *VideoStartStreamingBuilder) CategoryID(v int) *VideoStartStreamingBuilder {
b.Params["category_id"] = v
return b
}

// Publish parameter.
func (b *VideoStartStreamingBuilder) Publish(v bool) *VideoStartStreamingBuilder {
b.Params["publish"] = v
return b
}

// VideoStopStreamingBuilder builder.
//
// https://vk.com/dev/video.stopStreaming
type VideoStopStreamingBuilder struct {
api.Params
}

// NewVideoStopStreamingBuilder func.
func NewVideoStopStreamingBuilder() *VideoStopStreamingBuilder {
return &VideoStopStreamingBuilder{api.Params{}}
}

// GroupID parameter.
func (b *VideoStopStreamingBuilder) GroupID(v int) *VideoStopStreamingBuilder {
b.Params["group_id"] = v
return b
}

// OwnerID parameter.
func (b *VideoStopStreamingBuilder) OwnerID(v int) *VideoStopStreamingBuilder {
b.Params["owner_id"] = v
return b
}

// VideoID parameter.
func (b *VideoStopStreamingBuilder) VideoID(v int) *VideoStopStreamingBuilder {
b.Params["video_id"] = v
return b
}
42 changes: 42 additions & 0 deletions api/params/video_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,45 @@ func TestVideoSearchBuilder(t *testing.T) {
assert.Equal(t, b.Params["legal"], true)
assert.Equal(t, b.Params["legal_owner"], 1)
}

func TestVideoStartStreamingBuilder(t *testing.T) {
t.Parallel()

b := params.NewVideoStartStreamingBuilder()

b.VideoID(1)
b.Name("text")
b.Description("text")
b.Wallpost(true)
b.GroupID(1)
b.PrivacyView([]string{"text"})
b.PrivacyComment([]string{"text"})
b.NoComments(true)
b.CategoryID(1)
b.Publish(true)

assert.Equal(t, b.Params["video_id"], 1)
assert.Equal(t, b.Params["name"], "text")
assert.Equal(t, b.Params["description"], "text")
assert.Equal(t, b.Params["wallpost"], true)
assert.Equal(t, b.Params["group_id"], 1)
assert.Equal(t, b.Params["privacy_view"], []string{"text"})
assert.Equal(t, b.Params["privacy_comment"], []string{"text"})
assert.Equal(t, b.Params["no_comments"], true)
assert.Equal(t, b.Params["category_id"], 1)
assert.Equal(t, b.Params["publish"], true)
}

func TestVideoStopStreamingBuilder(t *testing.T) {
t.Parallel()

b := params.NewVideoStopStreamingBuilder()

b.GroupID(1)
b.OwnerID(1)
b.VideoID(1)

assert.Equal(t, b.Params["group_id"], 1)
assert.Equal(t, b.Params["owner_id"], 1)
assert.Equal(t, b.Params["video_id"], 1)
}
35 changes: 35 additions & 0 deletions api/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ func (vk *VK) VideoGetCommentsExtended(params Params) (response VideoGetComments
return
}

// VideoLiveGetCategoriesResponse struct.
type VideoLiveGetCategoriesResponse []object.VideoLiveCategory

// VideoLiveGetCategories method.
//
// https://vk.com/dev/video.liveGetCategories
func (vk *VK) VideoLiveGetCategories(params Params) (response VideoLiveGetCategoriesResponse, err error) {
err = vk.RequestUnmarshal("video.liveGetCategories", &response, params)
return
}

// VideoRemoveFromAlbum allows you to remove the video from the album.
//
// https://vk.com/dev/video.removeFromAlbum
Expand Down Expand Up @@ -336,3 +347,27 @@ func (vk *VK) VideoSearchExtended(params Params) (response VideoSearchExtendedRe

return
}

// VideoStartStreamingResponse struct.
type VideoStartStreamingResponse object.VideoLive

// VideoStartStreaming method.
//
// https://vk.com/dev/video.startStreaming
func (vk *VK) VideoStartStreaming(params Params) (response VideoStartStreamingResponse, err error) {
err = vk.RequestUnmarshal("video.startStreaming", &response, params)
return
}

// VideoStopStreamingResponse struct.
type VideoStopStreamingResponse struct {
UniqueViewers int `json:"unique_viewers"`
}

// VideoStopStreaming method.
//
// https://vk.com/dev/video.stopStreaming
func (vk *VK) VideoStopStreaming(params Params) (response VideoStopStreamingResponse, err error) {
err = vk.RequestUnmarshal("video.stopStreaming", &response, params)
return
}
27 changes: 27 additions & 0 deletions api/video_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ func TestVK_VideoGetCommentsExtended(t *testing.T) {
assert.NotEmpty(t, res.Profiles)
}

func TestVK_VideoLiveGetCategories(t *testing.T) {
t.Parallel()

needUserToken(t)

res, err := vkUser.VideoLiveGetCategories(nil)
noError(t, err)

assert.NotEmpty(t, res)
}

func TestVK_VideoReport(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -315,3 +326,19 @@ func TestVK_VideoSearchExtended(t *testing.T) {
assert.NotEmpty(t, res.Count)
assert.NotEmpty(t, res.Items)
}

func TestVK_VideoStartStreaming(t *testing.T) {
t.Parallel()

needUserToken(t)

res, err := vkUser.VideoStartStreaming(nil)
noError(t, err)

assert.NotEmpty(t, res)

_, err = vkUser.VideoStopStreaming(api.Params{
"video_id": res.VideoID,
})
noError(t, err)
}
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ package vksdk

// Module constants.
const (
Version = "2.13.1"
Version = "2.14.0"
API = "5.131"
)
24 changes: 24 additions & 0 deletions object/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,27 @@ type VideoVideoImage struct {
BaseImage
WithPadding BaseBoolInt `json:"with_padding"`
}

// VideoLive struct.
type VideoLive struct {
OwnerID int `json:"owner_id"`
VideoID int `json:"video_id"`
Name string `json:"name"`
Description string `json:"description"`
AccessKey string `json:"access_key"`
Stream VideoLiveStream `json:"stream"`
}

// VideoLiveStream struct.
type VideoLiveStream struct {
URL string `json:"url"`
Key string `json:"key"`
OKMPURL string `json:"okmp_url"`
}

// VideoLiveCategory struct.
type VideoLiveCategory struct {
ID int `json:"id"`
Label string `json:"label"`
Sublist []VideoLiveCategory `json:"sublist,omitempty"`
}

0 comments on commit 10f505f

Please sign in to comment.