fixes #22 - Need to strip html tags from overviews

This commit is contained in:
LukePulverenti 2013-03-12 00:09:31 -04:00
parent 02bfec8cc7
commit cb189e7394

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
@ -41,7 +42,15 @@ namespace MediaBrowser.Controller.Providers.Music
{ {
if (!string.IsNullOrWhiteSpace(data.mbid)) item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid); if (!string.IsNullOrWhiteSpace(data.mbid)) item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
item.Overview = data.wiki != null ? data.wiki.content : null; var overview = data.wiki != null ? data.wiki.content : null;
if (!string.IsNullOrEmpty(overview))
{
overview = StripHtml(overview);
}
item.Overview = overview;
var release = DateTime.MinValue; var release = DateTime.MinValue;
DateTime.TryParse(data.releasedate, out release); DateTime.TryParse(data.releasedate, out release);
item.PremiereDate = release; item.PremiereDate = release;
@ -51,6 +60,13 @@ namespace MediaBrowser.Controller.Providers.Music
} }
} }
private static string StripHtml(string htmlString)
{
// http://stackoverflow.com/questions/1349023/how-can-i-strip-html-from-text-in-net
const string pattern = @"<(.|\n)*?>";
return Regex.Replace(htmlString, pattern, string.Empty);
}
private static void AddGenres(BaseItem item, LastfmTags tags) private static void AddGenres(BaseItem item, LastfmTags tags)
{ {
foreach (var tag in tags.tag) foreach (var tag in tags.tag)