-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Flurl.Http; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Zune.Net.Helpers | ||
{ | ||
public static class Taddy | ||
{ | ||
public const string API_BASE = "https://api.taddy.org"; | ||
|
||
public static IFlurlRequest GetBase() | ||
{ | ||
return API_BASE | ||
.WithHeader("Content-Type", "application/json") | ||
.WithHeader("X-USER-ID", Constants.TD_USER_ID) | ||
.WithHeader("X-API-KEY", Constants.TD_API_KEY); | ||
} | ||
|
||
public static async Task<TaddyPodcastSeries> GetMinimalPodcastInfo(string name) | ||
{ | ||
RequestData request = new($"{{ getPodcastSeries(name: \"{name}\") {{ uuid rssUrl description(shouldStripHtmlTags: true) }} }}"); | ||
|
||
var response = await GetBase().PostJsonAsync(request); | ||
var responseObj = await response.GetJsonAsync<JToken>(); | ||
|
||
var data = responseObj["data"]["getPodcastSeries"]; | ||
return new( | ||
Guid.Parse(data.Value<string>("uuid")), | ||
data.Value<string>("rssUrl"), | ||
data.Value<string>("description") | ||
); | ||
} | ||
|
||
private record RequestData(string query); | ||
|
||
public record TaddyPodcastSeries(Guid Id, string RssUrl, string Description); | ||
} | ||
} |