Procházet zdrojové kódy

fixes #22 - Need to strip html tags from overviews

LukePulverenti před 12 roky
rodič
revize
cb189e7394

+ 17 - 1
MediaBrowser.Controller/Providers/Music/LastfmHelper.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using MediaBrowser.Controller.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);
 
-            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;
             DateTime.TryParse(data.releasedate, out 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)
         {
             foreach (var tag in tags.tag)