本文整理汇总了Golang中github.com/scakemyer/quasar/config.Get函数的典型用法代码示例。如果您正苦于以下问题:Golang Get函数的具体用法?Golang Get怎么用?Golang Get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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))
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例6: PlayShow
func PlayShow(ctx *gin.Context) {
if config.Get().ChooseStreamAuto == true {
ShowEpisodePlay(ctx)
} else {
ShowEpisodeLinks(ctx)
}
}
示例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")
}
示例8: PlayMovie
func PlayMovie(ctx *gin.Context) {
if config.Get().ChooseStreamAuto == true {
MoviePlay(ctx)
} else {
MovieLinks(ctx)
}
}
示例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")
}
}
示例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),
})
}
示例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: ¶ms,
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)
}
}
}
示例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
}
示例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
}
示例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())
}
}
示例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
}