Полностью переписанное api
All checks were successful
Release / pack-and-publish (release) Successful in 36s
All checks were successful
Release / pack-and-publish (release) Successful in 36s
This commit is contained in:
@@ -3,58 +3,61 @@ using YandexMusic.API.Models.Track;
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для трека
|
||||
/// Методы-расширения для трека.
|
||||
/// </summary>
|
||||
public static partial class YTrackExtensions
|
||||
public static class YTrackExtensions
|
||||
{
|
||||
public static Task<string> GetLinkAsync(this YTrack track)
|
||||
{
|
||||
return track.Context.API.Track.GetFileLinkAsync(track.Context.Storage, track);
|
||||
}
|
||||
/// <summary>
|
||||
/// Получает прямую ссылку на скачивание трека.
|
||||
/// </summary>
|
||||
public static Task<string?> GetLinkAsync(this YTrack track)
|
||||
=> track.Context.API.Track.GetFileLinkAsync(track);
|
||||
|
||||
/// <summary>
|
||||
/// Сохраняет трек в файл.
|
||||
/// </summary>
|
||||
public static Task SaveAsync(this YTrack track, string filePath)
|
||||
{
|
||||
return track.Context.API.Track.ExtractToFileAsync(track.Context.Storage, track, filePath);
|
||||
}
|
||||
=> track.Context.API.Track.ExtractToFileAsync(track, filePath);
|
||||
|
||||
public static async Task<int> AddLikeAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Library.AddTrackLikeAsync(track.Context.Storage, track))
|
||||
.Result.Revision;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавляет трек в список лайкнутых.
|
||||
/// </summary>
|
||||
public static async Task<int?> AddLikeAsync(this YTrack track)
|
||||
=> await track.Context.API.Library.AddTrackLikeAsync(track);
|
||||
|
||||
public static async Task<int> RemoveLikeAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Library.RemoveTrackLikeAsync(track.Context.Storage, track))
|
||||
.Result.Revision;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаляет трек из списка лайкнутых.
|
||||
/// </summary>
|
||||
public static async Task<int?> RemoveLikeAsync(this YTrack track)
|
||||
=> await track.Context.API.Library.RemoveTrackLikeAsync(track);
|
||||
|
||||
public static async Task<int> AddDislikeAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Library.AddTrackDislikeAsync(track.Context.Storage, track))
|
||||
.Result.Revision;
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавляет трек в список дизлайкнутых.
|
||||
/// </summary>
|
||||
public static async Task<int?> AddDislikeAsync(this YTrack track)
|
||||
=> await track.Context.API.Library.AddTrackDislikeAsync(track);
|
||||
|
||||
public static async Task<int> RemoveDislikeAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Library.RemoveTrackDislikeAsync(track.Context.Storage, track))
|
||||
?.Result.Revision ?? -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаляет трек из списка дизлайкнутых.
|
||||
/// </summary>
|
||||
public static async Task<int?> RemoveDislikeAsync(this YTrack track)
|
||||
=> await track.Context.API.Library.RemoveTrackDislikeAsync(track);
|
||||
|
||||
public static Task<string> SendPlayTrackInfoAsync(this YTrack track, string from, bool fromCache = false, string playId = "", string playlistId = "", double totalPlayedSeconds = 0, double endPositionSeconds = 0)
|
||||
{
|
||||
return track.Context.API.Track.SendPlayTrackInfoAsync(track.Context.Storage, track, from, fromCache, playId, playlistId, totalPlayedSeconds);
|
||||
}
|
||||
/// <summary>
|
||||
/// Отправляет информацию о воспроизведении трека.
|
||||
/// </summary>
|
||||
public static Task<string?> SendPlayTrackInfoAsync(this YTrack track, string from, bool fromCache = false, string playId = "", string playlistId = "", double totalPlayedSeconds = 0, double endPositionSeconds = 0)
|
||||
=> track.Context.API.Track.SendPlayTrackInfoAsync(track, from, fromCache, playId, playlistId, totalPlayedSeconds, endPositionSeconds);
|
||||
|
||||
public static async Task<YTrackSupplement> SupplementAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Track.GetSupplementAsync(track.Context.Storage, track))
|
||||
.Result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получает дополнительную информацию о треке.
|
||||
/// </summary>
|
||||
public static async Task<YTrackSupplement?> SupplementAsync(this YTrack track)
|
||||
=> await track.Context.API.Track.GetSupplementAsync(track);
|
||||
|
||||
public static async Task<YTrackSimilar> SimilarAsync(this YTrack track)
|
||||
{
|
||||
return (await track.Context.API.Track.GetSimilarAsync(track.Context.Storage, track))
|
||||
.Result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получает похожие треки.
|
||||
/// </summary>
|
||||
public static async Task<YTrackSimilar?> SimilarAsync(this YTrack track)
|
||||
=> await track.Context.API.Track.GetSimilarAsync(track);
|
||||
}
|
||||
Reference in New Issue
Block a user