• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang config.Get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/scakemyer/quasar/config.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ShowEpisodes

func ShowEpisodes(ctx *gin.Context) {
	showId, _ := strconv.Atoi(ctx.Params.ByName("showId"))
	seasonNumber, _ := strconv.Atoi(ctx.Params.ByName("season"))
	language := config.Get().Language
	show := tmdb.GetShow(showId, language)
	season := tmdb.GetSeason(showId, seasonNumber, language)
	items := season.Episodes.ToListItems(show, season)

	for _, item := range items {
		playUrl := UrlForXBMC("/show/%d/season/%d/episode/%d/play",
			show.Id,
			seasonNumber,
			item.Info.Episode,
		)
		episodeLinksUrl := UrlForXBMC("/show/%d/season/%d/episode/%d/links",
			show.Id,
			seasonNumber,
			item.Info.Episode,
		)
		if config.Get().ChooseStreamAuto == true {
			item.Path = playUrl
		} else {
			item.Path = episodeLinksUrl
		}
		item.ContextMenu = [][]string{
			[]string{"LOCALIZE[30202]", fmt.Sprintf("XBMC.PlayMedia(%s)", episodeLinksUrl)},
			[]string{"LOCALIZE[30023]", fmt.Sprintf("XBMC.PlayMedia(%s)", playUrl)},
			[]string{"LOCALIZE[30203]", "XBMC.Action(Info)"},
			[]string{"LOCALIZE[30037]", fmt.Sprintf("XBMC.RunPlugin(%s)", UrlForXBMC("/setviewmode/episodes"))},
		}
		item.IsPlayable = true
	}

	ctx.JSON(200, xbmc.NewView("episodes", items))
}
开发者ID:scakemyer,项目名称:quasar,代码行数:35,代码来源:shows.go


示例2: MoviesMostVoted

func MoviesMostVoted(ctx *gin.Context) {
	page := -1
	if config.Get().EnablePaging == true {
		currentpage, err := strconv.Atoi(ctx.DefaultQuery("page", "0"))
		if err == nil {
			page = currentpage
		}
	}
	renderMovies(tmdb.MostVotedMoviesComplete("", config.Get().Language, page), ctx, page)
}
开发者ID:peer23peer,项目名称:quasar,代码行数:10,代码来源:movies.go


示例3: TopRatedShows

func TopRatedShows(ctx *gin.Context) {
	page := -1
	if config.Get().EnablePagination == true {
		currentpage, err := strconv.Atoi(ctx.DefaultQuery("page", "0"))
		if err == nil {
			page = currentpage
		}
	}
	renderShows(tmdb.TopRatedShowsComplete("", config.Get().Language, page), ctx, page)
}
开发者ID:razer1s,项目名称:quasar,代码行数:10,代码来源:shows.go


示例4: TopRatedMovies

func TopRatedMovies(ctx *gin.Context) {
	genre := ctx.Params.ByName("genre")
	if genre == "0" {
		genre = ""
	}
	page := -1
	if config.Get().EnablePaging == true {
		currentpage, err := strconv.Atoi(ctx.DefaultQuery("page", "0"))
		if err == nil {
			page = currentpage
		}
	}
	renderMovies(tmdb.TopRatedMoviesComplete(genre, config.Get().Language, page), ctx, page)
}
开发者ID:peer23peer,项目名称:quasar,代码行数:14,代码来源:movies.go


示例5: MakeQuasarRepositoryAddon

func MakeQuasarRepositoryAddon() error {
	addonId := "repository.quasar"
	addonName := "Quasar Repository"

	quasarHost := fmt.Sprintf("http://localhost:%d", config.ListenPort)
	addon := &xbmc.Addon{
		Id:           addonId,
		Name:         addonName,
		Version:      util.Version,
		ProviderName: config.Get().Info.Author,
		Extensions: []*xbmc.AddonExtension{
			&xbmc.AddonExtension{
				Point: "xbmc.addon.repository",
				Name:  addonName,
				Info: &xbmc.AddonRepositoryInfo{
					Text:       quasarHost + "/repository/scakemyer/plugin.video.quasar/addons.xml",
					Compressed: false,
				},
				Checksum: quasarHost + "/repository/scakemyer/plugin.video.quasar/addons.xml.md5",
				Datadir: &xbmc.AddonRepositoryDataDir{
					Text: quasarHost + "/repository/scakemyer/",
					Zip:  true,
				},
			},
			&xbmc.AddonExtension{
				Point: "xbmc.addon.metadata",
				Summaries: []*xbmc.AddonText{
					&xbmc.AddonText{"GitHub repository for Quasar Updates", "en"},
				},
				Platform: "all",
			},
		},
	}

	addonPath := filepath.Clean(filepath.Join(config.Get().Info.Path, "..", addonId))
	if err := os.MkdirAll(addonPath, 0777); err != nil {
		return err
	}

	if err := copyFile(filepath.Join(config.Get().Info.Path, "icon.png"), filepath.Join(addonPath, "icon.png")); err != nil {
		return err
	}

	addonXmlFile, err := os.Create(filepath.Join(addonPath, "addon.xml"))
	if err != nil {
		return err
	}
	defer addonXmlFile.Close()
	return xml.NewEncoder(addonXmlFile).Encode(addon)
}
开发者ID:peer23peer,项目名称:quasar,代码行数:50,代码来源:repository.go


