picasa 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -4
- data/examples/add_tags_to_photo.rb +9 -14
- data/examples/create_new_album.rb +7 -12
- data/examples/delete_all_photos.rb +9 -13
- data/examples/download_all_albums.rb +24 -29
- data/examples/download_one_album.rb +18 -22
- data/examples/get_some_albums.rb +3 -8
- data/examples/get_some_photos.rb +5 -10
- data/examples/refresh-access-token.rb +29 -0
- data/examples/upload_photo.rb +12 -17
- data/lib/picasa/presenter/base.rb +1 -12
- data/lib/picasa/presenter/media.rb +6 -2
- data/lib/picasa/version.rb +1 -1
- data/picasa.gemspec +0 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c620c0f045fc74dc70cd23a64fbd92770c457e1
|
4
|
+
data.tar.gz: 52dada0a9d55ab05a8bf1d685445b727008c89fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ec8d9e5affa7181a84ab9536161bca5d53efb83749a90e45db4dc0759f080e1491728ae1c57191421661458cda13ac6bb14cc8f28c16b91fefda51a1362d89
|
7
|
+
data.tar.gz: ddcc148b54492c1db5b025e26c5ba71d70c86590c2402a8649517b64d1eece7d6f979221db5f41e7f9d454328bc73720f7d5025a235a76d910bc406c82a643b5
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Ruby library for [Picasa Web Albums Data API](https://developers.google.com/pica
|
|
8
8
|
gem install picasa
|
9
9
|
```
|
10
10
|
|
11
|
-
|
11
|
+
# Usage
|
12
12
|
|
13
13
|
[Documentation](http://rubydoc.info/github/morgoth/picasa)
|
14
14
|
|
@@ -24,7 +24,7 @@ client.photo.create("album_id", file_path: "path/to/my-photo.png")
|
|
24
24
|
# => Picasa::Presenter::Photo
|
25
25
|
```
|
26
26
|
|
27
|
-
|
27
|
+
## Authentication
|
28
28
|
|
29
29
|
When request is authenticated, response will contain private data, however this can be controlled by `access` parameter.
|
30
30
|
|
@@ -37,6 +37,8 @@ client = Picasa::Client.new(user_id: "some.user@gmail.com", access_token: "acces
|
|
37
37
|
As authenticating by providing password is no longer possible due to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps
|
38
38
|
you need to set `access_token` for authenticated requests.
|
39
39
|
|
40
|
+
### One time usage
|
41
|
+
|
40
42
|
For one time usage, you can retrieve access_token from google playground:
|
41
43
|
* Visit https://developers.google.com/oauthplayground
|
42
44
|
* Find "Picasa Web v2"
|
@@ -46,7 +48,50 @@ For one time usage, you can retrieve access_token from google playground:
|
|
46
48
|
|
47
49
|
OAuth2 integration is not yet supported in this gem.
|
48
50
|
|
49
|
-
###
|
51
|
+
### Permanent server side usage
|
52
|
+
|
53
|
+
* Go to https://console.developers.google.com
|
54
|
+
* Register an account and create project
|
55
|
+
* On "APIs & auth > Credentials" click "Create new Client ID"
|
56
|
+
* Choose "Installed application > Other"
|
57
|
+
* Note "Client ID" and "Client secret"
|
58
|
+
* Craft URL replacing `YOUR_CLIENT_ID` `https://accounts.google.com/o/oauth2/auth?scope=http://picasaweb.google.com/data/&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&client_id=YOUR_CLIENT_ID`
|
59
|
+
* Visit URL, grant access to your account and note `code`
|
60
|
+
* Install gem `signet`
|
61
|
+
* One time setup, to fetch `refresh_token`
|
62
|
+
```ruby
|
63
|
+
client_id = "client-id"
|
64
|
+
client_secret = "client-secret"
|
65
|
+
code = "authorization-code"
|
66
|
+
|
67
|
+
require "signet/oauth_2/client"
|
68
|
+
signet = Signet::OAuth2::Client.new(
|
69
|
+
code: code,
|
70
|
+
token_credential_uri: "https://www.googleapis.com/oauth2/v3/token",
|
71
|
+
client_id: client_id,
|
72
|
+
client_secret: client_secret,
|
73
|
+
redirect_uri: "urn:ietf:wg:oauth:2.0:oob"
|
74
|
+
)
|
75
|
+
signet.fetch_access_token!
|
76
|
+
signet.refresh_token
|
77
|
+
```
|
78
|
+
* Note `refresh_token`
|
79
|
+
* Before gem usage, you can get `access_token` by:
|
80
|
+
```ruby
|
81
|
+
require "signet/oauth_2/client"
|
82
|
+
signet = Signet::OAuth2::Client.new(
|
83
|
+
client_id: client_id,
|
84
|
+
client_secret: client_secret,
|
85
|
+
token_credential_uri: "https://www.googleapis.com/oauth2/v3/token",
|
86
|
+
refresh_token: refresh_token
|
87
|
+
)
|
88
|
+
signet.refresh!
|
89
|
+
|
90
|
+
# Use access token with picasa gem
|
91
|
+
signet.access_token
|
92
|
+
```
|
93
|
+
|
94
|
+
## Proxy
|
50
95
|
|
51
96
|
You can connect via proxy server setting `https_proxy` or `HTTPS_PROXY` environment variable to valid URL.
|
52
97
|
|
@@ -82,7 +127,7 @@ If you run out of quota and want to resize images to fit Picasa free storage lim
|
|
82
127
|
thor imagery:resize path-to-folder-with-photos
|
83
128
|
```
|
84
129
|
|
85
|
-
|
130
|
+
## Boost
|
86
131
|
|
87
132
|
Picasa uses gzipped requests to speedup fetching results. Benchmarks are available on [Vinicius Teles gist](https://gist.github.com/4012466)
|
88
133
|
|
@@ -1,20 +1,15 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
3
|
# add tags to your photos in an album.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
album = albums.find { |album| album.title == "New Album" }
|
4
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
5
|
+
albums = client.album.list.entries
|
6
|
+
album = albums.find { |album| album.title == "New Album" }
|
8
7
|
|
9
|
-
|
8
|
+
photos = client.album.show(album.id).entries
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
rescue Picasa::ForbiddenError
|
19
|
-
puts "You have the wrong user_id or password."
|
10
|
+
photos.each do |photo|
|
11
|
+
client.tag.create(
|
12
|
+
:album_id => album.id,
|
13
|
+
:photo_id => photo.id,
|
14
|
+
:tag_name => "test")
|
20
15
|
end
|
@@ -1,14 +1,9 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
)
|
11
|
-
|
12
|
-
rescue Picasa::ForbiddenError
|
13
|
-
puts "You have the wrong user_id or password."
|
14
|
-
end
|
3
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
4
|
+
# create new album.
|
5
|
+
client.album.create(
|
6
|
+
:title => "New Album",
|
7
|
+
:summary => "This is a new album.",
|
8
|
+
:access => "protected"
|
9
|
+
)
|
@@ -1,20 +1,16 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
3
|
# delete all photos in an album.
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
album = albums.find { |album| album.title == "New Album" }
|
4
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
5
|
+
albums = client.album.list.entries
|
6
|
+
album = albums.find { |album| album.title == "New Album" }
|
8
7
|
|
9
|
-
|
8
|
+
photos = client.album.show(album.id).entries
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
photos.each do |photo|
|
11
|
+
if client.tag.delete(album_id, photo.id)
|
12
|
+
"#{photo.title} deleted"
|
13
|
+
else
|
14
|
+
"#{photo.title} failed to delete"
|
17
15
|
end
|
18
|
-
rescue Picasa::ForbiddenError
|
19
|
-
puts "You have the wrong user_id or password."
|
20
16
|
end
|
@@ -7,35 +7,30 @@ require "open-uri"
|
|
7
7
|
username = "user@gmail.com"
|
8
8
|
dir = "/Users/path.../"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
puts e
|
28
|
-
end
|
29
|
-
|
30
|
-
open(get_string) do |f|
|
31
|
-
File.open(photo.title, "wb") do |file|
|
32
|
-
file.puts f.read
|
33
|
-
end
|
34
|
-
end
|
35
|
-
puts "======================================"
|
10
|
+
client = Picasa::Client.new(:user_id => username)
|
11
|
+
albums = client.album.list.entries
|
12
|
+
|
13
|
+
albums.each do |album|
|
14
|
+
Dir.chdir(dir)
|
15
|
+
this_album = client.album.show(album.id).entries
|
16
|
+
Dir.mkdir(album.title)
|
17
|
+
Dir.chdir(album.title)
|
18
|
+
|
19
|
+
for photo in this_album
|
20
|
+
begin
|
21
|
+
get_string = photo.content.src
|
22
|
+
puts "processing" << photo.id
|
23
|
+
|
24
|
+
rescue Exception => e
|
25
|
+
puts photo.id << " **ERROR**"
|
26
|
+
puts e
|
36
27
|
end
|
37
|
-
end
|
38
28
|
|
39
|
-
|
40
|
-
|
29
|
+
open(get_string) do |f|
|
30
|
+
File.open(photo.title, "wb") do |file|
|
31
|
+
file.puts f.read
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts "======================================"
|
35
|
+
end
|
41
36
|
end
|
@@ -7,31 +7,27 @@ require "open-uri"
|
|
7
7
|
username = "user@gmail.com"
|
8
8
|
dir = "/Users/path.../"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
albums = client.album.list.entries
|
10
|
+
client = Picasa::Client.new(:user_id => username)
|
11
|
+
albums = client.album.list.entries
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
album = albums.find { |album| album.title == "your_album_name" }
|
14
|
+
photos = client.album.show(album.id).entries
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
photos.each do |photo|
|
17
|
+
begin
|
18
|
+
get_string = photo.content.src
|
19
|
+
puts "processing " << photo.id
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
rescue Exception => e
|
22
|
+
puts photo.id << " **ERROR**"
|
23
|
+
puts e
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
puts "======================================"
|
25
|
+
Dir.chdir(dir)
|
26
|
+
open(get_string) do |f|
|
27
|
+
File.open(photo.title, "wb") do |file|
|
28
|
+
file.puts f.read
|
29
|
+
end
|
33
30
|
end
|
34
|
-
|
35
|
-
|
36
|
-
puts "You have the wrong user_id or password."
|
31
|
+
puts "======================================"
|
32
|
+
end
|
37
33
|
end
|
data/examples/get_some_albums.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
3
|
# get some albums.
|
4
|
-
|
5
|
-
client = Picasa::Client.new(:user_id => "your_gmail_account", :password => "password")
|
4
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
rescue Picasa::ForbiddenError
|
11
|
-
puts "You have the wrong user_id or password."
|
12
|
-
end
|
6
|
+
albums = client.album.list.entries
|
7
|
+
albums.each { |album| puts album.title }
|
data/examples/get_some_photos.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
3
|
# get some photos in an album
|
4
|
-
|
5
|
-
client = Picasa::Client.new(:user_id => "your_gmail_account", :password => "password")
|
4
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
albums = client.album.list.entries
|
7
|
+
album = albums.find { |album| album.title == "New Album" }
|
9
8
|
|
10
|
-
|
9
|
+
photos = client.album.show(album.id).entries
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
rescue Picasa::ForbiddenError
|
15
|
-
puts "You have the wrong user_id or password."
|
16
|
-
end
|
11
|
+
photos.each { |photo| puts photo.title }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "signet/oauth_2/client"
|
2
|
+
|
3
|
+
# Setup your private credentials
|
4
|
+
client_id = "client-id"
|
5
|
+
client_secret = "client-secret"
|
6
|
+
code = "authorization-code"
|
7
|
+
|
8
|
+
signet = Signet::OAuth2::Client.new(
|
9
|
+
code: code,
|
10
|
+
token_credential_uri: "https://www.googleapis.com/oauth2/v3/token",
|
11
|
+
client_id: client_id,
|
12
|
+
client_secret: client_secret,
|
13
|
+
redirect_uri: "urn:ietf:wg:oauth:2.0:oob"
|
14
|
+
)
|
15
|
+
signet.fetch_access_token!
|
16
|
+
refresh_token = signet.refresh_token
|
17
|
+
# Note and store refresh_token
|
18
|
+
|
19
|
+
# In your app fetch access_token by:
|
20
|
+
signet = Signet::OAuth2::Client.new(
|
21
|
+
client_id: client_id,
|
22
|
+
client_secret: client_secret,
|
23
|
+
token_credential_uri: "https://www.googleapis.com/oauth2/v3/token",
|
24
|
+
refresh_token: refresh_token
|
25
|
+
)
|
26
|
+
signet.refresh!
|
27
|
+
|
28
|
+
# Use access token with picasa gem
|
29
|
+
signet.access_token
|
data/examples/upload_photo.rb
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
require "picasa"
|
2
2
|
|
3
3
|
# upload photo
|
4
|
-
|
5
|
-
client = Picasa::Client.new(:user_id => "your_gmail_account", :password => "password")
|
4
|
+
client = Picasa::Client.new(user_id: "your-gmail-account@gmail.com", access_token: "oauth-access-token")
|
6
5
|
|
7
|
-
|
6
|
+
photo_bin = File.binread("./test.jpg")
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
albums = client.album.list.entries
|
9
|
+
album = albums.find { |album| album.title == "New Album" }
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
rescue Picasa::ForbiddenError
|
22
|
-
puts "You have the wrong user_id or password."
|
23
|
-
end
|
11
|
+
client.photo.create(album.id,
|
12
|
+
{
|
13
|
+
:binary => photo_bin,
|
14
|
+
:content_type => "image/jpeg",
|
15
|
+
:title => "Test Photo",
|
16
|
+
:summary => "Hoge hoge"
|
17
|
+
}
|
18
|
+
)
|
@@ -10,18 +10,7 @@ module Picasa
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def inspect
|
13
|
-
|
14
|
-
value = send(method)
|
15
|
-
value = value.nil? ? "nil" : value.inspect
|
16
|
-
"#{method}: #{value}"
|
17
|
-
end.join(", ")
|
18
|
-
"#<#{self.class} #{inspection}>"
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def methods_to_inspect
|
24
|
-
public_methods - Object.methods - [:parsed_body, :entries]
|
13
|
+
"#<#{self.class}>"
|
25
14
|
end
|
26
15
|
end
|
27
16
|
end
|
@@ -10,12 +10,16 @@ module Picasa
|
|
10
10
|
|
11
11
|
# @return [String]
|
12
12
|
def cover_photo_url
|
13
|
-
@cover_photo_url
|
13
|
+
return @cover_photo_url if defined?(@cover_photo_url)
|
14
|
+
content = safe_retrieve(parsed_body, "media$content")
|
15
|
+
@cover_photo_url = content && content[0]["url"]
|
14
16
|
end
|
15
17
|
|
16
18
|
# @return [String]
|
17
19
|
def credit
|
18
|
-
@credit
|
20
|
+
return @credit if defined?(@credit)
|
21
|
+
content = safe_retrieve(parsed_body, "media$credit")
|
22
|
+
@credit = content && content[0]["$t"]
|
19
23
|
end
|
20
24
|
|
21
25
|
# @return [String]
|
data/lib/picasa/version.rb
CHANGED
data/picasa.gemspec
CHANGED
@@ -28,6 +28,4 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "webmock"
|
29
29
|
spec.add_development_dependency "mocha", ">= 0.13.0"
|
30
30
|
spec.add_development_dependency "vcr", ">= 2.4.0"
|
31
|
-
|
32
|
-
spec.post_install_message = "Authenticating by providing password is no longer possible due to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps You need to set `access_token` for authenticated requests now."
|
33
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: picasa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Wnętrzak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- examples/download_one_album.rb
|
129
129
|
- examples/get_some_albums.rb
|
130
130
|
- examples/get_some_photos.rb
|
131
|
+
- examples/refresh-access-token.rb
|
131
132
|
- examples/upload_photo.rb
|
132
133
|
- extra/Thorfile
|
133
134
|
- lib/picasa.rb
|
@@ -203,9 +204,7 @@ homepage: https://github.com/morgoth/picasa
|
|
203
204
|
licenses:
|
204
205
|
- MIT
|
205
206
|
metadata: {}
|
206
|
-
post_install_message:
|
207
|
-
to google API shutdown https://developers.google.com/accounts/docs/AuthForInstalledApps
|
208
|
-
You need to set `access_token` for authenticated requests now.
|
207
|
+
post_install_message:
|
209
208
|
rdoc_options: []
|
210
209
|
require_paths:
|
211
210
|
- lib
|
@@ -221,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
220
|
version: '0'
|
222
221
|
requirements: []
|
223
222
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.4.
|
223
|
+
rubygems_version: 2.4.8
|
225
224
|
signing_key:
|
226
225
|
specification_version: 4
|
227
226
|
summary: Simple Google Picasa managment
|
@@ -261,3 +260,4 @@ test_files:
|
|
261
260
|
- test/presenter/photo_test.rb
|
262
261
|
- test/template_test.rb
|
263
262
|
- test/utils_test.rb
|
263
|
+
has_rdoc:
|