diff --git a/VkNet/Abstractions/Category/Async/IShortVideoCategoryAsync.cs b/VkNet/Abstractions/Category/Async/IShortVideoCategoryAsync.cs new file mode 100644 index 000000000..cf3bedcd2 --- /dev/null +++ b/VkNet/Abstractions/Category/Async/IShortVideoCategoryAsync.cs @@ -0,0 +1,31 @@ +using System.Threading; +using System.Threading.Tasks; +using VkNet.Model; + +namespace VkNet.Abstractions; + +/// +/// ShortVideo В этой секции представлены методы, +/// предназначенные для работы с Клипами +/// +public interface IShortVideoCategoryAsync +{ + /// + /// Получает ссылку для загрузки Клипа + /// + /// Описание клипа + /// Токен отмены + /// Размер файла в КБ, если файл меньше 16384 кб, то указывать не обязательно + /// ID группы, если нужно выкладывать от имени группы + /// Нужно ли выкладывать клип на стену + /// + /// + /// + /// Страница документации ВКонтакте http://vk.com/dev/shortVideo.create + /// + Task CreateAsync(string description, + ulong fileSize = 16384, + long? groupId = null, + bool? wallPost = null, + CancellationToken token = default); +} \ No newline at end of file diff --git a/VkNet/Abstractions/Category/IShortVideoCategory.cs b/VkNet/Abstractions/Category/IShortVideoCategory.cs new file mode 100644 index 000000000..e6e345d48 --- /dev/null +++ b/VkNet/Abstractions/Category/IShortVideoCategory.cs @@ -0,0 +1,13 @@ +using VkNet.Model; + +namespace VkNet.Abstractions; + +/// +public interface IShortVideoCategory : IShortVideoCategoryAsync +{ + /// + ShortVideoUploadServer Create(string description, + ulong fileSize = 16384, + long? groupId = null, + bool? wallPost = null); +} \ No newline at end of file diff --git a/VkNet/Abstractions/Core/IVkApiCategories.cs b/VkNet/Abstractions/Core/IVkApiCategories.cs index 3b4e6e9db..4c60992ca 100644 --- a/VkNet/Abstractions/Core/IVkApiCategories.cs +++ b/VkNet/Abstractions/Core/IVkApiCategories.cs @@ -228,4 +228,9 @@ public interface IVkApiCategories /// Asr /// IAsrCategory Asr { get; } + + /// + /// ShortVideo + /// + IShortVideoCategory ShortVideo { get; } } \ No newline at end of file diff --git a/VkNet/Categories/Async/ShortVideoCategoryAsync.cs b/VkNet/Categories/Async/ShortVideoCategoryAsync.cs new file mode 100644 index 000000000..81fc049d2 --- /dev/null +++ b/VkNet/Categories/Async/ShortVideoCategoryAsync.cs @@ -0,0 +1,19 @@ +using System.Threading; +using System.Threading.Tasks; +using VkNet.Model; +using VkNet.Utils; + +namespace VkNet.Categories; + +/// +public partial class ShortVideoCategory +{ + /// + public Task CreateAsync(string description, + ulong fileSize = 16384, + long? groupId = null, + bool? wallPost = null, + CancellationToken token = default) => + TypeHelper.TryInvokeMethodAsync(() => + Create(description, fileSize, groupId, wallPost), token); +} \ No newline at end of file diff --git a/VkNet/Categories/ShortVideoCategory.cs b/VkNet/Categories/ShortVideoCategory.cs new file mode 100644 index 000000000..009c17b1a --- /dev/null +++ b/VkNet/Categories/ShortVideoCategory.cs @@ -0,0 +1,40 @@ +using VkNet.Abstractions; +using VkNet.Model; + +namespace VkNet.Categories; + +/// +public partial class ShortVideoCategory : IShortVideoCategory +{ + /// + /// API. + /// + private readonly IVkApiInvoke _vk; + + /// + /// api vk.com + /// + /// API. + public ShortVideoCategory(IVkApiInvoke vk) => _vk = vk; + + /// + public ShortVideoUploadServer Create(string description, + ulong fileSize = 16384, + long? groupId = null, + bool? wallPost = null) => _vk.Call("shortVideo.create", + new() + { + { + "group_id", groupId + }, + { + "description", description + }, + { + "wall_post", wallPost + }, + { + "file_size", fileSize + } + }); +} \ No newline at end of file diff --git a/VkNet/Model/Results/ShortVideo/ShortVideoUploadServer.cs b/VkNet/Model/Results/ShortVideo/ShortVideoUploadServer.cs new file mode 100644 index 000000000..0adfac5a4 --- /dev/null +++ b/VkNet/Model/Results/ShortVideo/ShortVideoUploadServer.cs @@ -0,0 +1,29 @@ +using System; +using Newtonsoft.Json; + +namespace VkNet.Model; + +/// +/// Результат метода ShortVideo.Create +/// +[Serializable] +public class ShortVideoUploadServer +{ + /// + /// Адрес для загрузки Клипа + /// + [JsonProperty("upload_url")] + public Uri UploadUrl { get; set; } + + /// + /// Идентификатор владельца Клипа + /// + [JsonProperty("owner_id")] + public long? OwnerId { get; set; } + + /// + /// Идентификатор Клипа + /// + [JsonProperty("video_id")] + public long? VideoId { get; set; } +} \ No newline at end of file diff --git a/VkNet/VkApi.cs b/VkNet/VkApi.cs index 2d91960b9..45656872c 100644 --- a/VkNet/VkApi.cs +++ b/VkNet/VkApi.cs @@ -735,6 +735,9 @@ public int MaxCaptchaRecognitionCount /// public IAsrCategory Asr { get; set; } + /// + public IShortVideoCategory ShortVideo { get; set; } + #endregion #region private @@ -1002,6 +1005,7 @@ private void Initialization(IServiceProvider serviceProvider) Donut = new DonutCategory(this); DownloadedGames = new DownloadedGamesCategory(this); Asr = new AsrCategory(this); + ShortVideo = new ShortVideoCategory(this); RequestsPerSecond = 3;