本文整理汇总了Golang中github.com/jmcvetta/napping.Params类的典型用法代码示例。如果您正苦于以下问题:Golang Params类的具体用法?Golang Params怎么用?Golang Params使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Params类的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
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:35,代码来源:tmdb.go
示例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
}
开发者ID:scakemyer,项目名称:quasar,代码行数:30,代码来源:show.go
示例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
}
开发者ID:i96751414,项目名称:quasar,代码行数:53,代码来源:show.go
示例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
}
开发者ID:felipejfc,项目名称:quasar,代码行数:50,代码来源:show.go
示例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
}
开发者ID:i96751414,项目名称:quasar,代码行数:43,代码来源:tmdb.go
示例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
}
开发者ID:abuisine,项目名称:quasar,代码行数:42,代码来源:movie.go
示例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
}
开发者ID:felipejfc,项目名称:quasar,代码行数:41,代码来源:tmdb.go
注:本文中的github.com/jmcvetta/napping.Params类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论