本文整理汇总了Golang中github.com/jmcvetta/napping.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
args := os.Args
if len(args) != 3 {
fmt.Println("Give me a URL, and a name and off we go.")
return
}
url := args[1]
fmt.Println(url)
name := args[2]
var result map[string]interface{}
var w writeAndPrint
response, err := napping.Get(url, nil, &result, nil)
if err != nil {
fmt.Println(err)
return
}
if response.Status() != 200 {
fmt.Printf("Could not download JSON. Sorry. \n The Server responded with: \n %v \n And HTTP status code: %v", response.RawText(), response.Status())
}
err = generator.WriteGo(result, name, w)
if err != nil {
fmt.Print(err)
}
}
开发者ID:AWare,项目名称:j2s,代码行数:25,代码来源:main.go
示例2: GetImageDetails
func (api *DockerApi) GetImageDetails(fqImageName string) (*ApiDockerImage, error) {
url := strings.Join(
[]string{
api.configFile.DockerEndpoint,
"images",
fqImageName,
"json",
},
"/",
)
// For testing, also need to `import "encoding/json"`
// result := map[string]json.RawMessage{}
result := ApiDockerImage{}
Logger.Trace("GetImageDetails Api call to:", url)
if resp, err := napping.Get(url, nil, &result, nil); err != nil {
Logger.Error("Error while getting Image information from docker,", err)
return nil, err
} else {
switch resp.Status() {
case 200:
Logger.Trace(result)
return &result, nil
case 404:
Logger.Debug("Image not found")
return nil, nil
}
return nil, nil
}
}
开发者ID:JasonGiedymin,项目名称:test-flight,代码行数:32,代码来源:docker.go
示例3: Find
func Find(externalId string, externalSource string) *FindResult {
var result *FindResult
cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
key := fmt.Sprintf("com.tmdb.find.%s.%s", externalSource, externalId)
if err := cacheStore.Get(key, &result); err != nil {
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"external_source": externalSource,
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"find/"+externalId,
&urlValues,
&result,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "Failed Find call, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("Find call bad status: %d", resp.Status())
log.Error(message)
xbmc.Notify("Quasar", message, config.AddonIcon())
}
cacheStore.Set(key, result, 365*24*time.Hour)
})
}
return result
}
开发者ID:i96751414,项目名称:quasar,代码行数:31,代码来源:tmdb.go
示例4: 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
示例5: ListMoviesComplete
func ListMoviesComplete(endpoint string, params napping.Params) Movies {
movies := make(Movies, popularMoviesMaxPages*moviesPerPage)
params["api_key"] = apiKey
wg := sync.WaitGroup{}
for i := 0; i < popularMoviesMaxPages; i++ {
wg.Add(1)
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
}
rateLimiter.Call(func() {
napping.Get(
tmdbEndpoint+endpoint,
&tmpParams,
&tmp,
nil,
)
})
for i, movie := range tmp.Results {
movies[page*moviesPerPage+i] = GetMovie(movie.Id, params["language"])
}
}(i)
}
wg.Wait()
return movies
}
开发者ID:xfanity,项目名称:pulsar,代码行数:33,代码来源:movie.go
示例6: 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
示例7: getMovieById
func getMovieById(movieId string, language string) *Movie {
var movie *Movie
cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
key := fmt.Sprintf("com.tmdb.movie.%s.%s", movieId, language)
if err := cacheStore.Get(key, &movie); err != nil {
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"append_to_response": "credits,images,alternative_titles,translations,external_ids,trailers",
"language": language,
}.AsUrlValues()
napping.Get(
tmdbEndpoint+"movie/"+movieId,
&urlValues,
&movie,
nil,
)
if movie != nil {
cacheStore.Set(key, movie, cacheTime)
}
})
}
if movie == nil {
return nil
}
switch t := movie.RawPopularity.(type) {
case string:
popularity, _ := strconv.ParseFloat(t, 64)
movie.Popularity = popularity
case float64:
movie.Popularity = t
}
return movie
}
开发者ID:abuisine,项目名称:quasar,代码行数:34,代码来源:movie.go
示例8: GetSeason
func GetSeason(showId int, seasonNumber int, language string) *Season {
var season *Season
cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
key := fmt.Sprintf("com.tmdb.season.%d.%d.%s", showId, seasonNumber, language)
if err := cacheStore.Get(key, &season); err != nil {
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"append_to_response": "credits,images,videos,external_ids",
"language": language,
}.AsUrlValues()
resp, err := napping.Get(
fmt.Sprintf("%stv/%d/season/%d", tmdbEndpoint, showId, seasonNumber),
&urlValues,
&season,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
})
season.EpisodeCount = len(season.Episodes)
if season != nil {
cacheStore.Set(key, season, cacheTime)
}
}
if season == nil {
return nil
}
return season
}
开发者ID:felipejfc,项目名称:quasar,代码行数:34,代码来源:season.go
示例9: GetList
func GetList(listId string, language string, page int) Movies {
var results *List
listResultsPerPage := config.Get().ResultsPerPage
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"list/"+listId,
&urlValues,
&results,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "GetList failed, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("GetList bad status: %d", resp.Status())
log.Error(message)
xbmc.Notify("Quasar", message, config.AddonIcon())
}
})
tmdbIds := make([]int, 0, listResultsPerPage)
for i, movie := range results.Items {
if i < page*listResultsPerPage {
continue
}
tmdbIds = append(tmdbIds, movie.Id)
if i >= (startPage+page)*listResultsPerPage-1 {
break
}
}
return GetMovies(tmdbIds, language)
}
开发者ID:scakemyer,项目名称:quasar,代码行数:35,代码来源:movie.go
示例10: Find
func Find(externalId string, externalSource string) *FindResult {
var result *FindResult
cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
key := fmt.Sprintf("com.tmdb.find.%s.%s", externalSource, externalId)
if err := cacheStore.Get(key, &result); err != nil {
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"external_source": externalSource,
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"find/"+externalId,
&urlValues,
&result,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
cacheStore.Set(key, result, 365*24*time.Hour)
})
}
return result
}
开发者ID:felipejfc,项目名称:quasar,代码行数:29,代码来源:tmdb.go
示例11: GetList
func GetList(listId string, language string) Movies {
var results *List
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"list/"+listId,
&urlValues,
&results,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
})
tmdbIds := make([]int, 0, len(results.Items))
for _, movie := range results.Items {
tmdbIds = append(tmdbIds, movie.Id)
}
return GetMovies(tmdbIds, language)
}
开发者ID:felipejfc,项目名称:quasar,代码行数:25,代码来源:movie.go
示例12: SearchShows
func SearchShows(query string, language string) Shows {
var results EntityList
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"query": query,
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"search/tv",
&urlValues,
&results,
nil,
)
if err != nil {
panic(err)
}
if resp.Status() != 200 {
panic(errors.New(fmt.Sprintf("Bad status: %d", resp.Status())))
}
})
tmdbIds := make([]int, 0, len(results.Results))
for _, entity := range results.Results {
tmdbIds = append(tmdbIds, entity.Id)
}
return GetShows(tmdbIds, language)
}
开发者ID:felipejfc,项目名称:quasar,代码行数:26,代码来源:show.go
示例13: SearchShows
func SearchShows(query string, language string, page int) Shows {
var results EntityList
rateLimiter.Call(func() {
urlValues := napping.Params{
"api_key": apiKey,
"query": query,
"page": strconv.Itoa(startPage + page),
}.AsUrlValues()
resp, err := napping.Get(
tmdbEndpoint+"search/tv",
&urlValues,
&results,
nil,
)
if err != nil {
log.Error(err.Error())
xbmc.Notify("Quasar", "SearchShows failed, check your logs.", config.AddonIcon())
} else if resp.Status() != 200 {
message := fmt.Sprintf("SearchShows bad status: %d", resp.Status())
log.Error(message)
xbmc.Notify("Quasar", message, config.AddonIcon())
}
})
tmdbIds := make([]int, 0, len(results.Results))
for _, entity := range results.Results {
tmdbIds = append(tmdbIds, entity.Id)
}
return GetShows(tmdbIds, language)
}
开发者ID:i96751414,项目名称:quasar,代码行数:29,代码来源:show.go
示例14: GetShow
func GetShow(showId int, language string) *Show {
var show *Show
cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
key := fmt.Sprintf("com.tmdb.show.%d.%s", showId, language)
if err := cacheStore.Get(key, &show); err != nil {
rateLimiter.Call(func() {
napping.Get(
tmdbEndpoint+"tv/"+strconv.Itoa(showId),
&napping.Params{"api_key": apiKey, "append_to_response": "credits,images,alternative_titles,translations,external_ids", "language": language},
&show,
nil,
)
})
if show != nil {
cacheStore.Set(key, show, cacheTime)
}
}
if show == nil {
return nil
}
switch t := show.RawPopularity.(type) {
case string:
if popularity, err := strconv.ParseFloat(t, 64); err == nil {
show.Popularity = popularity
}
case float64:
show.Popularity = t
}
return show
}
开发者ID:xfanity,项目名称:pulsar,代码行数:30,代码来源:show.go
示例15: TrendingShows
func TrendingShows() ShowList {
var shows ShowList
napping.Get(fmt.Sprintf("%s/shows/trending.json/%s", ENDPOINT, APIKEY), nil, &shows, nil)
for _, show := range shows {
sanitizeIds(show)
}
return shows
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:8,代码来源:shows.go
示例16: Seasons
func (show *Show) Seasons() []*ShowSeason {
var seasons []*ShowSeason
napping.Get(fmt.Sprintf("%s/show/seasons.json/%s/%s", ENDPOINT, APIKEY, show.TVDBId), nil, &seasons, nil)
for _, season := range seasons {
season.Show = show
}
return seasons
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:8,代码来源:shows.go
示例17: SearchMovies
func SearchMovies(query string) MovieList {
var movies MovieList
napping.Get(fmt.Sprintf("%s/search/movies.json/%s", ENDPOINT, APIKEY),
&napping.Params{"query": query, "limit": SearchLimit},
&movies,
nil)
return movies
}
开发者ID:xfanity,项目名称:pulsar,代码行数:8,代码来源:movies.go
示例18: SearchShows
func SearchShows(query string) ShowList {
var shows ShowList
napping.Get(fmt.Sprintf("%s/search/shows.json/%s", ENDPOINT, APIKEY),
&napping.Params{"query": query, "limit": SearchLimit},
&shows,
nil)
for _, show := range shows {
sanitizeIds(show)
}
return shows
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:11,代码来源:shows.go
示例19: 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
示例20: GetMovieGenres
func GetMovieGenres(language string) []*Genre {
genres := GenreList{}
rateLimiter.Call(func() {
napping.Get(
tmdbEndpoint+"genre/movie/list",
&napping.Params{"api_key": apiKey, "language": language},
&genres,
nil,
)
})
return genres.Genres
}
开发者ID:xfanity,项目名称:pulsar,代码行数:12,代码来源:movie.go
注:本文中的github.com/jmcvetta/napping.Get函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论