-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
111 lines (99 loc) · 2.82 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
require "picasa"
picasa = Picasa::Picasa.new
puts picasa.login("fattah.uign@gmail.com", "donttryme")
puts picasa.picasa_session.auth_key
tags = picasa.tags(:user_id => "someone", :access => "public")
tags.each do |tag|
puts "===== Tag ======"
puts tag.id
puts tag.title
puts tag.self_xml_url
photos = tag.photos
if(photos.size > 0)
photos.each do |photo|
puts "====== Photo ====="
puts photo.id
puts photo.title
puts photo.url
photo.thumbnails.each do |thumbnail|
puts thumbnail.url
puts thumbnail.width
puts thumbnail.height
end
end
else
puts "====== No photo for this tag ====="
end
albums = []
########### get albums of logged in account ############
albums = picasa.albums(:access => "private")
albums.each do |album|
puts "===== Album ======"
puts album.id
puts album.name
puts album.thumbnail.url
puts album.thumbnail.width
puts album.thumbnail.height
############ get photos of an album ############
photos = album.photos
if(photos.size > 0)
photos.each do |photo|
puts "====== Photo ====="
puts photo.id
puts photo.title
puts photo.url
photo.thumbnails.each do |thumbnail|
puts thumbnail.url
puts thumbnail.width
puts thumbnail.height
end
end
else
puts "====== No photo for this album ====="
end
end
######## get photos using album name #############
photos = picasa.photos(:album => "AlbumFromRuby")
puts "====== Photos of AlbumFromRuby ====="
if(photos.size > 0)
photos.each do |photo|
puts "====== Photos ====="
puts photo.id
puts photo.title
puts photo.url
photo.thumbnails.each do |thumbnail|
puts thumbnail.url
puts thumbnail.width
puts thumbnail.height
end
end
else
puts "====== No photo for this album ====="
end
############ get photos using another user_id and album name ############
photos = []
photos = albums[0].photos(:user_id => "fattah.uign")
photos.each do |photo|
puts photo.id
puts photo.title
puts photo.description
puts photo.url
photo.thumbnails.each do |thumbnail|
puts thumbnail.url
puts thumbnail.width
puts thumbnail.height
end
puts "====== Photo ====="
end
############ Create an album ###############
album = picasa.create_album(:title => "Album From Ruby",
:summary => "This album is created from ruby code",
:location => "Bangladesh", :keywords => "keyword1, keyword2")
puts album.inspect
############ Post photo to an album ########
fileName = "C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/Blue hills.jpg"
image_data = open(fileName, "rb").read
photo = picasa.post_photo(image_data, :album => "AlbumFromRuby",
:summary => "Upload2 from ruby api", :title => "From Ruby 2",
:local_file_name => "Blue hills.jpg")
puts photo.inspect