Yandex Music metadata plugin for Jellyfin 12.4
This commit is contained in:
commit
c3dc901337
25 files changed
+3233
No files matched your search
@@ -0,0 +1,99 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
|
||||
namespace Jellyfin.Plugin.YandexMusic.Providers;
|
||||
|
||||
/// <summary>Track external id.</summary>
|
||||
public class YandexMusicTrackExternalId : IExternalId
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ProviderName => Mapping.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key => YandexProviderIds.Track;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ExternalIdMediaType? Type => ExternalIdMediaType.Track;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(IHasProviderIds item) => item is Audio;
|
||||
}
|
||||
|
||||
/// <summary>Album external id.</summary>
|
||||
public class YandexMusicAlbumExternalId : IExternalId
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ProviderName => Mapping.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key => YandexProviderIds.Album;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ExternalIdMediaType? Type => ExternalIdMediaType.Album;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(IHasProviderIds item) => item is MusicAlbum;
|
||||
}
|
||||
|
||||
/// <summary>Artist external id.</summary>
|
||||
public class YandexMusicArtistExternalId : IExternalId
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string ProviderName => Mapping.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Key => YandexProviderIds.Artist;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ExternalIdMediaType? Type => ExternalIdMediaType.Artist;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(IHasProviderIds item) => item is MusicArtist;
|
||||
}
|
||||
|
||||
/// <summary>Links to music.yandex.ru on item pages.</summary>
|
||||
public class YandexMusicExternalUrlProvider : IExternalUrlProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string Name => Mapping.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<string> GetExternalUrls(BaseItem item)
|
||||
{
|
||||
switch (item)
|
||||
{
|
||||
case MusicAlbum album:
|
||||
var albumId = album.GetProviderId(YandexProviderIds.Album);
|
||||
if (!string.IsNullOrEmpty(albumId))
|
||||
{
|
||||
yield return $"https://music.yandex.ru/album/{albumId}";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MusicArtist artist:
|
||||
var artistId = artist.GetProviderId(YandexProviderIds.Artist);
|
||||
if (!string.IsNullOrEmpty(artistId))
|
||||
{
|
||||
yield return $"https://music.yandex.ru/artist/{artistId}";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case Audio audio:
|
||||
var trackId = audio.GetProviderId(YandexProviderIds.Track);
|
||||
var trackAlbumId = audio.GetProviderId(YandexProviderIds.Album);
|
||||
if (!string.IsNullOrEmpty(trackId))
|
||||
{
|
||||
yield return string.IsNullOrEmpty(trackAlbumId)
|
||||
? $"https://music.yandex.ru/track/{trackId}"
|
||||
: $"https://music.yandex.ru/album/{trackAlbumId}/track/{trackId}";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user