Compare commits
3 Commits
v0.0.5
...
50da85be57
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50da85be57 | ||
|
|
699d38da74 | ||
|
|
1779ecaca9 |
@@ -8,9 +8,9 @@ internal class Program
|
||||
var type = await client.Authorize("y0__xDy2budARje-AYg7rmliBc11LbYoMeUiwiO6f6mSCAMDYVIKg");
|
||||
var playlists = (await client.GetFavoritesAsync()).Where(t => t.Owner.Uid == client.Account.Uid).ToList();
|
||||
var playlist = await client.GetPlaylistAsync("97ae0768-8a40-8485-9fa4-b6c856bc6b21");
|
||||
|
||||
|
||||
var tracks = await client.GetTracksAsync(new[] { "78412759" });
|
||||
await playlist.InsertTracksAsync(tracks.ToArray());
|
||||
var tracks = playlist.Tracks.Where(t => t.Id == "21696942").Select(t => t.Track).ToArray();
|
||||
var x = await playlist.RemoveTracksAsync(tracks);
|
||||
Console.WriteLine($"TC: {playlist.TrackCount}; {playlist.Title}");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,7 @@ public class YPlaylistAPI : YCommonAPI
|
||||
public Task<YResponse<YPlaylist>> DeleteTracksAsync(AuthStorage storage, YPlaylist playlist, IEnumerable<YTrack> tracks)
|
||||
{
|
||||
var distinctTracks = tracks.Distinct().ToList();
|
||||
|
||||
var changes = distinctTracks
|
||||
.Select(t => playlist.Tracks?.FindIndex(ct => ct.Track?.GetKey() == t.GetKey()) ?? -1)
|
||||
.Where(i => i != -1)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
namespace YandexMusic.API.Common.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Провайдер запросов данными из файла
|
||||
/// </summary>
|
||||
public class MockRequestProvider : CommonRequestProvider
|
||||
{
|
||||
|
||||
|
||||
public MockRequestProvider(AuthStorage authStorage) : base(authStorage)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region IRequestProvider
|
||||
|
||||
public override Task<HttpResponseMessage> GetWebResponseAsync(HttpRequestMessage message,
|
||||
HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion IRequestProvider
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using YandexMusic.API.Models.Album;
|
||||
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для альбома
|
||||
/// </summary>
|
||||
public static partial class YAlbumExtensions
|
||||
{
|
||||
public static YAlbum WithTracks(this YAlbum album)
|
||||
{
|
||||
return WithTracksAsync(album).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string AddLike(this YAlbum album)
|
||||
{
|
||||
return AddLikeAsync(album).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string RemoveLike(this YAlbum album)
|
||||
{
|
||||
return RemoveLikeAsync(album).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using YandexMusic.API.Models.Artist;
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для исполнителя
|
||||
/// </summary>
|
||||
public static partial class YArtistExtensions
|
||||
{
|
||||
public static YArtistBriefInfo BriefInfo(this YArtist artist)
|
||||
{
|
||||
return BriefInfoAsync(artist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YTracksPage GetTracks(this YArtist artist, int page = 0, int pageSize = 20)
|
||||
{
|
||||
return GetTracksAsync(artist, page, pageSize).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static List<YTrack> GetAllTracks(this YArtist artist)
|
||||
{
|
||||
return GetAllTracksAsync(artist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string AddLike(this YArtist artist)
|
||||
{
|
||||
return AddLikeAsync(artist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string RemoveLike(this YArtist artist)
|
||||
{
|
||||
return RemoveLikeAsync(artist).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для плейлиста
|
||||
/// </summary>
|
||||
public static partial class YPlaylistExtensions
|
||||
{
|
||||
private static bool CheckUser(YPlaylist playlist)
|
||||
{
|
||||
return playlist.Owner.Uid == playlist.Context.Storage.User.Uid;
|
||||
}
|
||||
|
||||
public static YPlaylist WithTracks(this YPlaylist playlist)
|
||||
{
|
||||
return WithTracksAsync(playlist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string AddLike(this YPlaylist playlist)
|
||||
{
|
||||
return AddLikeAsync(playlist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string RemoveLike(this YPlaylist playlist)
|
||||
{
|
||||
return RemoveLikeAsync(playlist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YPlaylist Rename(this YPlaylist playlist, string newName)
|
||||
{
|
||||
return RenameAsync(playlist, newName).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static bool Delete(this YPlaylist playlist)
|
||||
{
|
||||
return DeleteAsync(playlist).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YPlaylist InsertTracks(this YPlaylist playlist, params YTrack[] tracks)
|
||||
{
|
||||
return InsertTracksAsync(playlist, tracks).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YPlaylist RemoveTracks(this YPlaylist playlist, params YTrack[] tracks)
|
||||
{
|
||||
return RemoveTracksAsync(playlist, tracks).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static bool UploadTracks(this YPlaylist playlist, string filePath, string fileName)
|
||||
{
|
||||
return UploadTracksAsync(playlist, filePath, fileName).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,11 @@ namespace YandexMusic.API.Extensions.API;
|
||||
/// </summary>
|
||||
public static partial class YPlaylistExtensions
|
||||
{
|
||||
private static bool CheckUser(YPlaylist playlist)
|
||||
{
|
||||
return playlist.Owner.Uid == playlist.Context.Storage.User.Uid;
|
||||
}
|
||||
|
||||
public static async Task<YPlaylist> WithTracksAsync(this YPlaylist playlist)
|
||||
{
|
||||
return playlist.Tracks != null
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using YandexMusic.API.Models.Radio;
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для радиостанции
|
||||
/// </summary>
|
||||
public static partial class YStationResultExtensions
|
||||
{
|
||||
public static List<YSequenceItem> GetTracks(this YStation station, string prevTrackId = "")
|
||||
{
|
||||
return GetTracksAsync(station, prevTrackId).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string SetSettings2(this YStation station, YStationSettings2 settings)
|
||||
{
|
||||
return SetSettings2Async(station, settings).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string SendFeedBack(this YStation station, YStationFeedbackType type, YTrack track = null, string batchId = "", double totalPlayedSeconds = 0)
|
||||
{
|
||||
return SendFeedBackAsync(station, type, track, batchId, totalPlayedSeconds).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using YandexMusic.API.Models.Track;
|
||||
|
||||
namespace YandexMusic.API.Extensions.API;
|
||||
|
||||
/// <summary>
|
||||
/// Методы-расширения для трека
|
||||
/// </summary>
|
||||
public static partial class YTrackExtensions
|
||||
{
|
||||
public static string GetLink(this YTrack track)
|
||||
{
|
||||
return GetLinkAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static void Save(this YTrack track, string filePath)
|
||||
{
|
||||
SaveAsync(track, filePath).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static int AddLike(this YTrack track)
|
||||
{
|
||||
return AddLikeAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static int RemoveLike(this YTrack track)
|
||||
{
|
||||
return RemoveLikeAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static int AddDislike(this YTrack track)
|
||||
{
|
||||
return AddDislikeAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static int RemoveDislike(this YTrack track)
|
||||
{
|
||||
return RemoveDislikeAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static string SendPlayTrackInfo(this YTrack track, string from, bool fromCache = false, string playId = "", string playlistId = "", double totalPlayedSeconds = 0, double endPositionSeconds = 0)
|
||||
{
|
||||
return SendPlayTrackInfoAsync(track, from, fromCache, playId, playlistId, totalPlayedSeconds).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YTrackSupplement Supplement(this YTrack track)
|
||||
{
|
||||
return SupplementAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static YTrackSimilar Similar(this YTrack track)
|
||||
{
|
||||
return SimilarAsync(track).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,16 @@ public class YTrackAlbumPair : IEquatable<YTrackAlbumPair>
|
||||
return string.Join(":", new[] { Id, AlbumId }.Where(s => !string.IsNullOrEmpty(s)));
|
||||
}
|
||||
|
||||
public static bool operator ==(YTrackAlbumPair left, YTrackAlbumPair right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(YTrackAlbumPair left, YTrackAlbumPair right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
public bool Equals(YTrackAlbumPair other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
|
||||
@@ -5,15 +5,11 @@ namespace YandexMusic.API.Requests.Common;
|
||||
|
||||
internal class YRequest<T>
|
||||
{
|
||||
#region Поля
|
||||
|
||||
private HttpRequestMessage msg;
|
||||
private IRequestProvider provider;
|
||||
|
||||
protected YandexMusicApi api;
|
||||
|
||||
#endregion Поля
|
||||
|
||||
public YRequest(HttpRequestMessage message, YandexMusicApi yandex, AuthStorage auth)
|
||||
{
|
||||
msg = message;
|
||||
|
||||
@@ -35,7 +35,19 @@ public class YandexMusicApi
|
||||
/// <summary>Создаёт экземпляр API с инициализацией всех подсистем.</summary>
|
||||
public YandexMusicApi()
|
||||
{
|
||||
foreach (var property in GetType().GetProperties())
|
||||
property.SetValue(this, Activator.CreateInstance(property.PropertyType, this));
|
||||
Album = new YAlbumAPI(this);
|
||||
Artist = new YArtistAPI(this);
|
||||
Label = new YLabelAPI(this);
|
||||
Landing = new YLandingAPI(this);
|
||||
Library = new YLibraryAPI(this);
|
||||
Playlist = new YPlaylistAPI(this);
|
||||
Pins = new YPinsAPI(this);
|
||||
Radio = new YRadioAPI(this);
|
||||
Search = new YSearchAPI(this);
|
||||
Track = new YTrackAPI(this);
|
||||
Queue = new YQueueAPI(this);
|
||||
User = new YUserAPI(this);
|
||||
UserGeneratedContent = new YUgcAPI(this);
|
||||
Ynison = new YYnisonAPI(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user