Removed all the html from the new TVMaze api (for overview).

Added tests to cover the html removal.
updated Readme to remove TheTVDB
pull/39/head
Jamie Rees 8 years ago
parent 87baf542c5
commit 87b497e48e

@ -0,0 +1,56 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: HtmlRemoverTests.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using NUnit.Framework;
namespace PlexRequests.Helpers.Tests
{
[TestFixture]
public class HtmlRemoverTests
{
[Test]
public void RemoveHtmlBasic()
{
var html = "this is <b>bold</b> <p>para</p> OK!";
var result = html.RemoveHtml();
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.EqualTo("this is bold para OK!"));
}
[Test]
public void RemoveHtmlMoreTags()
{
// Good 'ol Ali G ;)
var html = "<p><strong><em>\"Ali G: Rezurection\"</em></strong> includes every episode of <em>Da Ali G Show</em> with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of <em>Da Ali G Show</em> which have never aired on American television and <em>The Best of Ali G</em>.</p>";
var result = html.RemoveHtml();
Assert.That(result, Is.Not.Null);
Assert.That(result, Is.EqualTo("\"Ali G: Rezurection\" includes every episode of Da Ali G Show with new, original introductions by star, creator/writer Sacha Baron Cohen, along with the BAFTA(R) Award-winning English episodes of Da Ali G Show which have never aired on American television and The Best of Ali G."));
}
}
}

@ -70,6 +70,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="HtmlRemoverTests.cs" />
<Compile Include="AssemblyHelperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UriHelperTests.cs" />

@ -0,0 +1,41 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: HtmlRemover.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System.Text.RegularExpressions;
namespace PlexRequests.Helpers
{
public static class HtmlRemover
{
public static string RemoveHtml(this string value)
{
var step1 = Regex.Replace(value, @"<[^>]+>|&nbsp;", "").Trim();
var step2 = Regex.Replace(step1, @"\s{2,}", " ");
return step2;
}
}
}

@ -48,6 +48,7 @@
<ItemGroup>
<Compile Include="AssemblyHelper.cs" />
<Compile Include="Exceptions\ApplicationSettingsException.cs" />
<Compile Include="HtmlRemover.cs" />
<Compile Include="ICacheProvider.cs" />
<Compile Include="LoggingHelper.cs" />
<Compile Include="MemoryCacheProvider.cs" />

@ -128,7 +128,7 @@ namespace PlexRequests.UI.Modules
ImdbId = t.show.externals?.imdb,
Network = t.show.network?.name,
NetworkId = t.show.network?.id.ToString(),
Overview = t.show.summary,
Overview = t.show.summary.RemoveHtml(),
Rating = t.score.ToString(CultureInfo.CurrentUICulture),
Runtime = t.show.runtime.ToString(),
SeriesId = t.show.id,
@ -276,7 +276,7 @@ namespace PlexRequests.UI.Modules
{
ProviderId = showInfo.id,
Type = RequestType.TvShow,
Overview = showInfo.summary,
Overview = showInfo.summary.RemoveHtml(),
PosterPath = showInfo.image?.medium,
Title = showInfo.name,
ReleaseDate = firstAir,

@ -13,7 +13,7 @@ I wanted to write a similar application in .Net!
#Features
* Integration with [TheMovieDB](https://www.themoviedb.org/) for all Movies
* Integration with [TheTvDb](http://thetvdb.com/) for all TV shows! (soon to be changed [#21](https://github.com/tidusjar/PlexRequests.Net/issues/21))
* Integration with [TVMaze](www.tvmaze.com) for all TV shows!
* Secure authentication
* [Sonarr](https://sonarr.tv/) integration (SickRage/Sickbeard TBD)
* [CouchPotato](https://couchpota.to/) integration

Loading…
Cancel
Save