Skip to content

Commit 40ae362

Browse files
committed
change query casing and use StringBuilder
1 parent b96dc81 commit 40ae362

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

FileListSharp/Builders/FileListSearchParams.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Diagnostics.CodeAnalysis;
2-
using System.Dynamic;
2+
using System.Text;
33
using System.Text.RegularExpressions;
4-
using Newtonsoft.Json;
54

65
namespace FileListSharp.Builders;
76

@@ -21,17 +20,17 @@ public partial class FileListSearchParams
2120
public override string ToString()
2221
{
2322
if (_query is null) throw new ArgumentNullException("Query", $"The query for {GetType().Name} cannot be null.");
24-
var final = $"type={_type}&query={_query}";
23+
var final = new StringBuilder($"type={_type}&query={_query}");
2524

26-
if (_category is not null) final += $"&category={string.Join(',', _category)}";
27-
if (_moderated is not null) final += $"&moderated={_moderated}";
28-
if (_internal is not null) final += $"&internal={_internal}";
29-
if (_freeleech is not null) final += $"&freeleech={_freeleech}";
30-
if (_doubleup is not null) final += $"&doubleup={_doubleup}";
31-
if (_season is not null) final += $"&season={_season}";
32-
if (_episode is not null) final += $"&episode={_episode}";
25+
if (_category is not null) final.Append($"&category={string.Join(',', _category)}");
26+
if (_moderated is not null) final.Append($"&moderated={_moderated}");
27+
if (_internal is not null) final.Append($"&internal={_internal}");
28+
if (_freeleech is not null) final.Append($"&freeleech={_freeleech}");
29+
if (_doubleup is not null) final.Append($"&doubleup={_doubleup}");
30+
if (_season is not null) final.Append($"&season={_season}");
31+
if (_episode is not null) final.Append($"&episode={_episode}");
3332

34-
return final;
33+
return final.ToString();
3534
}
3635

3736
/// <summary>

FileListSharp/FileListSharp.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ public FileList(string username, string passkey)
3535
/// var searchParams = new FileListSearchParams().Query("The Haunting of Hill House").Categories([21]).FreeLeech(true);
3636
/// </code>
3737
/// </example>
38-
/// <exception cref="Exception">If API returns an error or rate limit is reached</exception>
38+
/// <exception cref="Exception">If the API returns an error or rate limit is reached</exception>
3939
/// <returns>FileListTorrent</returns>
4040
public async Task<List<FileListTorrent>?> SearchAsync(FileListSearchParams searchParams)
4141
{
42-
var parameters = searchParams.ToString();
43-
parameters += "&action=search-torrents&output=json";
44-
return await _query(parameters);
42+
var parameters = new StringBuilder(searchParams.ToString());
43+
parameters.Append("&action=search-torrents&output=json");
44+
return await _Query(parameters.ToString());
4545
}
4646

4747
/// <summary>
@@ -54,16 +54,16 @@ public FileList(string username, string passkey)
5454
/// var latestParams = new FileListLatestParams().Imdb("tt14527626").Categories([21]);
5555
/// </code>
5656
/// </example>
57-
/// <exception cref="Exception">If API returns an error or rate limit is reached</exception>
57+
/// <exception cref="Exception">If the API returns an error or rate limit is reached</exception>
5858
/// <returns>FileListTorrent</returns>
5959
public async Task<List<FileListTorrent>?> LatestAsync(FileListLatestParams searchParams)
6060
{
61-
var parameters = searchParams.ToString();
62-
parameters += "&action=latest-torrents&output=json";
63-
return await _query(parameters);
61+
var parameters = new StringBuilder(searchParams.ToString());
62+
parameters.Append("&action=latest-torrents&output=json");
63+
return await _Query(parameters.ToString());
6464
}
6565

66-
private async Task<List<FileListTorrent>?> _query(string parameters)
66+
private async Task<List<FileListTorrent>?> _Query(string parameters)
6767
{
6868
var url = $"{ApiUrl}?{HttpUtility.UrlDecode(parameters)}";
6969
var response = await _client.GetAsync(url);

FileListSharp/FileListSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1717
</ItemGroup>
1818

1919
</Project>

0 commit comments

Comments
 (0)