Files
YandexMusic/YandexMusic.API/Requests/Track/YStorageDownloadFileBuilder.cs
FrigaT 526353d679
All checks were successful
Release / pack-and-publish (release) Successful in 36s
Переделано воспроизведение аудио
2026-04-21 11:14:36 +03:00

37 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Specialized;
using System.Net;
using YandexMusic.API.Models.Common;
using YandexMusic.API.Requests.Common;
namespace YandexMusic.API.Requests.Track;
/// <summary>Особый запрос не к api.music.yandex.net, а к произвольному URL.</summary>
internal class YStorageDownloadFileBuilder : YXmlRequestBuilder<YStorageDownloadFile?, string>
{
public YStorageDownloadFileBuilder(YandexMusicApi api) : base(api) { }
protected override bool ShouldAddAuthorization => false;
protected override string BaseUrl => "{src}"; // не используется, т.к. URL берётся из параметра
protected override string Method => WebRequestMethods.Http.Get;
protected override string PathTemplate => "";
protected override Dictionary<string, string> GetSubstitutions(string src)
=> new() { { "src", src } };
protected override NameValueCollection GetQueryParams(string src)
{
var query = new NameValueCollection();
var parts = src.Split('?');
if (parts.Length > 1)
{
foreach (var param in parts[1].Split('&'))
{
var kv = param.Split('=');
if (kv.Length >= 2) query.Add(kv[0], kv[1]);
}
}
return query;
}
}