aboutsummaryrefslogtreecommitdiffstats
path: root/src/Services/NrkRadioService.cs
blob: a2889ceaabe39b6bafbf45f2967f28fa58e05e5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Extensions.Caching.Memory;

namespace I2R.LightNews.Services;

public class NrkRadioService
{
    private readonly IMemoryCache _cache;
    private readonly HttpClient _http;
    private const string CATEGORY_SEARCH_CACHE_KEY = "category_search";

    public NrkRadioService(IMemoryCache cache, HttpClient http) {
        _cache = cache;
        http.BaseAddress = new Uri("https://psapi.nrk.no");
        _http = http;
    }

    public async Task GetEverythingAsync() {
        var path = "/radio/search/categories/alt-innhold";
        var everything = new List<RadioSeries>();
        while (path.HasValue()) {
            var response = await _http.GetFromJsonAsync<RadioCategorySearchResult>(path);
            
        }
    }

    public async Task<RadioCategorySearchResult> SearchCategoriesAsync(string query, int take = 50, int skip = 50) {
        return await _http.GetFromJsonAsync<RadioCategorySearchResult>(
            "/radio/search/categories/alt-innhold?q=" + query + "&take=" + take + "&skip=" + skip
        );
    }
}