示例6: PlayShow

func PlayShow(ctx *gin.Context) {
	if config.Get().ChooseStreamAuto == true {
		ShowEpisodePlay(ctx)
	} else {
		ShowEpisodeLinks(ctx)
	}
}
开发者ID:razer1s,项目名称:quasar,代码行数:7,代码来源:library.go


示例7: RemoveShow

func RemoveShow(ctx *gin.Context) {
	LibraryPath := config.Get().LibraryPath
	ShowsLibraryPath := filepath.Join(LibraryPath, "Shows")
	DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName))
	showId := ctx.Params.ByName("showId")
	show, err := tvdb.NewShow(showId, "en")
	if err != nil {
		ctx.String(404, "")
		return
	}
	ShowPath := filepath.Join(ShowsLibraryPath, toFileName(show.SeriesName))

	if err := RemoveFromJsonDB(DBPath, showId, LShow); err != nil {
		libraryLog.Info("Unable to remove show from db")
		ctx.String(404, "")
		return
	}

	if err := os.RemoveAll(ShowPath); err != nil {
		libraryLog.Info("Unable to remove show folder")
		ctx.String(404, "")
		return
	}

	xbmc.Notify("Quasar", "LOCALIZE[30222]", config.AddonIcon())
	ctx.String(200, "")
	xbmc.VideoLibraryClean()
	libraryLog.Info("Show removed")
}
开发者ID:razer1s,项目名称:quasar,代码行数:29,代码来源:library.go


示例8: PlayMovie

func PlayMovie(ctx *gin.Context) {
	if config.Get().ChooseStreamAuto == true {
		MoviePlay(ctx)
	} else {
		MovieLinks(ctx)
	}
}
开发者ID:razer1s,项目名称:quasar,代码行数:7,代码来源:library.go


示例9: CheckApiKey

func CheckApiKey() {
	tmdbLog.Info("Checking TMDB API key...")

	customApiKey := config.Get().TMDBApiKey
	if customApiKey != "" {
		apiKeys = append(apiKeys, customApiKey)
		apiKey = customApiKey
	}

	result := false
	for index := len(apiKeys); index >= 0; index-- {
		result = tmdbCheck(apiKey)
		if result {
			tmdbLog.Noticef("TMDB API key check passed, using %s...", apiKey[:7])
			break
		} else {
			tmdbLog.Warningf("TMDB API key failed: %s", apiKey)
			if apiKey == apiKeys[index] {
				apiKeys = append(apiKeys[:index], apiKeys[index+1:]...)
			}
			apiKey = apiKeys[rand.Int()%len(apiKeys)]
		}
	}
	if result == false {
		tmdbLog.Error("No valid TMDB API key found")
	}
}
开发者ID:felipejfc,项目名称:quasar,代码行数:27,代码来源:tmdb.go


示例10: GetCount

func GetCount(ctx *gin.Context) {
	LibraryPath := config.Get().LibraryPath
	DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName))
	var db DataBase

	if _, err := os.Stat(DBPath); err == nil {
		file, err := ioutil.ReadFile(DBPath)
		if err != nil {
			ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
			ctx.JSON(200, gin.H{
				"success": false,
			})
			return
		}
		json.Unmarshal(file, &db)
	}

	ctx.Writer.Header().Set("Access-Control-Allow-Origin", "*")
	ctx.JSON(200, gin.H{
		"success": true,
		"movies":  len(db.Movies),
		"shows":   len(db.Shows),
		"total":   len(db.Movies) + len(db.Shows),
	})
}
开发者ID:razer1s,项目名称:quasar,代码行数:25,代码来源:library.go


示例11: GetSurgeClearances

