本文整理汇总了Golang中github.com/jmcvetta/napping.Params.AsUrlValues方法的典型用法代码示例。如果您正苦于以下问题:Golang Params.AsUrlValues方法的具体用法?Golang Params.AsUrlValues怎么用?Golang Params.AsUrlValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jmcvetta/napping.Params
的用法示例。
在下文中一共展示了Params.AsUrlValues方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ListEntities
func ListEntities(endpoint string, params napping.Params) []*Entity {
var wg sync.WaitGroup
entities := make([]*Entity, popularMoviesMaxPages*moviesPerPage)
params["api_key"] = apiKey
params["language"] = "en"
wg.Add(popularMoviesMaxPages)
for i := 0; i < popularMoviesMaxPages; i++ {
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(popularMoviesStartPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
p := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
napping.Get(
tmdbEndpoint+endpoint,
&p,
&tmp,
nil,
)
})
for i, entity := range tmp.Results {
entities[page*moviesPerPage+i] = entity
}
}(i)
}
wg.Wait()
return entities
}
示例2: ListShows
func ListShows(endpoint string, params napping.Params, page int) (shows Shows) {
var results *EntityList
params["page"] = strconv.Itoa(startPage + page)
params["api_key"] = apiKey
p := params.AsUrlValues()
rateLimiter.Call(func() {
resp, err := napping.Get(
tmdbEndpoint + endpoint,
&p,
&results,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "ListShows failed, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("ListShows bad status: %d", resp.Status())
log.Error(message)
xbmc.Notify("Quasar", message, config.AddonIcon())
}
})
if results != nil {
for _, show := range results.Results {
shows = append(shows, GetShow(show.Id, params["language"]))
}
}
return shows
}
示例3: ListShowsComplete
func ListShowsComplete(endpoint string, params napping.Params, page int) Shows {
maxPages := MaxPages
if page >= 0 {
maxPages = 1
}
shows := make(Shows, maxPages*resultsPerPage)
params["api_key"] = apiKey
wg := sync.WaitGroup{}
for i := 0; i < maxPages; i++ {
wg.Add(1)
currentpage := i
startIndex := i * resultsPerPage
if page >= 0 {
currentpage = page
}
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(startPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
urlValues := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
resp, err := napping.Get(
tmdbEndpoint+endpoint,
&urlValues,
&tmp,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "ListShows failed, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("ListShows bad status: %d", resp.Status())
xbmc.Notify("Quasar", message, config.AddonIcon())
}
})
if tmp != nil {
for i, entity := range tmp.Results {
shows[startIndex+i] = GetShow(entity.Id, params["language"])
}
}
}(currentpage)
}
wg.Wait()
return shows
}
示例4: ListShowsComplete
func ListShowsComplete(endpoint string, params napping.Params, page int) Shows {
MaxPages := popularMoviesMaxPages
if page >= 0 {
MaxPages = 1
}
shows := make(Shows, MaxPages*moviesPerPage)
params["api_key"] = apiKey
wg := sync.WaitGroup{}
for i := 0; i < MaxPages; i++ {
wg.Add(1)
currentpage := i
startMoviesIndex := i * moviesPerPage
if page >= 0 {
currentpage = page
}
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(popularMoviesStartPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
urlValues := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
resp, err := napping.Get(
tmdbEndpoint+endpoint,
&urlValues,
&tmp,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
})
for i, entity := range tmp.Results {
shows[startMoviesIndex+i] = GetShow(entity.Id, params["language"])
}
}(currentpage)
}
wg.Wait()
return shows
}
示例5: ListEntities
func ListEntities(endpoint string, params napping.Params) []*Entity {
var wg sync.WaitGroup
entities := make([]*Entity, MaxPages*resultsPerPage)
params["api_key"] = apiKey
params["language"] = "en"
wg.Add(MaxPages)
for i := 0; i < MaxPages; i++ {
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(startPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
urlValues := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
resp, err := napping.Get(
tmdbEndpoint+endpoint,
&urlValues,
&tmp,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "ListEntities failed, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("ListEntities bad status: %d", resp.Status())
log.Error(message)
xbmc.Notify("Quasar", message, config.AddonIcon())
}
})
for i, entity := range tmp.Results {
entities[page*resultsPerPage+i] = entity
}
}(i)
}
wg.Wait()
return entities
}
示例6: ListMoviesComplete
func ListMoviesComplete(endpoint string, params napping.Params, page int) Movies {
MaxPages := popularMoviesMaxPages
if page >= 0 {
MaxPages = 1
}
movies := make(Movies, MaxPages*moviesPerPage)
params["api_key"] = apiKey
wg := sync.WaitGroup{}
for i := 0; i < MaxPages; i++ {
wg.Add(1)
currentpage := i
startMoviesIndex := i * moviesPerPage
if page >= 0 {
currentpage = page
}
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(popularMoviesStartPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
urlValues := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
napping.Get(
tmdbEndpoint+endpoint,
&urlValues,
&tmp,
nil,
)
})
for i, movie := range tmp.Results {
movies[startMoviesIndex+i] = GetMovie(movie.Id, params["language"])
}
}(currentpage)
}
wg.Wait()
return movies
}
示例7: ListEntities
func ListEntities(endpoint string, params napping.Params) []*Entity {
var wg sync.WaitGroup
entities := make([]*Entity, popularMoviesMaxPages*moviesPerPage)
params["api_key"] = apiKey
params["language"] = "en"
wg.Add(popularMoviesMaxPages)
for i := 0; i < popularMoviesMaxPages; i++ {
go func(page int) {
defer wg.Done()
var tmp *EntityList
tmpParams := napping.Params{
"page": strconv.Itoa(popularMoviesStartPage + page),
}
for k, v := range params {
tmpParams[k] = v
}
urlValues := tmpParams.AsUrlValues()
rateLimiter.Call(func() {
resp, err := napping.Get(
tmdbEndpoint+endpoint,
&urlValues,
&tmp,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
})
for i, entity := range tmp.Results {
entities[page*moviesPerPage+i] = entity
}
}(i)
}
wg.Wait()
return entities
}