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

Golang config.Get函数代码示例

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

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



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

示例1: 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:daniloharuo,项目名称:pulsar,代码行数:10,代码来源:movies.go


示例2: TopRatedShows

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


示例3: MakePulsarRepositoryAddon

func MakePulsarRepositoryAddon() error {
	addonId := "repository.pulsar"
	addonName := "Pulsar Repository"

	pulsarHost := 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:       pulsarHost + "/repository/steeve/plugin.video.pulsar/addons.xml",
					Compressed: false,
				},
				Checksum: pulsarHost + "/repository/steeve/plugin.video.pulsar/addons.xml.md5",
				Datadir: &xbmc.AddonRepositoryDataDir{
					Text: pulsarHost + "/repository/steeve/",
					Zip:  true,
				},
			},
			&xbmc.AddonExtension{
				Point: "xbmc.addon.metadata",
				Summaries: []*xbmc.AddonText{
					&xbmc.AddonText{"Virtual repository for Pulsar 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:daniloharuo,项目名称:pulsar,代码行数:50,代码来源:repository.go


示例4: PopularMovies

func PopularMovies(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.PopularMoviesComplete(genre, config.Get().Language, page), ctx, page)
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:14,代码来源:movies.go


示例5: 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() {
			p := 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),
				&p,
				&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:daniloharuo,项目名称:pulsar,代码行数:31,代码来源:show.go


示例6: 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() {
			p := napping.Params{"api_key": apiKey, "append_to_response": "credits,images,alternative_titles,translations,external_ids,trailers", "language": language}.AsUrlValues()
			napping.Get(
				tmdbEndpoint+"movie/"+movieId,
				&p,
				&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:daniloharuo,项目名称:pulsar,代码行数:30,代码来源:movie.go


示例7: call

func (as *AddonSearcher) call(method string, searchObject interface{}) []*bittorrent.Torrent {
	torrents := make([]*bittorrent.Torrent, 0)
	cid, c := GetCallback()
	cbUrl := fmt.Sprintf("%s/callbacks/%s", util.GetHTTPHost(), cid)

	payload := &SearchPayload{
		Method:       method,
		CallbackURL:  cbUrl,
		SearchObject: searchObject,
	}

	xbmc.ExecuteAddon(as.addonId, payload.String())

	timeout := providerTimeout()
	conf := config.Get()
	if conf.CustomProviderTimeoutEnabled == true {
		timeout = time.Duration(conf.CustomProviderTimeout) * time.Second
	}

	select {
	case <-time.After(timeout):
		as.log.Info("Provider %s was too slow. Ignored.", as.addonId)
		RemoveCallback(cid)
	case result := <-c:
		json.Unmarshal(result, &torrents)
	}

	return torrents
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:29,代码来源:xbmc.go


示例8: ShowEpisodes

func ShowEpisodes(ctx *gin.Context) {
	show, err := tvdb.NewShowCached(ctx.Params.ByName("showId"), config.Get().Language)
	if err != nil {
		ctx.Error(err)
		return
	}

	seasonNumber, _ := strconv.Atoi(ctx.Params.ByName("season"))

	season := show.Seasons[seasonNumber]
	items := season.Episodes.ToListItems(show)
	for _, item := range items {
		item.Path = UrlForXBMC("/show/%d/season/%d/episode/%d/play",
			show.Id,
			season.Season,
			item.Info.Episode,
		)
		item.ContextMenu = [][]string{
			[]string{"LOCALIZE[30202]", fmt.Sprintf("XBMC.PlayMedia(%s)", UrlForXBMC("/show/%d/season/%d/episode/%d/links",
				show.Id,
				season.Season,
				item.Info.Episode,
			))},
			[]string{"LOCALIZE[30203]", "XBMC.Action(Info)"},
		}
		item.IsPlayable = true
	}

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


示例9: SearchMovies

func SearchMovies(ctx *gin.Context) {
	query := ctx.Request.URL.Query().Get("q")
	if query == "" {
		query = xbmc.Keyboard("", "LOCALIZE[30206]")
		if query == "" {
			return
		}
	}
	renderMovies(tmdb.SearchMovies(query, config.Get().Language), ctx, -1)
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:10,代码来源:movies.go


示例10: Migrate

func Migrate() {
	firstRun := filepath.Join(config.Get().Info.Path, ".firstrun")
	if _, err := os.Stat(firstRun); err == nil {
		return
	}
	file, _ := os.Create(firstRun)
	defer file.Close()

	log.Info("Preparing for first run")

	// Move ga client id file out of the cache directory
	gaFile := filepath.Join(config.Get().Info.Profile, "cache", "io.steeve.pulsar.ga")
	if _, err := os.Stat(gaFile); err == nil {
		os.Rename(gaFile, filepath.Join(config.Get().Info.Profile, "io.steeve.pulsar.ga"))
	}

	gaFile = filepath.Join(config.Get().Info.Profile, "io.steeve.pulsar.ga")
	if file, err := os.Open(gaFile); err == nil {
		if gzReader, err := gzip.NewReader(file); err != nil {
			outFile, _ := os.Create(gaFile + ".gz")
			gzWriter := gzip.NewWriter(outFile)
			file.Seek(0, os.SEEK_SET)
			io.Copy(gzWriter, file)
			gzWriter.Flush()
			gzWriter.Close()
			outFile.Close()
			file.Close()
			os.Rename(gaFile+".gz", gaFile)
		} else {
			gzReader.Close()
		}
	}

	// Remove the cache
	log.Info("Clearing cache")
	os.RemoveAll(filepath.Join(config.Get().Info.Profile, "cache"))

	log.Info("Creating Pulsar Repository Addon")
	if err := repository.MakePulsarRepositoryAddon(); err != nil {
		log.Error("Unable to create repository addon: %s", err)
	}
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:42,代码来源:migration.go


示例11: getClientId

func getClientId() string {
	clientId := ""
	key := "io.steeve.pulsar.ga"
	cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath))
	if err := cacheStore.Get(key, &clientId); err != nil {
		clientUUID, _ := uuid.NewV4()
		clientId := clientUUID.String()
		cacheStore.Set(key, clientId, clientIdCacheTime)
	}
	return clientId
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:11,代码来源:ga.go


示例12: MovieGenres

func MovieGenres(ctx *gin.Context) {
	genres := tmdb.GetMovieGenres(config.Get().Language)
	items := make(xbmc.ListItems, 0, len(genres))
	for _, genre := range genres {
		items = append(items, &xbmc.ListItem{
			Label: genre.Name,
			Path:  UrlForXBMC("/movies/popular/%s", strconv.Itoa(genre.Id)),
		})
	}

	ctx.JSON(200, xbmc.NewView("", items))
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:12,代码来源:movies.go


示例13: movieLinks

func movieLinks(imdbId string) []*bittorrent.Torrent {
	log.Println("Searching links for IMDB:", imdbId)

	movie := tmdb.GetMovieFromIMDB(imdbId, config.Get().Language)

	log.Printf("Resolved %s to %s\n", imdbId, movie.Title)

	searchers := providers.GetMovieSearchers()
	if len(searchers) == 0 {
		xbmc.Notify("Pulsar", "LOCALIZE[30204]", config.AddonIcon())
	}

	return providers.SearchMovie(searchers, movie)
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:14,代码来源:movies.go


示例14: TVIndex

func TVIndex(ctx *gin.Context) {
	items := xbmc.ListItems{
		{Label: "LOCALIZE[30209]", Path: UrlForXBMC("/shows/search"), Thumbnail: config.AddonResource("img", "search.png")},
		{Label: "LOCALIZE[30210]", Path: UrlForXBMC("/shows/popular"), Thumbnail: config.AddonResource("img", "popular.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)),
		})
	}

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


示例15: NewShowCached

func NewShowCached(tvdbId string, language string) (*Show, error) {
	var show *Show
	cacheStore := cache.NewFileStore(path.Join(config.Get().ProfilePath, "cache"))
	key := fmt.Sprintf("com.tvdb.show.%s.%s", tvdbId, language)
	if err := cacheStore.Get(key, &show); err != nil {
		newShow, err := NewShow(tvdbId, language)
		if err != nil {
			return nil, err
		}
		if newShow != nil {
			cacheStore.Set(key, newShow, cacheTime)
		}
		show = newShow
	}
	return show, nil
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:16,代码来源:tvdb.go


示例16: ShowSeasons

func ShowSeasons(ctx *gin.Context) {
	show, err := tvdb.NewShowCached(ctx.Params.ByName("showId"), config.Get().Language)
	if err != nil {
		ctx.Error(err)
		return
	}

	items := show.Seasons.ToListItems(show)
	reversedItems := make(xbmc.ListItems, 0)
	for i := len(items) - 1; i >= 0; i-- {
		item := items[i]
		item.Path = UrlForXBMC("/show/%d/season/%d/episodes", show.Id, item.Info.Season)
		reversedItems = append(reversedItems, item)
	}
	// xbmc.ListItems always returns false to Less() so that order is unchanged

	ctx.JSON(200, xbmc.NewView("seasons", reversedItems))
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:18,代码来源:shows.go


示例17: showEpisodeLinks

func showEpisodeLinks(showId string, seasonNumber, episodeNumber int) ([]*bittorrent.Torrent, error) {
	log.Println("Searching links for TVDB Id:", showId)

	show, err := tvdb.NewShowCached(showId, config.Get().Language)
	if err != nil {
		return nil, err
	}

	episode := show.Seasons[seasonNumber].Episodes[episodeNumber-1]

	log.Printf("Resolved %s to %s\n", showId, show.SeriesName)

	searchers := providers.GetEpisodeSearchers()
	if len(searchers) == 0 {
		xbmc.Notify("Pulsar", "LOCALIZE[30204]", config.AddonIcon())
	}

	return providers.SearchEpisode(searchers, show, episode), nil
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:19,代码来源:shows.go


示例18: 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() {
			p := napping.Params{"api_key": apiKey, "external_source": externalSource}.AsUrlValues()
			napping.Get(
				tmdbEndpoint+"find/"+externalId,
				&p,
				&result,
				nil,
			)
			cacheStore.Set(key, result, 365*24*time.Hour)
		})
	}

	return result
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:20,代码来源:tmdb.go


示例19: Play

func Play(btService *bittorrent.BTService) gin.HandlerFunc {
	return func(ctx *gin.Context) {
		uri := ctx.Request.URL.Query().Get("uri")
		if uri == "" {
			return
		}
		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)
		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:daniloharuo,项目名称:pulsar,代码行数:24,代码来源:play.go


示例20: main

func main() {
	// Make sure we are properly multithreaded.
	runtime.GOMAXPROCS(runtime.NumCPU())

	logging.SetFormatter(logging.MustStringFormatter("%{time:2006-01-02 15:04:05}  %{level:.4s}  %{module:-15s}  %{message}"))
	logging.SetBackend(logging.NewLogBackend(os.Stdout, "", 0))

	for _, line := range strings.Split(PulsarLogo, "\n") {
		log.Info(line)
	}
	log.Info("Version: %s Git: %s Go: %s", util.Version, util.GitCommit, runtime.Version())

	conf := config.Reload()

	ensureSingleInstance()
	Migrate()

	xbmc.CloseAllDialogs()

	log.Info("Addon: %s v%s", conf.Info.Id, conf.Info.Version)

	btService := bittorrent.NewBTService(*makeBTConfiguration(conf))

	var shutdown = func() {
		log.Info("Shutting down...")
		btService.Close()
		log.Info("Bye bye")
		os.Exit(0)
	}

	var watchParentProcess = func() {
		for {
			// did the parent die? shutdown!
			if os.Getppid() == 1 {
				log.Warning("Parent shut down. Me too.")
				go shutdown()
				break
			}
			time.Sleep(1 * time.Second)
		}
	}
	go watchParentProcess()

	http.Handle("/", api.Routes(btService))
	http.Handle("/files/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		handler := http.StripPrefix("/files/", http.FileServer(bittorrent.NewTorrentFS(btService, config.Get().DownloadPath)))
		handler.ServeHTTP(w, r)
	}))
	http.Handle("/reload", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		btService.Reconfigure(*makeBTConfiguration(config.Reload()))
	}))
	http.Handle("/shutdown", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		shutdown()
	}))

	xbmc.Notify("Pulsar", "LOCALIZE[30208]", config.AddonIcon())

	http.ListenAndServe(":"+strconv.Itoa(config.ListenPort), nil)
}
开发者ID:daniloharuo,项目名称:pulsar,代码行数:59,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang log.Error函数代码示例发布时间:2022-05-28
下一篇:
Golang prago.Request类代码示例发布时间: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