func GetSurgeClearances() {
	header := http.Header{
		"Content-type": []string{"application/json"},
	}
	params := napping.Params{}.AsUrlValues()

	req := napping.Request{
		Url:    fmt.Sprintf("%s/%s", "https://cloudhole.surge.sh", "cloudhole.json"),
		Method: "GET",
		Params: &params,
		Header: &header,
	}

	resp, err := napping.Send(&req)

	var tmpClearances []*Clearance
	if err == nil && resp.Status() == 200 {
		resp.Unmarshal(&tmpClearances)
	}

	apiKey := config.Get().CloudHoleKey
	for _, clearance := range tmpClearances {
		if clearance.Key == apiKey {
			clearances = append(clearances, clearance)
		}
	}
}
开发者ID:scakemyer,项目名称:quasar,代码行数:27,代码来源:cloudhole.go


示例12: 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


示例13: SearchMovies

func SearchMovies(query string, page string) (movies []*Movies, err error) {
	endPoint := "search"

	params := napping.Params{
		"page": page,
		"limit": strconv.Itoa(config.Get().ResultsPerPage),
		"query": query,
		"extended": "full,images",
	}.AsUrlValues()

	resp, err := Get(endPoint, params)

	if err != nil {
		return movies, err
	} else if resp.Status() != 200 {
		return movies, errors.New(fmt.Sprintf("SearchMovies bad status: %d", resp.Status()))
	}

  // TODO use response headers for pagination limits:
  // X-Pagination-Page-Count:10
  // X-Pagination-Item-Count:100

	resp.Unmarshal(&movies)
	return movies, err
}
开发者ID:scakemyer,项目名称:quasar,代码行数:25,代码来源:movies.go


示例14: Play

func Play(btService *bittorrent.BTService) gin.HandlerFunc {
	return func(ctx *gin.Context) {
		uri := ctx.Request.URL.Query().Get("uri")
		if uri == "" {
			return
		}
		fileIndex := -1
		index := ctx.Request.URL.Query().Get("index")
		if index != "" {
			fIndex, err := strconv.Atoi(index)
			if err == nil {
				fileIndex = fIndex
			}
		}
		torrent := bittorrent.NewTorrent(uri)
		magnet := torrent.Magnet()
		boosters := url.Values{
			"tr": providers.DefaultTrackers,
		}
		magnet += "&" + boosters.Encode()
		player := bittorrent.NewBTPlayer(btService, magnet, config.Get().KeepFilesAfterStop == false, fileIndex)
		if player.Buffer() != nil {
			return
		}
		hostname := "localhost"
		if localIP, err := util.LocalIP(); err == nil {
			hostname = localIP.String()
		}
		rUrl, _ := url.Parse(fmt.Sprintf("http://%s:%d/files/%s", hostname, config.ListenPort, player.PlayURL()))
		ctx.Redirect(302, rUrl.String())
	}
}
开发者ID:txesin,项目名称:quasar,代码行数:32,代码来源:play.go


示例15: TopShows

func TopShows(topCategory string, page string) (shows []*Shows, err error) {
	endPoint := "shows/" + topCategory

	params := napping.Params{
		"page":     page,
		"limit":    strconv.Itoa(config.Get().ResultsPerPage),
		"extended": "full,images",
	}.AsUrlValues()

	resp, err := Get(endPoint, params)

	if err != nil {
		return shows, err
	} else if resp.Status() != 200 {
		return shows, errors.New(fmt.Sprintf("TopShows bad status: %d", resp.Status()))
	}

	if topCategory == "popular" {
		var showList []*Show
		resp.Unmarshal(&showList)

		showListing := make([]*Shows, 0)
		for _, show := range showList {
			showItem := Shows{
				Show: show,
			}
			showListing = append(showListing, &showItem)
		}
		shows = showListing
	} else {
		resp.Unmarshal(&shows)
	}
	return shows, err
}
开发者ID:scakemyer,项目名称:quasar,代码行数:34,代码来源:shows.go


示例16: Post

