當前位置: 首頁>>代碼示例>>Golang>>正文


Golang napping.Params類代碼示例

本文整理匯總了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;未經允許,請勿轉載。