modify google api
This commit is contained in:
parent
919a6ed968
commit
56f7fb3d4e
|
|
@ -12,10 +12,18 @@ public class VideoItem
|
|||
[JsonPropertyName("etag")]
|
||||
public string Etag { get; set; }
|
||||
public VideoItemId Id { get; set; }
|
||||
public VideoSnippet Snippet { get; set; }
|
||||
}
|
||||
|
||||
public class VideoItemId
|
||||
{
|
||||
public string Kind { get; set; }
|
||||
public string VideoId { get; set; }
|
||||
}
|
||||
|
||||
public class VideoSnippet
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ChannelTitle { get; set; }
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@ public class GoogleApiSettings
|
|||
public class MapSettings
|
||||
{
|
||||
public string Endpoint { get; set; }
|
||||
public string Language { get; set; }
|
||||
public string Components { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -20,5 +19,4 @@ public class YoutubeSettings
|
|||
public string Endpoint { get; set; }
|
||||
public string Part { get; set; }
|
||||
public string RegionCode { get; set; }
|
||||
public string Language { get; set; }
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ public class GoogleController : ControllerBase
|
|||
}
|
||||
|
||||
[HttpGet("/address/options")]
|
||||
public async Task<GoogleAddressResult> GetAddressOptions([FromQuery] string address)
|
||||
public async Task<GoogleAddressResult> GetAddressOptions([FromQuery] string address, [FromQuery] string language = "en")
|
||||
{
|
||||
var result = new GoogleAddressResult();
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class GoogleController : ControllerBase
|
|||
using var client = _httpClientFactory.CreateClient();
|
||||
var url = $"{settings.Map.Endpoint}?key={settings.ApiKey}&" +
|
||||
$"components={settings.Map.Components}&" +
|
||||
$"language={settings.Map.Language}&" +
|
||||
$"language={language}&" +
|
||||
$"address={address}";
|
||||
|
||||
var response = await client.GetAsync(url);
|
||||
|
|
@ -49,7 +49,7 @@ public class GoogleController : ControllerBase
|
|||
}
|
||||
|
||||
[HttpGet("/video/options")]
|
||||
public async Task<GoogleVideoResult> GetVideoOptions([FromQuery] string query, [FromQuery] int? maxResults)
|
||||
public async Task<GoogleVideoResult> GetVideoOptions([FromQuery] string query, [FromQuery] int? maxResults, [FromQuery] string language = "en")
|
||||
{
|
||||
var result = new GoogleVideoResult();
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ public class GoogleController : ControllerBase
|
|||
using var client = _httpClientFactory.CreateClient();
|
||||
var url = $"{settings.Youtube.Endpoint}?key={settings.ApiKey}&" +
|
||||
$"part={settings.Youtube.Part}&" +
|
||||
$"relevanceLanguage={settings.Youtube.Language}&" +
|
||||
$"relevanceLanguage={language}&" +
|
||||
$"regionCode={settings.Youtube.RegionCode}&" +
|
||||
$"q={query}";
|
||||
|
||||
|
|
|
|||
|
|
@ -220,12 +220,10 @@
|
|||
"Map": {
|
||||
"Endpoint": "https://maps.googleapis.com/maps/api/geocode/json",
|
||||
"Components": "country=US|country=CA",
|
||||
"Language": "en"
|
||||
},
|
||||
"Youtube": {
|
||||
"Endpoint": "https://www.googleapis.com/youtube/v3/search",
|
||||
"RegionCode": "US",
|
||||
"Language": "en",
|
||||
"Part": "id"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue