2013-04-10 15:56:36 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
2013-04-24 14:05:47 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
2013-03-05 16:48:17 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2013-03-12 22:49:45 +00:00
|
|
|
|
using System;
|
2013-03-04 20:03:36 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Providers.Music
|
|
|
|
|
{
|
|
|
|
|
public static class LastfmHelper
|
|
|
|
|
{
|
2013-04-22 04:38:03 +00:00
|
|
|
|
public static string LocalArtistMetaFileName = "mbartist.js";
|
|
|
|
|
public static string LocalAlbumMetaFileName = "mbalbum.js";
|
2013-03-04 20:03:36 +00:00
|
|
|
|
|
|
|
|
|
public static void ProcessArtistData(BaseItem artist, LastfmArtist data)
|
|
|
|
|
{
|
2013-03-05 15:45:25 +00:00
|
|
|
|
var yearFormed = 0;
|
2013-04-10 15:56:36 +00:00
|
|
|
|
|
|
|
|
|
if (data.bio != null)
|
2013-03-05 15:45:25 +00:00
|
|
|
|
{
|
2013-04-10 15:56:36 +00:00
|
|
|
|
Int32.TryParse(data.bio.yearformed, out yearFormed);
|
2013-04-22 04:38:03 +00:00
|
|
|
|
|
|
|
|
|
artist.Overview = data.bio.content;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(data.bio.placeformed))
|
|
|
|
|
{
|
|
|
|
|
artist.AddProductionLocation(data.bio.placeformed);
|
|
|
|
|
}
|
2013-03-05 15:45:25 +00:00
|
|
|
|
}
|
2013-04-10 15:56:36 +00:00
|
|
|
|
|
2013-03-12 14:27:37 +00:00
|
|
|
|
artist.PremiereDate = yearFormed > 0 ? new DateTime(yearFormed, 1,1) : DateTime.MinValue;
|
|
|
|
|
artist.ProductionYear = yearFormed;
|
2013-03-04 20:03:36 +00:00
|
|
|
|
if (data.tags != null)
|
|
|
|
|
{
|
2013-03-05 16:48:17 +00:00
|
|
|
|
AddGenres(artist, data.tags);
|
|
|
|
|
}
|
2013-04-24 14:05:47 +00:00
|
|
|
|
|
|
|
|
|
var entity = artist as Artist;
|
|
|
|
|
|
|
|
|
|
if (entity != null)
|
|
|
|
|
{
|
|
|
|
|
entity.IsOnTour = string.Equals(data.ontour, "1");
|
|
|
|
|
}
|
2013-03-05 16:48:17 +00:00
|
|
|
|
}
|
2013-03-04 20:03:36 +00:00
|
|
|
|
|
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);
|
|
|
|
|
|
2013-03-12 04:09:31 +00:00
|
|
|
|
var overview = data.wiki != null ? data.wiki.content : null;
|
|
|
|
|
|
|
|
|
|
item.Overview = overview;
|
|
|
|
|
|
2013-04-10 15:56:36 +00:00
|
|
|
|
DateTime release;
|
2013-03-05 16:48:17 +00:00
|
|
|
|
DateTime.TryParse(data.releasedate, out release);
|
|
|
|
|
item.PremiereDate = release;
|
2013-03-12 14:27:37 +00:00
|
|
|
|
item.ProductionYear = release.Year;
|
2013-03-05 16:48:17 +00:00
|
|
|
|
if (data.toptags != null)
|
|
|
|
|
{
|
|
|
|
|
AddGenres(item, data.toptags);
|
2013-03-04 20:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-05 16:48:17 +00:00
|
|
|
|
private static void AddGenres(BaseItem item, LastfmTags tags)
|
|
|
|
|
{
|
|
|
|
|
foreach (var tag in tags.tag)
|
|
|
|
|
{
|
2013-04-22 04:38:03 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(tag.name))
|
|
|
|
|
{
|
|
|
|
|
item.AddGenre(tag.name);
|
|
|
|
|
}
|
2013-03-05 16:48:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-03-04 20:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|