func Post(endPoint string, payload *bytes.Buffer) (resp *napping.Response, err error) {
	header := http.Header{
		"Content-type":      []string{"application/json"},
		"Authorization":     []string{fmt.Sprintf("Bearer %s", config.Get().TraktToken)},
		"trakt-api-key":     []string{ClientId},
		"trakt-api-version": []string{ApiVersion},
		"User-Agent":        []string{clearance.UserAgent},
		"Cookie":            []string{clearance.Cookies},
	}

	req := napping.Request{
		Url:        fmt.Sprintf("%s/%s", ApiUrl, endPoint),
		Method:     "POST",
		RawPayload: true,
		Payload:    payload,
		Header:     &header,
	}

	resp, err = napping.Send(&req)
	if err == nil && resp.Status() == 403 && retries < 3 {
		retries += 1
		err = newClearance()
		if err == nil {
			resp, err = Post(endPoint, payload)
		}
	}

	return resp, err
}
开发者ID:scakemyer,项目名称:quasar,代码行数:29,代码来源:trakt.go


示例17: GetWithAuth

func GetWithAuth(endPoint string, params url.Values) (resp *napping.Response, err error) {
	header := http.Header{
		"Content-type":      []string{"application/json"},
		"Authorization":     []string{fmt.Sprintf("Bearer %s", config.Get().TraktToken)},
		"trakt-api-key":     []string{ClientId},
		"trakt-api-version": []string{ApiVersion},
		"User-Agent":        []string{clearance.UserAgent},
		"Cookie":            []string{clearance.Cookies},
	}

	req := napping.Request{
		Url:    fmt.Sprintf("%s/%s", ApiUrl, endPoint),
		Method: "GET",
		Params: &params,
		Header: &header,
	}

	resp, err = napping.Send(&req)
	if err == nil && resp.Status() == 403 && retries < 3 {
		retries += 1
		err = newClearance()
		if err == nil {
			resp, err = GetWithAuth(endPoint, params)
		}
	}

	return resp, err
}
开发者ID:scakemyer,项目名称:quasar,代码行数:28,代码来源:trakt.go


示例18: 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() {
			urlValues := napping.Params{
				"api_key":            apiKey,
				"append_to_response": "credits,images,alternative_titles,translations,external_ids",
				"language":           language,
			}.AsUrlValues()
			napping.Get(
				tmdbEndpoint+"tv/"+strconv.Itoa(showId),
				&urlValues,
				&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:abuisine,项目名称:quasar,代码行数:35,代码来源:show.go


示例19: TVIndex

func TVIndex(ctx *gin.Context) {
	items := xbmc.ListItems{
		{Label: "LOCALIZE[30209]", Path: UrlForXBMC("/shows/search"), Thumbnail: config.AddonResource("img", "search.png")},
		{Label: "LOCALIZE[30056]", Path: UrlForXBMC("/shows/trakt/"), Thumbnail: config.AddonResource("img", "trakt.png")},
		{Label: "LOCALIZE[30238]", Path: UrlForXBMC("/shows/recent/episodes"), Thumbnail: config.AddonResource("img", "fresh.png")},
		{Label: "LOCALIZE[30237]", Path: UrlForXBMC("/shows/recent/shows"), Thumbnail: config.AddonResource("img", "clock.png")},
		{Label: "LOCALIZE[30210]", Path: UrlForXBMC("/shows/popular"), Thumbnail: config.AddonResource("img", "popular.png")},
		{Label: "LOCALIZE[30211]", Path: UrlForXBMC("/shows/top"), Thumbnail: config.AddonResource("img", "top_rated.png")},
		{Label: "LOCALIZE[30212]", Path: UrlForXBMC("/shows/mostvoted"), Thumbnail: config.AddonResource("img", "most_voted.png")},
	}
	for _, genre := range tmdb.GetTVGenres(config.Get().Language) {
		slug, _ := genreSlugs[genre.Id]
		items = append(items, &xbmc.ListItem{
			Label:     genre.Name,
			Path:      UrlForXBMC("/shows/popular/%s", strconv.Itoa(genre.Id)),
			Thumbnail: config.AddonResource("img", fmt.Sprintf("genre_%s.png", slug)),
			ContextMenu: [][]string{
				[]string{"LOCALIZE[30237]", fmt.Sprintf("Container.Update(%s)", UrlForXBMC("/shows/recent/shows/%s", strconv.Itoa(genre.Id)))},
				[]string{"LOCALIZE[30238]", fmt.Sprintf("Container.Update(%s)", UrlForXBMC("/shows/recent/episodes/%s", strconv.Itoa(genre.Id)))},
			},
		})
	}

	ctx.JSON(200, xbmc.NewView("", items))
}
开发者ID:scakemyer,项目名称:quasar,代码行数:25,代码来源:shows.go


示例20: 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



注:本文中的github.com/scakemyer/quasar/config.Get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang xbmc.NewView函数代码示例发布时间:2022-05-28
下一篇:
Golang config.AddonResource函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap