aboutsummaryrefslogtreecommitdiffstats
path: root/src/Services/NrkRadioService.cs
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-12-02 04:04:42 +0100
committerivarlovlie <git@ivarlovlie.no>2022-12-02 04:04:42 +0100
commit623a45d1ec1f7e636defd139b35b615b1a64af91 (patch)
tree0e5c2d5f1e96cd6f4adb305ed3f35dd02f2485ee /src/Services/NrkRadioService.cs
parenta453135b470565c56df2fd319dc927db67e299c6 (diff)
downloadlettnytt-623a45d1ec1f7e636defd139b35b615b1a64af91.tar.xz
lettnytt-623a45d1ec1f7e636defd139b35b615b1a64af91.zip
feat: !WIP nrk radio
Diffstat (limited to 'src/Services/NrkRadioService.cs')
-rw-r--r--src/Services/NrkRadioService.cs31
1 files changed, 31 insertions, 0 deletions
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<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
+ );
+ }
+} \ No newline at end of file