Exemplo n.º 1
0
func main() {
	flag.Usage = usage
	flag.Parse()
	cachingHTTPClient = util.CachingHttpClient()

	if *tokenFlag == "" || cachingHTTPClient == nil {
		flag.Usage()
		return
	}

	ds = clientFlags.CreateDataset()
	if ds == nil {
		flag.Usage()
		return
	}
	defer ds.Store().Close()

	if err := clientFlags.CreateProgressFile(); err != nil {
		fmt.Println(err)
	} else {
		defer clientFlags.CloseProgressFile()
	}

	token := oauth2.Token{AccessToken: *tokenFlag}
	authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))

	start = time.Now()
	var user = getUser()
	printStats(user)

	userRef := ds.Store().WriteValue(user)
	fmt.Printf("userRef: %s\n", userRef.TargetRef())
	_, err := ds.Commit(userRef)
	d.Exp.NoError(err)
}
Exemplo n.º 2
0
func main() {
	flag.Usage = flickrUsage
	flag.Parse()

	httpClient = util.CachingHttpClient()

	if *clientIdFlag == "" || *clientSecretFlag == "" || httpClient == nil {
		flag.Usage()
		os.Exit(1)
	}

	ds = clientFlags.CreateDataset()
	if ds == nil {
		flag.Usage()
		os.Exit(1)
	}
	defer ds.Store().Close()

	if err := clientFlags.CreateProgressFile(); err != nil {
		fmt.Println(err)
	} else {
		defer clientFlags.CloseProgressFile()
	}

	oauthClient = oauth.Client{
		TemporaryCredentialRequestURI: "https://www.flickr.com/services/oauth/request_token",
		ResourceOwnerAuthorizationURI: "https://www.flickr.com/services/oauth/authorize",
		TokenRequestURI:               "https://www.flickr.com/services/oauth/access_token",
		Credentials: oauth.Credentials{
			Token:  *clientIdFlag,
			Secret: *clientSecretFlag,
		},
	}

	var tokenCred *oauth.Credentials
	if *tokenFlag != "" && *tokenSecretFlag != "" {
		tokenCred = &oauth.Credentials{*tokenFlag, *tokenSecretFlag}
	} else {
		tokenCred = requestTokenCredentials()
	}

	api := liveFlickrAPI{tokenCred}
	if !findUser() {
		if err := requestUser(api); err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	}

	progress := progressTracker{}
	progress.didLogin = true
	progress.Update()

	user = user.SetAlbums(getAlbums(api, &progress))
	commitUser()
}
Exemplo n.º 3
0
func main() {
	flag.Usage = picasaUsage
	flag.Parse()
	cachingHTTPClient = util.CachingHttpClient()

	if *tokenFlag == "" || cachingHTTPClient == nil {
		flag.Usage()
		os.Exit(1)
	}

	util.MaybeStartCPUProfile()
	defer util.StopCPUProfile()

	ds = clientFlags.CreateDataset()
	if ds == nil {
		flag.Usage()
		os.Exit(1)
	}
	defer ds.Store().Close()

	if err := clientFlags.CreateProgressFile(); err != nil {
		fmt.Println(err)
	} else {
		defer clientFlags.CloseProgressFile()
	}

	token := oauth2.Token{AccessToken: *tokenFlag}
	authHTTPClient = oauth2.NewClient(oauth2.NoContext, oauth2.StaticTokenSource(&token))

	start = time.Now()
	user := getUser()

	userRef := ds.Store().WriteValue(user)
	fmt.Printf("userRef: %s\n", userRef)
	_, err := ds.Commit(userRef)
	d.Exp.NoError(err)
}