Обнновлено до .net10
This commit is contained in:
@@ -6,20 +6,19 @@ using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackId}/similar")]
|
||||
public class YGetTrackSimilarBuilder : YRequestBuilder<YResponse<YTrackSimilar>, string>
|
||||
{
|
||||
public YGetTrackSimilarBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string trackId)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackId", trackId }
|
||||
};
|
||||
}
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackId}/similar")]
|
||||
public class YGetTrackSimilarBuilder : YRequestBuilder<YResponse<YTrackSimilar>, string>
|
||||
{
|
||||
public YGetTrackSimilarBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string trackId)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackId", trackId }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,19 @@ using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackId}/supplement")]
|
||||
public class YGetTrackSupplementBuilder : YRequestBuilder<YResponse<YTrackSupplement>, string>
|
||||
{
|
||||
public YGetTrackSupplementBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string trackId)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackId", trackId }
|
||||
};
|
||||
}
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackId}/supplement")]
|
||||
public class YGetTrackSupplementBuilder : YRequestBuilder<YResponse<YTrackSupplement>, string>
|
||||
{
|
||||
public YGetTrackSupplementBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string trackId)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackId", trackId }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,20 @@ using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "tracks")]
|
||||
public class YGetTracksBuilder : YRequestBuilder<YResponse<List<YTrack>>, IEnumerable<string>>
|
||||
{
|
||||
public YGetTracksBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
protected override HttpContent GetContent(IEnumerable<string> trackIds)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
{ "track-ids", string.Join(",", trackIds) },
|
||||
{ "with-positions", "true" }
|
||||
});
|
||||
}
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "tracks")]
|
||||
public class YGetTracksBuilder : YRequestBuilder<YResponse<List<YTrack>>, IEnumerable<string>>
|
||||
{
|
||||
public YGetTracksBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent(IEnumerable<string> trackIds)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
{ "track-ids", string.Join(",", trackIds) },
|
||||
{ "with-positions", "true" }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,33 +6,32 @@ using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "play-audio")]
|
||||
public class YSendTrackInfoBuilder : YRequestBuilder<string, (YTrack track, string from, bool fromCache, string playId, string playlistId, double totalPlayedSeconds, double endPositionSeconds)>
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "play-audio")]
|
||||
public class YSendTrackInfoBuilder : YRequestBuilder<string, (YTrack track, string from, bool fromCache, string playId, string playlistId, double totalPlayedSeconds, double endPositionSeconds)>
|
||||
public YSendTrackInfoBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
public YSendTrackInfoBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent((YTrack track, string from, bool fromCache, string playId, string playlistId, double totalPlayedSeconds, double endPositionSeconds) tuple)
|
||||
{
|
||||
Dictionary<string, string> formData = new() {
|
||||
{ "track_id", tuple.track.Id },
|
||||
{ "from-cache", tuple.fromCache.ToString() },
|
||||
{ "play_id", tuple.playId },
|
||||
{ "uid", Storage.User.Uid },
|
||||
{ "timestamp", DateTime.Now.ToString("o", CultureInfo.InvariantCulture) },
|
||||
{ "client-now", DateTime.Now.ToString("o", CultureInfo.InvariantCulture) },
|
||||
{ "album-id", tuple.track.Albums.FirstOrDefault()?.Id },
|
||||
{ "from", tuple.from },
|
||||
{ "playlist-id", tuple.playlistId },
|
||||
{ "track-length-seconds", ((double)(tuple.track.DurationMs / 1000)).ToString(CultureInfo.InvariantCulture) },
|
||||
{ "total-played-seconds", tuple.totalPlayedSeconds.ToString(CultureInfo.InvariantCulture) },
|
||||
{ "end-position-seconds", tuple.endPositionSeconds.ToString(CultureInfo.InvariantCulture) },
|
||||
};
|
||||
protected override HttpContent GetContent((YTrack track, string from, bool fromCache, string playId, string playlistId, double totalPlayedSeconds, double endPositionSeconds) tuple)
|
||||
{
|
||||
Dictionary<string, string> formData = new() {
|
||||
{ "track_id", tuple.track.Id },
|
||||
{ "from-cache", tuple.fromCache.ToString() },
|
||||
{ "play_id", tuple.playId },
|
||||
{ "uid", storage.User.Uid },
|
||||
{ "timestamp", DateTime.Now.ToString("o", CultureInfo.InvariantCulture) },
|
||||
{ "client-now", DateTime.Now.ToString("o", CultureInfo.InvariantCulture) },
|
||||
{ "album-id", tuple.track.Albums.FirstOrDefault()?.Id },
|
||||
{ "from", tuple.from },
|
||||
{ "playlist-id", tuple.playlistId },
|
||||
{ "track-length-seconds", ((double)(tuple.track.DurationMs / 1000)).ToString(CultureInfo.InvariantCulture) },
|
||||
{ "total-played-seconds", tuple.totalPlayedSeconds.ToString(CultureInfo.InvariantCulture) },
|
||||
{ "end-position-seconds", tuple.endPositionSeconds.ToString(CultureInfo.InvariantCulture) },
|
||||
};
|
||||
|
||||
return new FormUrlEncodedContent(formData);
|
||||
}
|
||||
return new FormUrlEncodedContent(formData);
|
||||
}
|
||||
}
|
||||
@@ -6,38 +6,37 @@ using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
[YRequest(WebRequestMethods.Http.Get, "{src}")]
|
||||
public class YStorageDownloadFileBuilder : YRequestBuilder<YStorageDownloadFile, string>
|
||||
{
|
||||
[YRequest(WebRequestMethods.Http.Get, "{src}")]
|
||||
public class YStorageDownloadFileBuilder : YRequestBuilder<YStorageDownloadFile, string>
|
||||
public YStorageDownloadFileBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
public YStorageDownloadFileBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string src)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "src", src.Split('?')[0] }
|
||||
};
|
||||
}
|
||||
protected override Dictionary<string, string> GetSubstitutions(string src)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "src", src.Split('?')[0] }
|
||||
};
|
||||
}
|
||||
|
||||
protected override NameValueCollection GetQueryParams(string src)
|
||||
{
|
||||
NameValueCollection query = new() {
|
||||
{ "format", "json" }
|
||||
};
|
||||
protected override NameValueCollection GetQueryParams(string src)
|
||||
{
|
||||
NameValueCollection query = new() {
|
||||
{ "format", "json" }
|
||||
};
|
||||
|
||||
src.Split('?')[1]
|
||||
.Split('&')
|
||||
.ToList()
|
||||
.ForEach(p =>
|
||||
{
|
||||
string[] param = p.Split('=');
|
||||
query.Add(param[0], param[1]);
|
||||
});
|
||||
src.Split('?')[1]
|
||||
.Split('&')
|
||||
.ToList()
|
||||
.ForEach(p =>
|
||||
{
|
||||
string[] param = p.Split('=');
|
||||
query.Add(param[0], param[1]);
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@@ -6,27 +6,26 @@ using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Track
|
||||
namespace YandexMusic.API.Requests.Track;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackKey}/download-info")]
|
||||
public class YTrackDownloadInfoBuilder : YRequestBuilder<YResponse<List<YTrackDownloadInfo>>, (string trackKey, bool direct)>
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "tracks/{trackKey}/download-info")]
|
||||
public class YTrackDownloadInfoBuilder : YRequestBuilder<YResponse<List<YTrackDownloadInfo>>, (string trackKey, bool direct)>
|
||||
public YTrackDownloadInfoBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
public YTrackDownloadInfoBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions((string trackKey, bool direct) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackKey", tuple.trackKey }
|
||||
};
|
||||
}
|
||||
protected override Dictionary<string, string> GetSubstitutions((string trackKey, bool direct) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "trackKey", tuple.trackKey }
|
||||
};
|
||||
}
|
||||
|
||||
protected override NameValueCollection GetQueryParams((string trackKey, bool direct) tuple)
|
||||
{
|
||||
return new NameValueCollection {
|
||||
{ "direct", tuple.direct.ToString() }
|
||||
};
|
||||
}
|
||||
protected override NameValueCollection GetQueryParams((string trackKey, bool direct) tuple)
|
||||
{
|
||||
return new NameValueCollection {
|
||||
{ "direct", tuple.direct.ToString() }
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user