Skip to content

Commit

Permalink
Добавляет категорию ShortVideo
Browse files Browse the repository at this point in the history
  • Loading branch information
Panuchi committed Jul 28, 2023
1 parent 48ecf27 commit 8a310f3
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 0 deletions.
31 changes: 31 additions & 0 deletions VkNet/Abstractions/Category/Async/IShortVideoCategoryAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Threading;
using System.Threading.Tasks;
using VkNet.Model;

namespace VkNet.Abstractions;

/// <summary>
/// ShortVideo В этой секции представлены методы,
/// предназначенные для работы с Клипами
/// </summary>
public interface IShortVideoCategoryAsync
{
/// <summary>
/// Получает ссылку для загрузки Клипа
/// </summary>
/// <param name="description">Описание клипа</param>
/// <param name="token">Токен отмены</param>
/// <param name="fileSize">Размер файла в КБ, если файл меньше 16384 кб, то указывать не обязательно</param>
/// <param name="groupId">ID группы, если нужно выкладывать от имени группы</param>
/// <param name="wallPost">Нужно ли выкладывать клип на стену</param>
/// <returns>
/// </returns>
/// <remarks>
/// Страница документации ВКонтакте http://vk.com/dev/shortVideo.create
/// </remarks>
Task<ShortVideoUploadServer> CreateAsync(string description,
ulong fileSize = 16384,
long? groupId = null,
bool? wallPost = null,
CancellationToken token = default);
}
13 changes: 13 additions & 0 deletions VkNet/Abstractions/Category/IShortVideoCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using VkNet.Model;

namespace VkNet.Abstractions;

/// <inheritdoc cref="IShortVideoCategoryAsync"/>
public interface IShortVideoCategory : IShortVideoCategoryAsync
{
/// <inheritdoc cref="IShortVideoCategoryAsync.CreateAsync"/>
ShortVideoUploadServer Create(string description,
ulong fileSize = 16384,
long? groupId = null,
bool? wallPost = null);
}
5 changes: 5 additions & 0 deletions VkNet/Abstractions/Core/IVkApiCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,9 @@ public interface IVkApiCategories
/// Asr
/// </summary>
IAsrCategory Asr { get; }

/// <summary>
/// ShortVideo
/// </summary>
IShortVideoCategory ShortVideo { get; }
}
19 changes: 19 additions & 0 deletions VkNet/Categories/Async/ShortVideoCategoryAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Threading;
using System.Threading.Tasks;
using VkNet.Model;
using VkNet.Utils;

namespace VkNet.Categories;

/// <inheritdoc />
public partial class ShortVideoCategory
{
/// <inheritdoc/>
public Task<ShortVideoUploadServer> CreateAsync(string description,
ulong fileSize = 16384,
long? groupId = null,
bool? wallPost = null,
CancellationToken token = default) =>
TypeHelper.TryInvokeMethodAsync(() =>
Create(description, fileSize, groupId, wallPost), token);
}
40 changes: 40 additions & 0 deletions VkNet/Categories/ShortVideoCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using VkNet.Abstractions;
using VkNet.Model;

namespace VkNet.Categories;

/// <inheritdoc />
public partial class ShortVideoCategory : IShortVideoCategory
{
/// <summary>
/// API.
/// </summary>
private readonly IVkApiInvoke _vk;

/// <summary>
/// api vk.com
/// </summary>
/// <param name="vk"> API. </param>
public ShortVideoCategory(IVkApiInvoke vk) => _vk = vk;

/// <inheritdoc/>
public ShortVideoUploadServer Create(string description,
ulong fileSize = 16384,
long? groupId = null,
bool? wallPost = null) => _vk.Call<ShortVideoUploadServer>("shortVideo.create",
new()
{
{
"group_id", groupId
},
{
"description", description
},
{
"wall_post", wallPost
},
{
"file_size", fileSize
}
});
}
29 changes: 29 additions & 0 deletions VkNet/Model/Results/ShortVideo/ShortVideoUploadServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using Newtonsoft.Json;

namespace VkNet.Model;

/// <summary>
/// Результат метода ShortVideo.Create
/// </summary>
[Serializable]
public class ShortVideoUploadServer
{
/// <summary>
/// Адрес для загрузки Клипа
/// </summary>
[JsonProperty("upload_url")]
public Uri UploadUrl { get; set; }

/// <summary>
/// Идентификатор владельца Клипа
/// </summary>
[JsonProperty("owner_id")]
public long? OwnerId { get; set; }

/// <summary>
/// Идентификатор Клипа
/// </summary>
[JsonProperty("video_id")]
public long? VideoId { get; set; }
}
4 changes: 4 additions & 0 deletions VkNet/VkApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ public int MaxCaptchaRecognitionCount
/// <inheritdoc />
public IAsrCategory Asr { get; set; }

/// <inheritdoc />
public IShortVideoCategory ShortVideo { get; set; }

#endregion

#region private
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8a310f3

Please sign in to comment.