Добавьте файлы проекта.
This commit is contained in:
33
YandexMusic.API/Requests/Ugc/YUgcGetUploadLinkBuilder.cs
Normal file
33
YandexMusic.API/Requests/Ugc/YUgcGetUploadLinkBuilder.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Models.Ugc;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Ugc
|
||||
{
|
||||
[YWebApiRequest(WebRequestMethods.Http.Get, "handlers/ugc-upload.jsx")]
|
||||
public class YUgcGetUploadLinkBuilder : YRequestBuilder<YUgcUpload, (YPlaylist playlist, string fileName)>
|
||||
{
|
||||
private static readonly Lazy<Random> Random = new(() => new Random());
|
||||
|
||||
public YUgcGetUploadLinkBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override NameValueCollection GetQueryParams((YPlaylist playlist, string fileName) tuple)
|
||||
{
|
||||
return new NameValueCollection {
|
||||
{ "filename", tuple.fileName },
|
||||
{ "kind", tuple.playlist.Kind },
|
||||
{ "visibility", "private" },
|
||||
{ "external-domain", "music.yandex.ru" },
|
||||
{ "ncrnd", Random.Value.NextDouble().ToString(CultureInfo.InvariantCulture) }
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
32
YandexMusic.API/Requests/Ugc/YUgcUploadBuilder.cs
Normal file
32
YandexMusic.API/Requests/Ugc/YUgcUploadBuilder.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Ugc
|
||||
{
|
||||
[YRequest(WebRequestMethods.Http.Post, "{postTargetLink}")]
|
||||
public class YUgcUploadBuilder : YRequestBuilder<YResponse<string>, (string postTargetLink, byte[] fileBytes)>
|
||||
{
|
||||
public YUgcUploadBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions((string postTargetLink, byte[] fileBytes) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "postTargetLink", tuple.postTargetLink }
|
||||
};
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent((string postTargetLink, byte[] fileBytes) tuple)
|
||||
{
|
||||
return new MultipartFormDataContent {
|
||||
{ new ByteArrayContent(tuple.fileBytes), "file" }
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user