func Authorize(fromSettings bool) error { code, err := GetCode() if err != nil { xbmc.Notify("Quasar", err.Error(), config.AddonIcon()) return err } log.Noticef("Got code for %s: %s", code.VerificationURL, code.UserCode) if xbmc.Dialog("LOCALIZE[30058]", fmt.Sprintf("Visit %s and enter your code: %s", code.VerificationURL, code.UserCode)) == false { return errors.New("Authentication canceled.") } token, err := PollToken(code) if err != nil { xbmc.Notify("Quasar", err.Error(), config.AddonIcon()) return err } success := "Woohoo!" if fromSettings { success += " (Save your settings!)" } xbmc.Notify("Quasar", success, config.AddonIcon()) xbmc.SetSetting("trakt_token", token.AccessToken) xbmc.SetSetting("trakt_refresh_token", token.RefreshToken) return nil }
func SetViewMode(ctx *gin.Context) { content_type := ctx.Params.ByName("content_type") viewName := xbmc.InfoLabel("Container.Viewmode") viewMode := xbmc.GetCurrentView() cmdLog.Noticef("ViewMode: %s (%s)", viewName, viewMode) if viewMode != "0" { xbmc.SetSetting("viewmode_"+content_type, viewMode) } ctx.String(200, "") }