Working search
This commit is contained in:
parent
271cf1f407
commit
2a572e8bc4
15 changed files with 217 additions and 39 deletions
|
|
@ -15,6 +15,8 @@ public class JellyfinApiClient
|
|||
private readonly HttpClient _client;
|
||||
private readonly string _username, _password;
|
||||
|
||||
public string ID { get; private set; } = string.Empty;
|
||||
|
||||
public JellyfinApiClient(string instanceUrl, string username, string password)
|
||||
{
|
||||
InstanceUrl = instanceUrl;
|
||||
|
|
@ -24,7 +26,7 @@ public class JellyfinApiClient
|
|||
_password = password;
|
||||
}
|
||||
|
||||
public async Task<ItemResponse> GetInstanceLibraries()
|
||||
public async Task<Item[]> GetInstanceLibraries()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -35,7 +37,7 @@ public class JellyfinApiClient
|
|||
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<ItemResponse>();
|
||||
|
||||
return apiResponse!;
|
||||
return apiResponse.Items.ToArray();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
|
|
@ -43,7 +45,7 @@ public class JellyfinApiClient
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<ItemResponse> GetItemChildren(string itemId)
|
||||
public async Task<Item[]> GetItemChildren(string itemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -55,7 +57,7 @@ public class JellyfinApiClient
|
|||
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<ItemResponse>();
|
||||
|
||||
return apiResponse!;
|
||||
return apiResponse!.Items.ToArray();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
|
|
@ -63,16 +65,24 @@ public class JellyfinApiClient
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<ItemResponse> GetItems(string searchTerm = "", string years = "", string itemTypes = "", string limit = "", string parentId = "")
|
||||
public async Task<Item[]> GetItems(string searchTerm = "", string years = "", string itemTypes = "", string limit = "", string parentId = "")
|
||||
{
|
||||
var query = new Dictionary<string, string>();
|
||||
|
||||
if (searchTerm != String.Empty)
|
||||
try
|
||||
{
|
||||
query.Add("SearchTerm", searchTerm);
|
||||
}
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, $"{InstanceUrl}/items?searchTerm={searchTerm}&recursive=true&includeItemTypes=Series,Movie");
|
||||
|
||||
throw new NotImplementedException();
|
||||
var response = await MakeRequest(request);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var apiResponse = await response.Content.ReadFromJsonAsync<ItemResponse>();
|
||||
|
||||
return apiResponse!.Items.ToArray();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
throw new JellyfinApiClientException(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Authenticate()
|
||||
|
|
@ -98,6 +108,7 @@ public class JellyfinApiClient
|
|||
var authResponse = await response.Content.ReadFromJsonAsync<AuthResponse>();
|
||||
|
||||
_apiKey = authResponse!.AccessToken;
|
||||
ID = authResponse.ServerId;
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue