jellyfin-server/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs

60 lines
1.8 KiB
C#
Raw Normal View History

using MediaBrowser.Controller.Entities;
2013-03-05 16:48:17 +00:00
using MediaBrowser.Model.Entities;
using System;
namespace MediaBrowser.Controller.Providers.Music
{
public static class LastfmHelper
{
public static string LocalArtistMetaFileName = "MBArtist.json";
2013-03-05 16:48:17 +00:00
public static string LocalAlbumMetaFileName = "MBAlbum.json";
public static void ProcessArtistData(BaseItem artist, LastfmArtist data)
{
var overview = data.bio != null ? data.bio.content : null;
artist.Overview = overview;
2013-03-05 15:45:25 +00:00
var yearFormed = 0;
if (data.bio != null)
2013-03-05 15:45:25 +00:00
{
Int32.TryParse(data.bio.yearformed, out yearFormed);
2013-03-05 15:45:25 +00:00
}
artist.PremiereDate = yearFormed > 0 ? new DateTime(yearFormed, 1,1) : DateTime.MinValue;
artist.ProductionYear = yearFormed;
if (data.tags != null)
{
2013-03-05 16:48:17 +00:00
AddGenres(artist, data.tags);
}
}
2013-03-05 16:48:17 +00:00
public static void ProcessAlbumData(BaseItem item, LastfmAlbum data)
{
if (!string.IsNullOrWhiteSpace(data.mbid)) item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
var overview = data.wiki != null ? data.wiki.content : null;
item.Overview = overview;
DateTime release;
2013-03-05 16:48:17 +00:00
DateTime.TryParse(data.releasedate, out release);
item.PremiereDate = release;
item.ProductionYear = release.Year;
2013-03-05 16:48:17 +00:00
if (data.toptags != null)
{
AddGenres(item, data.toptags);
}
}
2013-03-05 16:48:17 +00:00
private static void AddGenres(BaseItem item, LastfmTags tags)
{
foreach (var tag in tags.tag)
{
item.AddGenre(tag.name);
}
}
}
}