Здравствуйте. Есть запрос:
private async Task<string> Kodik(string key, string value, string selectToken)
{
var uri = new Uri("https://kodikapi.com/search");
var formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("token", "#######"),
new KeyValuePair<string, string>(key, value)
});
var client = new HttpClient();
var response = await client.PostAsync(uri.ToString(), formContent);
var responseContent = await response.Content.ReadAsStringAsync();
var jsonResult = JObject.Parse(responseContent).SelectToken(selectToken);
return jsonResult.ToString();
}
Он возвращает следующий json
{
"time": "5ms",
"total": 8,
"results": [
{
"id": "serial-39652",
"type": "anime-serial",
"link": "//kodik.info/serial/39652/a8a268aa817e9fb2c812870972350f79/720p",
"title": "Невеста чародея OVA-2",
"title_orig": "Mahou Tsukai no Yome: Nishi no Shounen to Seiran no Kishi",
"other_title": "Mahoutsukai no Yome: Nishi no Shounen to Seiran no Kishi",
"translation": {
"id": 767,
"title": "SHIZA Project",
"type": "voice"
},
"year": 2021,
"last_season": 2,
"last_episode": 2,
"episodes_count": 2,
"kinopoisk_id": "4533458",
"imdb_id": "tt15400722",
"worldart_link": "http://www.world-art.ru/animation/animation.php?id=10840",
"shikimori_id": "48438",
"quality": "WEB-DLRip 720p",
"camrip": false,
"blocked_countries": [],
"blocked_seasons": {},
"created_at": "2021-12-24T02:01:16Z",
"updated_at": "2022-06-13T12:04:15Z",
"screenshots": [
"https://i.kodik.biz/screenshots/seria/938141/1.jpg",
"https://i.kodik.biz/screenshots/seria/938141/2.jpg",
"https://i.kodik.biz/screenshots/seria/938141/3.jpg",
"https://i.kodik.biz/screenshots/seria/938141/4.jpg",
"https://i.kodik.biz/screenshots/seria/938141/5.jpg"
]
},
{
"id": "serial-45558",
"type": "anime-serial",
"link": "//kodik.info/serial/45558/4105c8b870d4451b5c978adb89290a4e/720p",
"title": "Невеста чародея OVA-2",
"title_orig": "Mahou Tsukai no Yome: Nishi no Shounen to Seiran no Kishi",
"other_title": "Mahoutsukai no Yome: Nishi no Shounen to Seiran no Kishi",
"translation": {
"id": 910,
"title": "AniStar",
"type": "voice"
},
"year": 2021,
"last_season": 2,
"last_episode": 2,
"episodes_count": 2,
"kinopoisk_id": "4533458",
"imdb_id": "tt15400722",
"worldart_link": "http://www.world-art.ru/animation/animation.php?id=10840",
"shikimori_id": "48438",
"quality": "BDRip 720p",
"camrip": false,
"blocked_countries": [],
"blocked_seasons": {},
"created_at": "2022-09-15T13:12:14Z",
"updated_at": "2022-09-15T13:37:44Z",
"screenshots": [
"https://i.kodik.biz/screenshots/seria/1050238/1.jpg",
"https://i.kodik.biz/screenshots/seria/1050238/2.jpg",
"https://i.kodik.biz/screenshots/seria/1050238/3.jpg",
"https://i.kodik.biz/screenshots/seria/1050238/4.jpg",
"https://i.kodik.biz/screenshots/seria/1050238/5.jpg"
]
}
...............................................
]
}
}
Метод вызываю так:
await Kodik("kinopoisk_id", kinopoisk_id, "results[0].translation.title");
Он возвращает мне значение из
translation.title
.
Но озвучек в выбранном сериале может быть больше одной, как в приведенном мной примере. А раз я обращаюсь к нулевому элементу, то я получаю лишь одну, вместо всех. Как можно за раз получить значения всех
translation.title
из всех ветвей
results
?
Я думал пробежаться циклом, но, может быть, есть более простой способ?