Skip to content

Commit

Permalink
V1.0.5 (#29)
Browse files Browse the repository at this point in the history
Fix search escaping
  • Loading branch information
sharkusmanch authored Apr 19, 2022
1 parent 5f01b5b commit 3612f46
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion extension.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Id: PCGamingWikiMetadata_c038558e-427b-4551-be4c-be7009ce5a8d
Name: PCGamingWiki Metadata Provider
Author: sharkusmanch
Version: 1.0.4
Version: 1.0.5
Module: PCGamingWikiMetadata.dll
Type: MetadataProvider
Icon: icon.png
6 changes: 6 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
AddonId: PCGamingWikiMetadata_c038558e-427b-4551-be4c-be7009ce5a8d
Packages:
- Version: 1.0.5
RequiredApiVersion: 6.2.2
ReleaseDate: 2022-04-18
PackageUrl: https://github.com/sharkusmanch/playnite-pcgamingwiki-metadata-provider/releases/download/v1.0.5/PCGamingWiki_Metadata_Provider_v1.0.5.pext
Changelog:
- Fix search matching when game title contains special characters
- Version: 1.0.4
RequiredApiVersion: 6.2.2
ReleaseDate: 2022-04-12
Expand Down
15 changes: 10 additions & 5 deletions src/PCGWClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Linq;
using System.Text;

namespace PCGamingWikiMetadata
{
Expand All @@ -19,16 +20,19 @@ public class PCGWClient
public PCGWClient(MetadataRequestOptions options, PCGWGameController gameController)
{
client = new RestClient(baseUrl);
client.UserAgent = "Playnite";
client.Encoding = Encoding.UTF8;
this.options = options;
this.gameController = gameController;
}

public JObject ExecuteRequest(RestRequest request)
{
request.AddParameter("format", "json", ParameterType.QueryString);
request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

var fullUrl = client.BuildUri(request);
logger.Info(fullUrl.ToString());

var response = client.Execute(request);

if (response.ErrorException != null)
Expand All @@ -44,9 +48,7 @@ public JObject ExecuteRequest(RestRequest request)

private string NormalizeSearchString(string search)
{
string updated = search.Replace("-", " ");

return updated;
return search.Replace("-", " ");
}

public List<GenericItemOption> SearchGames(string searchName)
Expand All @@ -55,11 +57,14 @@ public List<GenericItemOption> SearchGames(string searchName)
logger.Info(searchName);

var request = new RestRequest("/", Method.GET);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddHeader("Accept", "application/json, text/json, text/x-json");

request.AddParameter("action", "query", ParameterType.QueryString);
request.AddParameter("list", "search", ParameterType.QueryString);
request.AddParameter("srlimit", 300, ParameterType.QueryString);
request.AddParameter("srwhat", "title", ParameterType.QueryString);
request.AddParameter("srsearch", NormalizeSearchString(searchName), ParameterType.QueryString);
request.AddParameter("srsearch", $"\"{NormalizeSearchString(searchName)}\"", ParameterType.QueryString);

try
{
Expand Down
3 changes: 0 additions & 3 deletions src/PCGamingWikiHTMLParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ private IList<HtmlNode> SelectTableRowsByClass(string tableId, string rowClass)
private void ParseVideo()
{
var rows = SelectTableRowsByClass("table-settings-video", "template-infotable-body table-settings-video-body-row");
logger.Debug($"Video row count: {rows.Count}");
string feature = "";
string rating = "";

Expand All @@ -68,11 +67,9 @@ private void ParseVideo()
{
case "table-settings-video-body-parameter":
feature = child.FirstChild.InnerText.Trim();
logger.Debug(feature);
break;
case "table-settings-video-body-rating":
rating = child.FirstChild.Attributes["title"].Value;
logger.Debug(rating);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PCGamingWikiMetadata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="HtmlAgilityPack" Version="1.11.36" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
<PackageReference Include="RestSharp" Version="106.10.1" />
<PackageReference Include="RestSharp" Version="106.15.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand Down

0 comments on commit 3612f46

Please sign in to comment.