From 623a45d1ec1f7e636defd139b35b615b1a64af91 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Fri, 2 Dec 2022 12:04:42 +0900 Subject: feat: !WIP nrk radio --- src/Services/NrkRadioService.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Services/NrkRadioService.cs (limited to 'src/Services/NrkRadioService.cs') diff --git a/src/Services/NrkRadioService.cs b/src/Services/NrkRadioService.cs new file mode 100644 index 0000000..a2889ce --- /dev/null +++ b/src/Services/NrkRadioService.cs @@ -0,0 +1,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(); + while (path.HasValue()) { + var response = await _http.GetFromJsonAsync(path); + + } + } + + public async Task SearchCategoriesAsync(string query, int take = 50, int skip = 50) { + return await _http.GetFromJsonAsync( + "/radio/search/categories/alt-innhold?q=" + query + "&take=" + take + "&skip=" + skip + ); + } +} \ No newline at end of file -- cgit v1.3