using System.Text.Json.Serialization;
namespace Jellyfin.Plugin.YandexMusic.Yandex;
/// Generic Yandex API envelope.
public sealed class YandexResponse
{
[JsonPropertyName("result")]
public T? Result { get; set; }
[JsonPropertyName("error")]
public YandexError? Error { get; set; }
}
/// Yandex API error.
public sealed class YandexError
{
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("message")]
public string? Message { get; set; }
}
/// Search response.
public sealed class SearchResponse
{
[JsonPropertyName("result")]
public SearchResult? Result { get; set; }
}
/// Search result container.
public sealed class SearchResult
{
[JsonPropertyName("tracks")]
public SearchPage? Tracks { get; set; }
[JsonPropertyName("albums")]
public SearchPage? Albums { get; set; }
[JsonPropertyName("artists")]
public SearchPage? Artists { get; set; }
}
/// A page of search results.
public sealed class SearchPage
{
[JsonPropertyName("results")]
public List Results { get; set; } = [];
[JsonPropertyName("total")]
public int Total { get; set; }
}
/// Cover object.
public sealed class CoverDto
{
[JsonPropertyName("uri")]
public string? Uri { get; set; }
[JsonPropertyName("color")]
public string? Color { get; set; }
}
/// Track.
public sealed class TrackDto
{
[JsonPropertyName("id")]
[JsonConverter(typeof(FlexibleLongConverter))]
public long Id { get; set; }
[JsonPropertyName("realId")]
public string? RealId { get; set; }
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("durationMs")]
public long? DurationMs { get; set; }
[JsonPropertyName("coverUri")]
public string? CoverUri { get; set; }
[JsonPropertyName("ogImage")]
public string? OgImage { get; set; }
[JsonPropertyName("explicit")]
public bool Explicit { get; set; }
[JsonPropertyName("lyricsAvailable")]
public bool LyricsAvailable { get; set; }
[JsonPropertyName("lyricsInfo")]
public LyricsInfoDto? LyricsInfo { get; set; }
[JsonPropertyName("artists")]
public List Artists { get; set; } = [];
[JsonPropertyName("albums")]
public List Albums { get; set; } = [];
[JsonPropertyName("major")]
public LabelDto? Major { get; set; }
}
/// Lyrics availability info.
public sealed class LyricsInfoDto
{
[JsonPropertyName("hasLyrics")]
public bool HasLyrics { get; set; }
[JsonPropertyName("hasAvailableSyncLyrics")]
public bool HasAvailableSyncLyrics { get; set; }
[JsonPropertyName("hasAvailableTextLyrics")]
public bool HasAvailableTextLyrics { get; set; }
}
/// Album or label reference.
public sealed class AlbumDto
{
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("year")]
public int? Year { get; set; }
[JsonPropertyName("releaseDate")]
public string? ReleaseDate { get; set; }
[JsonPropertyName("genre")]
public string? Genre { get; set; }
[JsonPropertyName("metaType")]
public string? MetaType { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }
[JsonPropertyName("coverUri")]
public string? CoverUri { get; set; }
[JsonPropertyName("ogImage")]
public string? OgImage { get; set; }
[JsonPropertyName("trackCount")]
public int? TrackCount { get; set; }
[JsonPropertyName("artists")]
public List Artists { get; set; } = [];
[JsonPropertyName("labels")]
[JsonConverter(typeof(LabelListConverter))]
public List Labels { get; set; } = [];
[JsonPropertyName("volumes")]
public List> Volumes { get; set; } = [];
[JsonPropertyName("explicit")]
public bool? Explicit { get; set; }
}
/// Label.
public sealed class LabelDto
{
[JsonPropertyName("id")]
[JsonConverter(typeof(FlexibleLongConverter))]
public long Id { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
}
/// Artist.
public sealed class ArtistDto
{
[JsonPropertyName("id")]
[JsonConverter(typeof(FlexibleLongConverter))]
public long Id { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("cover")]
public CoverDto? Cover { get; set; }
[JsonPropertyName("ogImage")]
public string? OgImage { get; set; }
[JsonPropertyName("genres")]
public List Genres { get; set; } = [];
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("counts")]
public ArtistCountsDto? Counts { get; set; }
[JsonPropertyName("links")]
public List Links { get; set; } = [];
}
/// Artist counters.
public sealed class ArtistCountsDto
{
[JsonPropertyName("tracks")]
public int Tracks { get; set; }
[JsonPropertyName("directAlbums")]
public int DirectAlbums { get; set; }
}
/// Artist link.
public sealed class ArtistLinkDto
{
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("href")]
public string? Href { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }
[JsonPropertyName("socialNetwork")]
public string? SocialNetwork { get; set; }
}
/// Response of /artists/{id}.
public sealed class ArtistDetailResponse
{
[JsonPropertyName("artist")]
public ArtistDto? Artist { get; set; }
[JsonPropertyName("albums")]
public List Albums { get; set; } = [];
[JsonPropertyName("similarArtists")]
public List SimilarArtists { get; set; } = [];
[JsonPropertyName("allCovers")]
public List AllCovers { get; set; } = [];
}
/// Response of /artists/{id}/info.
public sealed class ArtistInfoResponse
{
[JsonPropertyName("artist")]
public ArtistDto? Artist { get; set; }
[JsonPropertyName("description")]
public string? Description { get; set; }
[JsonPropertyName("covers")]
public List Covers { get; set; } = [];
[JsonPropertyName("links")]
public List Links { get; set; } = [];
[JsonPropertyName("likesCount")]
public long? LikesCount { get; set; }
}
/// Response of /artists/{id}/brief-info.
public sealed class ArtistBriefResponse
{
[JsonPropertyName("result")]
public ArtistBriefDto? Result { get; set; }
}
/// Brief artist info.
public sealed class ArtistBriefDto
{
[JsonPropertyName("artist")]
public ArtistDto? Artist { get; set; }
[JsonPropertyName("similarArtists")]
public List SimilarArtists { get; set; } = [];
[JsonPropertyName("allCovers")]
public List AllCovers { get; set; } = [];
[JsonPropertyName("albums")]
public List Albums { get; set; } = [];
}
/// Genre tree node.
public sealed class GenreDto
{
[JsonPropertyName("id")]
public string? Id { get; set; }
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("titles")]
public Dictionary Titles { get; set; } = [];
[JsonPropertyName("subGenres")]
public List SubGenres { get; set; } = [];
}
/// Localized genre title.
public sealed class GenreTitleDto
{
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("fullTitle")]
public string? FullTitle { get; set; }
}
/// Track supplement response.
public sealed class SupplementResponse
{
[JsonPropertyName("result")]
public SupplementDto? Result { get; set; }
}
/// Track supplement payload.
public sealed class SupplementDto
{
[JsonPropertyName("lyrics")]
public SupplementLyricsDto? Lyrics { get; set; }
}
/// Lyrics contained in a track supplement.
public sealed class SupplementLyricsDto
{
[JsonPropertyName("lyrics")]
public string? Lyrics { get; set; }
[JsonPropertyName("fullLyrics")]
public string? FullLyrics { get; set; }
}
/// Lyrics lookup response.
public sealed class LyricsResponse
{
[JsonPropertyName("result")]
public LyricsResultDto? Result { get; set; }
}
/// Lyrics download info.
public sealed class LyricsResultDto
{
[JsonPropertyName("downloadUrl")]
public string? DownloadUrl { get; set; }
[JsonPropertyName("writers")]
public List Writers { get; set; } = [];
[JsonPropertyName("lyricId")]
public long? LyricId { get; set; }
}
/// OAuth device code response.
public sealed class DeviceCodeResponse
{
[JsonPropertyName("device_code")]
public string DeviceCode { get; set; } = string.Empty;
[JsonPropertyName("user_code")]
public string UserCode { get; set; } = string.Empty;
[JsonPropertyName("verification_url")]
public string VerificationUrl { get; set; } = string.Empty;
[JsonPropertyName("expires_in")]
public int ExpiresIn { get; set; }
[JsonPropertyName("interval")]
public int Interval { get; set; }
}
/// OAuth token response.
public sealed class OAuthTokenResponse
{
[JsonPropertyName("access_token")]
public string? AccessToken { get; set; }
[JsonPropertyName("refresh_token")]
public string? RefreshToken { get; set; }
[JsonPropertyName("expires_in")]
public int? ExpiresIn { get; set; }
[JsonPropertyName("token_type")]
public string? TokenType { get; set; }
[JsonPropertyName("error")]
public string? Error { get; set; }
[JsonPropertyName("error_description")]
public string? ErrorDescription { get; set; }
}