caring-r2flickr 0.1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENCE +278 -0
- data/README +50 -0
- data/examples/album_test.rb +30 -0
- data/examples/comics-reorder.rb +16 -0
- data/examples/loadr.rb +80 -0
- data/examples/relatedness.rb +65 -0
- data/examples/setdumpr.rb +46 -0
- data/lib/flickr.rb +20 -0
- data/lib/flickr/auth.rb +60 -0
- data/lib/flickr/base.rb +811 -0
- data/lib/flickr/blogs.rb +30 -0
- data/lib/flickr/comments.rb +35 -0
- data/lib/flickr/contacts.rb +48 -0
- data/lib/flickr/favorites.rb +59 -0
- data/lib/flickr/groups.rb +83 -0
- data/lib/flickr/interestingness.rb +19 -0
- data/lib/flickr/licenses.rb +23 -0
- data/lib/flickr/notes.rb +24 -0
- data/lib/flickr/people.rb +79 -0
- data/lib/flickr/photos.rb +293 -0
- data/lib/flickr/photosets.rb +102 -0
- data/lib/flickr/pools.rb +73 -0
- data/lib/flickr/reflection.rb +89 -0
- data/lib/flickr/tags.rb +59 -0
- data/lib/flickr/test.rb +20 -0
- data/lib/flickr/token_cache.rb +33 -0
- data/lib/flickr/transform.rb +11 -0
- data/lib/flickr/upload.rb +205 -0
- data/lib/flickr/urls.rb +50 -0
- metadata +82 -0
data/lib/flickr/blogs.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Blogs < Flickr::APIBase
|
4
|
+
|
5
|
+
def getList()
|
6
|
+
return @flickr.blog_cache_lookup if @flickr.blog_cache_lookup
|
7
|
+
res = @flickr.call_method('flickr.blogs.getList')
|
8
|
+
list = []
|
9
|
+
res.elements['/blogs'].each_element do |e|
|
10
|
+
att = e.attributes
|
11
|
+
list << Flickr::Blog.new(att['id'], att['name'],
|
12
|
+
att['needspassword'].to_i == 1, att['url'])
|
13
|
+
end
|
14
|
+
@flickr.blog_cache_store(list)
|
15
|
+
return list
|
16
|
+
end
|
17
|
+
|
18
|
+
# blog can be either an integer blog ID or a Blog object
|
19
|
+
# photo can be either an integer photo ID or a Photo object
|
20
|
+
def postPhoto(blog, photo, title, description, blog_password=nil)
|
21
|
+
blog = blog.id if blog.class == Flickr::Blog
|
22
|
+
photo = photo.id if photo.class == Flickr::Photo
|
23
|
+
|
24
|
+
args={'blog'=>blog,'photo'=>photo,'title'=>title,
|
25
|
+
description=>'description'}
|
26
|
+
args['blogs_password'] = blog_password if blog_password
|
27
|
+
|
28
|
+
@flickr.call_method('flickr.blogs.postPhoto',args)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Comments < Flickr::APIBase
|
4
|
+
|
5
|
+
def add(photo, comment)
|
6
|
+
photo = photo.id if photo.class == Flickr::Photo
|
7
|
+
res = @flickr.call_method('flickr.photos.comments.addComment',
|
8
|
+
'photo_id' => photo, 'comment_text' => comment)
|
9
|
+
xml = res.root
|
10
|
+
xml.attributes['id']
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete(comment_id)
|
14
|
+
@flickr.call_method('flickr.photos.comments.deleteComment',
|
15
|
+
'comment_id' => comment_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit(comment_id, comment)
|
19
|
+
@flickr.call_method('flickr.photos.comments.editComment',
|
20
|
+
'comment_id' => comment_id, 'comment_text' => comment)
|
21
|
+
end
|
22
|
+
|
23
|
+
def list(photo)
|
24
|
+
photo = photo.id if photo.class == Flickr::Photo
|
25
|
+
res = @flickr.call_method('flickr.photos.comments.getList',
|
26
|
+
'photo_id' => photo)
|
27
|
+
rv = []
|
28
|
+
res.elements['//comments'].each_element do |e|
|
29
|
+
rv << Flickr::Comment.from_xml(e, @flickr)
|
30
|
+
end
|
31
|
+
rv
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Contacts < Flickr::APIBase
|
4
|
+
def getList(filter=nil)
|
5
|
+
res = filter ?
|
6
|
+
@flickr.call_method('flickr.contacts.getList') :
|
7
|
+
@flickr.call_method('flickr.contacts.getList',
|
8
|
+
'filter'=>filter)
|
9
|
+
list = []
|
10
|
+
res.elements['/contacts'].each_element do |e|
|
11
|
+
att = e.attributes
|
12
|
+
nsid = att['nsid']
|
13
|
+
|
14
|
+
person = @flickr.person_cache_lookup(nsid)
|
15
|
+
person ||= Flickr::Person.new(@flickr,nsid,att['username'])
|
16
|
+
|
17
|
+
person.realname = att['realname']
|
18
|
+
person.friend = (att['friend'].to_i == 1)
|
19
|
+
person.family = (att['family'].to_i == 1)
|
20
|
+
person.ignored = (att['ignored'].to_i == 1)
|
21
|
+
|
22
|
+
list << person
|
23
|
+
|
24
|
+
@flickr.person_cache_store(person)
|
25
|
+
end
|
26
|
+
return list
|
27
|
+
end
|
28
|
+
|
29
|
+
# User can be either the NSID String or a Contact
|
30
|
+
def getPublicList(user)
|
31
|
+
user = user.nsid if user.class == Flickr::Person
|
32
|
+
res = @flickr.call_method('flickr.contacts.getPublicList',
|
33
|
+
'user_id'=>user)
|
34
|
+
list = []
|
35
|
+
res.elements['/contacts'].each_element do |e|
|
36
|
+
att = e.attributes
|
37
|
+
nsid = att['nsid']
|
38
|
+
|
39
|
+
person = @flickr.person_cache_lookup(nsid)
|
40
|
+
person ||= Flickr::Person.new(@flickr,nsid,att['username'])
|
41
|
+
|
42
|
+
person.ignored = (att['ignored'].to_i == 1)
|
43
|
+
@flickr.person_cache_store(person)
|
44
|
+
list << person
|
45
|
+
end
|
46
|
+
return list
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Favorites < Flickr::APIBase
|
4
|
+
# photo can be either a Photo or numeric id
|
5
|
+
def add(photo)
|
6
|
+
photo = photo.id if photo.class == Flickr::Photo
|
7
|
+
return @flickr.call_method('flickr.favorites.add',
|
8
|
+
'photo_id' => photo)
|
9
|
+
end
|
10
|
+
|
11
|
+
# photo can be either a Photo or numeric id
|
12
|
+
def remove(photo)
|
13
|
+
photo = photo.id if photo.class == Flickr::Photo
|
14
|
+
return @flickr.call_method('flickr.favorites.remove',
|
15
|
+
'photo_id' => photo)
|
16
|
+
end
|
17
|
+
|
18
|
+
# This is a little weird because all the parametrs are optional,
|
19
|
+
# let's go with it, ok?
|
20
|
+
# user can be a Person or a user NSID
|
21
|
+
# No caching because it's just too hard.
|
22
|
+
def getList(user=nil,extras=nil,per_page=nil,page=nil)
|
23
|
+
args = {}
|
24
|
+
|
25
|
+
user = user.nsid if user.class == Flickr::Person
|
26
|
+
args['user_id'] = user if user
|
27
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
28
|
+
args['per_page'] = per_page if per_page
|
29
|
+
args['page'] = page if page
|
30
|
+
|
31
|
+
res = @flickr.call_method('flickr.favorites.getList',args)
|
32
|
+
att = res.root.attributes
|
33
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
34
|
+
end
|
35
|
+
|
36
|
+
# This is a little weird because all the parametrs are optional,
|
37
|
+
# let's go with it, ok?
|
38
|
+
# user can be a Person or a user NSID
|
39
|
+
# No caching because it's just too hard.
|
40
|
+
def getPublicList(user,extras=nil,per_page=nil,page=nil)
|
41
|
+
args = {}
|
42
|
+
|
43
|
+
user = user.nsid if user.class == Flickr::Person
|
44
|
+
|
45
|
+
args['user_id'] = user if user
|
46
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
47
|
+
args['per_page'] = per_page if per_page
|
48
|
+
args['page'] = page if page
|
49
|
+
|
50
|
+
res = @flickr.call_method('flickr.favorites.getPublicList',args)
|
51
|
+
att = res.root.attributes
|
52
|
+
list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
|
53
|
+
att['perpage'].to_i,att['total'].to_i)
|
54
|
+
res.elements['/photos'].each_element do |e|
|
55
|
+
list << Flick::Photo.from_xml(e,@flickr)
|
56
|
+
end
|
57
|
+
return list
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Groups < Flickr::APIBase
|
4
|
+
def pools() @pools ||= Flickr::Pools.new(@flickr,self) end
|
5
|
+
|
6
|
+
# category can be a Category or nsid string
|
7
|
+
def browse(category=nil)
|
8
|
+
category=category.id if (category.class == Flickr::Category ||
|
9
|
+
category.class == Flickr::SubCategory )
|
10
|
+
|
11
|
+
args = category ? {'cat_id' => category } : {}
|
12
|
+
res = @flickr.call_method('flickr.groups.browse',args)
|
13
|
+
att = res.root.attributes
|
14
|
+
cat=Flickr::Category.new(att['name'],att['path'],att['pathids'])
|
15
|
+
res.elements['/category'].each_element('subcat') do |e|
|
16
|
+
att = e.attributes
|
17
|
+
cat.subcats << Flickr::SubCategory.new(att['name'],
|
18
|
+
att['id'],att['count'].to_i)
|
19
|
+
end
|
20
|
+
res.elements['/category'].each_element('group') do |e|
|
21
|
+
att = e.attributes
|
22
|
+
nsid = att['nsid']
|
23
|
+
|
24
|
+
g = @flickr.group_cache_lookup(nsid)
|
25
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
26
|
+
|
27
|
+
g.name = att['name']
|
28
|
+
g.members = att['members'].to_i
|
29
|
+
g.online = att['online'].to_i
|
30
|
+
g.chatnsid = att['chatnsid']
|
31
|
+
g.inchat = att['inchat'].to_i
|
32
|
+
|
33
|
+
@flickr.group_cache_store(g)
|
34
|
+
cat.groups << g
|
35
|
+
end
|
36
|
+
|
37
|
+
return cat
|
38
|
+
end
|
39
|
+
|
40
|
+
# group can be a Group or group nsid
|
41
|
+
def getInfo(group)
|
42
|
+
group = group.nsid if group.class == Flickr::Group
|
43
|
+
g = @flickr.group_cache_lookup(group)
|
44
|
+
return g if g && g.fully_fetched
|
45
|
+
|
46
|
+
res = @flickr.call_method('flickr.groups.getInfo',
|
47
|
+
'group_id' => group)
|
48
|
+
|
49
|
+
group = res.elements['/group'].attributes['id']
|
50
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
51
|
+
g.name = res.elements['/group/name'].text
|
52
|
+
g.description = res.elements['/group/description'].text
|
53
|
+
g.members = res.elements['/group/members'].text.to_i
|
54
|
+
g.privacy = res.elements['/group/privacy'].text.to_i
|
55
|
+
g.fully_fetched = true
|
56
|
+
|
57
|
+
@flickr.group_cache_store(g)
|
58
|
+
return g
|
59
|
+
end
|
60
|
+
|
61
|
+
def search(text,per_page=nil,page=nil)
|
62
|
+
args = { 'text' => text }
|
63
|
+
args['per_page'] = per_page if per_page
|
64
|
+
args['page'] = page if page
|
65
|
+
res = @flickr.call_method('flickr.groups.search',args)
|
66
|
+
att = res.root.attributes
|
67
|
+
list = Flickr::GroupList.new(att['page'].to_i,att['pages'].to_i,
|
68
|
+
att['perpage'].to_i,att['total'].to_i)
|
69
|
+
res.elements['/groups'].each_element('group') do |e|
|
70
|
+
att = e.attributes
|
71
|
+
nsid = att['nsid']
|
72
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
73
|
+
Flickr::Group.new(@flickr,nsid)
|
74
|
+
g.name = att['name']
|
75
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
76
|
+
|
77
|
+
@flickr.group_cache_store(g)
|
78
|
+
list << g
|
79
|
+
end
|
80
|
+
return list
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Interestingness < Flickr::APIBase
|
4
|
+
def getList(date=nil,extras=nil,per_page=nil,page=nil)
|
5
|
+
args = {}
|
6
|
+
if date
|
7
|
+
args['date'] = date if date.is_a?(String)
|
8
|
+
args['date'] = date.to_s if date.is_a?(Date)
|
9
|
+
args['date'] = @flickr.mysql_date(date) if
|
10
|
+
date.is_a?(Time)
|
11
|
+
end
|
12
|
+
extras = extras.join(',') if extras.class == Array
|
13
|
+
args['extras'] = extras if extras
|
14
|
+
args['per_page'] = per_page if per_page
|
15
|
+
args['page'] = page if page
|
16
|
+
res = @flickr.call_method('flickr.interestingness.getList',args)
|
17
|
+
return Flickr::PhotoSet.from_xml(res.root,@flickr)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Licenses < Flickr::APIBase
|
4
|
+
def getInfo
|
5
|
+
return @flickr.license_cache_lookup if
|
6
|
+
@flickr.license_cache_lookup
|
7
|
+
list = {}
|
8
|
+
res = @flickr.call_method('flickr.photos.licenses.getInfo')
|
9
|
+
res.elements['/licenses'].each_element do |el|
|
10
|
+
lic = Flickr::License.from_xml(el)
|
11
|
+
list[lic.id] = lic
|
12
|
+
end
|
13
|
+
@flickr.license_cache_store(list)
|
14
|
+
return list
|
15
|
+
end
|
16
|
+
|
17
|
+
def setLicense(photo,license)
|
18
|
+
photo = photo.id if photo.class == Flickr::Photo
|
19
|
+
license = license.id if license.class == Flickr::License
|
20
|
+
@flickr.call_method('flickr.photos.licenses.setLicense',
|
21
|
+
'photo_id' => photo, 'license_id' => license)
|
22
|
+
end
|
23
|
+
end
|
data/lib/flickr/notes.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Notes < Flickr::APIBase
|
4
|
+
def add(photo,x,y,w,h,text)
|
5
|
+
photo = photo.id if photo.class == Flickr::Photo
|
6
|
+
res = @flickr.call_method('flickr.photos.notes.add',
|
7
|
+
'photo_id' => photo, 'note_x' => x, 'note_y' => y,
|
8
|
+
'note_w' => w, 'note_h' => h, 'note_text' => text)
|
9
|
+
return res.elements['/note'].attributes['id']
|
10
|
+
end
|
11
|
+
|
12
|
+
def delete(note)
|
13
|
+
note = note.id if note.class == Flickr::Note
|
14
|
+
res = @flickr.call_method('flickr.photos.notes.delete',
|
15
|
+
'note_id' => note)
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit(note,x,y,w,h,text)
|
19
|
+
note = note.id if note.class == Flickr::Note
|
20
|
+
res = @flickr.call_method('flickr.photos.notes.edit',
|
21
|
+
'note_id' => note, 'note_x' => x, 'note_y' => y,
|
22
|
+
'note_w' => w, 'note_h' => h, 'note_text' => text)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::People < Flickr::APIBase
|
4
|
+
def findByEmail(find_email)
|
5
|
+
res = @flickr.call_method('flickr.people.findByEmail',
|
6
|
+
'find_email' => find_email)
|
7
|
+
p = Flickr::Person.from_xml(res,@flickr)
|
8
|
+
return p
|
9
|
+
end
|
10
|
+
|
11
|
+
def findByUsername(username)
|
12
|
+
res = @flickr.call_method('flickr.people.findByUsername',
|
13
|
+
'username' => username)
|
14
|
+
p = Flickr::Person.from_xml(res,@flickr)
|
15
|
+
return p
|
16
|
+
end
|
17
|
+
|
18
|
+
# user can be a Person or an nsid
|
19
|
+
def getInfo(user)
|
20
|
+
user = user.nsid if user.class == Flickr::Person
|
21
|
+
res = @flickr.call_method('flickr.people.getInfo',
|
22
|
+
'user_id'=>user)
|
23
|
+
person = Flickr::Person.from_xml(res,@flickr)
|
24
|
+
return person
|
25
|
+
end
|
26
|
+
|
27
|
+
# user can be a Person or an nsid
|
28
|
+
def getPublicGroups(user)
|
29
|
+
require 'flickr/groups'
|
30
|
+
groups = @flickr.groups
|
31
|
+
user = user.nsid if user.class == Flickr::Person
|
32
|
+
res = @flickr.call_method('flickr.people.getPublicGroups',
|
33
|
+
'user_id' => user)
|
34
|
+
list = []
|
35
|
+
res.elements['/groups'].each_element('group') do |e|
|
36
|
+
att = e.attributes
|
37
|
+
nsid = att['nsid']
|
38
|
+
|
39
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
40
|
+
Flickr::Group.new(@flickr,nsid)
|
41
|
+
|
42
|
+
g.name = att['name']
|
43
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
44
|
+
|
45
|
+
@flickr.group_cache_store(g)
|
46
|
+
list << g
|
47
|
+
end
|
48
|
+
return list
|
49
|
+
end
|
50
|
+
|
51
|
+
def getPublicPhotos(user,extras=nil,per_page=nil,page=nil)
|
52
|
+
args = {}
|
53
|
+
|
54
|
+
user = user.nsid if user.class == Flickr::Person
|
55
|
+
|
56
|
+
args['user_id'] = user if user
|
57
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
58
|
+
args['per_page'] = per_page if per_page
|
59
|
+
args['page'] = page if page
|
60
|
+
|
61
|
+
res = @flickr.call_method('flickr.people.getPublicPhotos',args)
|
62
|
+
att = res.root.attributes
|
63
|
+
list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
|
64
|
+
att['perpage'].to_i,att['total'].to_i)
|
65
|
+
res.elements['/photos'].each_element do |e|
|
66
|
+
list << Flickr::Photo.from_xml(e,@flickr)
|
67
|
+
end
|
68
|
+
return list
|
69
|
+
end
|
70
|
+
|
71
|
+
# user can be a Person or an nsid
|
72
|
+
def getUploadStatus(user)
|
73
|
+
user = user.nsid if user.class == Flickr::Person
|
74
|
+
res = @flickr.call_method('flickr.people.getUploadStatus',
|
75
|
+
'user_id'=>user)
|
76
|
+
person = Flickr::Person.from_xml(res,@flickr)
|
77
|
+
return person
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,293 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
begin
|
4
|
+
# Did not exist in 1.8.6
|
5
|
+
StopIteration
|
6
|
+
rescue NameError
|
7
|
+
class StopIteration < Exception
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Flickr::Photos < Flickr::APIBase
|
12
|
+
def upload
|
13
|
+
require 'flickr/upload'
|
14
|
+
@upload ||= Flickr::Upload.new(@flickr)
|
15
|
+
end
|
16
|
+
|
17
|
+
def licenses
|
18
|
+
require 'flickr/licenses'
|
19
|
+
@licenses ||= Flickr::Licenses.new(@flickr)
|
20
|
+
end
|
21
|
+
|
22
|
+
def notes
|
23
|
+
require 'flickr/notes'
|
24
|
+
@notes ||= Flickr::Notes.new(@flickr)
|
25
|
+
end
|
26
|
+
|
27
|
+
def transform
|
28
|
+
require 'flickr/transform'
|
29
|
+
@transform ||= Flickr::Transform.new(@flickr)
|
30
|
+
end
|
31
|
+
|
32
|
+
# photo can be a Photo or a photo id
|
33
|
+
# tags is an array of tags
|
34
|
+
def addTags(photo,tags)
|
35
|
+
photo = photo.id if photo.class == Flickr::Photo
|
36
|
+
tstr = tags.join(',')
|
37
|
+
@flickr.call_method('flickr.photos.addTags',
|
38
|
+
'photo_id' => photo, 'tags' => tstr)
|
39
|
+
end
|
40
|
+
|
41
|
+
def removeTag(tag)
|
42
|
+
tag = tag.id if tag.class == Flickr::Tag
|
43
|
+
@flickr.call_method('flickr.photos.removeTag', 'tag_id' => tag)
|
44
|
+
end
|
45
|
+
|
46
|
+
def setTags(tags)
|
47
|
+
tags=tags.map{|t| (t.class == Flickr::Tag) ? t.id : t}.join(' ')
|
48
|
+
photo = photo.id if photo.class == Flickr::Photo
|
49
|
+
@flickr.call_method('flickr.photos.setTags',
|
50
|
+
'photo_id' => photo, 'tags' => tags)
|
51
|
+
end
|
52
|
+
|
53
|
+
# photo can be a Photo or photo id string/number
|
54
|
+
def delete(photo)
|
55
|
+
photo = photo.id if photo.class == Flickr::Photo
|
56
|
+
res = @flickr.call_method('flickr.photos.delete',
|
57
|
+
'photo_id'=>photo)
|
58
|
+
end
|
59
|
+
|
60
|
+
# photo can be a Photo or photo id string/number
|
61
|
+
def getAllContexts(photo)
|
62
|
+
photo = photo.id if photo.class == Flickr::Photo
|
63
|
+
res @flickr.call_method('flickr.photos.getAllContexts',
|
64
|
+
'photo_id'=>photo)
|
65
|
+
list = []
|
66
|
+
res.each_element('set') do |set|
|
67
|
+
att = set.attributes
|
68
|
+
psid = att['id']
|
69
|
+
set = @flickr.photoset_cache_lookup(psid) ||
|
70
|
+
Flickr::PhotoSet.new(att['id'],@flickr)
|
71
|
+
set.title = att['title']
|
72
|
+
|
73
|
+
@flickr.photoset_cache_store(set)
|
74
|
+
list << set
|
75
|
+
end
|
76
|
+
res.each_element('pool') do |set|
|
77
|
+
att = set.attributes
|
78
|
+
ppid = att['id']
|
79
|
+
|
80
|
+
p = @flickr.photopool_cache_lookup(ppid) ||
|
81
|
+
Flickr::PhotoPool.new(ppid,@flickr)
|
82
|
+
p.title = att['title']
|
83
|
+
@flickr.photopool_cache_store(ppid)
|
84
|
+
list << p
|
85
|
+
end
|
86
|
+
return list
|
87
|
+
end
|
88
|
+
|
89
|
+
def getPerms(photo)
|
90
|
+
photo = photo.id if photo.class == Flickr::Photo
|
91
|
+
res = @flickr.call_method('flickr.photos.getPerms',
|
92
|
+
'photo_id' => photo)
|
93
|
+
perms = res.elements['/perms']
|
94
|
+
att = perms.attributes
|
95
|
+
phid = att['id']
|
96
|
+
photo = (photo.class == Flickr::Photo) ? photo :
|
97
|
+
(@flickr.photo_cache_lookup(phid) ||
|
98
|
+
Flickr::Photo.new(@flickr,phid))
|
99
|
+
photo.ispublic = (att['ispublic'].to_i == 1)
|
100
|
+
photo.isfriend = (att['isfriend'].to_i == 1)
|
101
|
+
photo.isfamily = (att['isfamily'].to_i == 1)
|
102
|
+
photo.permcomment = att['permcomment'].to_i
|
103
|
+
photo.permaddmeta = att['permaddmeta'].to_i
|
104
|
+
return photo
|
105
|
+
end
|
106
|
+
|
107
|
+
def setPerms(photo,is_public,is_friend,is_family,perm_comment,
|
108
|
+
perm_addmeta)
|
109
|
+
photo = photo.id if photo.class == Flickr::Photo
|
110
|
+
args = {
|
111
|
+
'photo_id' => photo,
|
112
|
+
'is_public' => (is_public == true || is_public == 1) ? 1 : 0,
|
113
|
+
'is_friend' => (is_friend == true || is_friend == 1) ? 1 : 0,
|
114
|
+
'is_family' => (is_family == true || is_family == 1) ? 1 : 0,
|
115
|
+
'perm_comment' => perm_comment,
|
116
|
+
'perm_addmeta' => perm_addmeta
|
117
|
+
}
|
118
|
+
res = @flickr.call_method('flickr.photos.setPerms',args)
|
119
|
+
end
|
120
|
+
|
121
|
+
def getContactsPhotos(count=nil,just_friends=nil,single_photo=nil,
|
122
|
+
include_self=nil)
|
123
|
+
args = {}
|
124
|
+
args['count'] = count if count
|
125
|
+
args['just_friends'] = just_friends ? '1' : '0' if
|
126
|
+
just_friends != nil
|
127
|
+
args['single_photo'] = single_photo ? '1' : '0' if
|
128
|
+
single_photo != nil
|
129
|
+
args['include_self'] = include_self ? '1' : '0' if
|
130
|
+
include_self != nil
|
131
|
+
res= @flickr.call_method('flickr.photos.getContactsPhotos',args)
|
132
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Person can be a string nsid or anything that responds to the
|
136
|
+
# nsid method.
|
137
|
+
def getContactsPublicPhotos(user, count=nil,just_friends=nil,
|
138
|
+
single_photo=nil, include_self=nil)
|
139
|
+
user = user.nsid if user.respond_to?(:nsid)
|
140
|
+
args = {}
|
141
|
+
args['count'] = count if count
|
142
|
+
args['user_id'] = user
|
143
|
+
args['just_friends'] = just_friends ? '1' : '0' if
|
144
|
+
just_friends != nil
|
145
|
+
args['single_photo'] = single_photo ? '1' : '0' if
|
146
|
+
single_photo != nil
|
147
|
+
args['include_self'] = include_self ? '1' : '0' if
|
148
|
+
include_self != nil
|
149
|
+
res=@flickr.call_method('flickr.photos.getContactsPublicPhotos',
|
150
|
+
args)
|
151
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
152
|
+
end
|
153
|
+
|
154
|
+
def getContext(photo)
|
155
|
+
photo = photo.id if photo.class == Flickr::Photo
|
156
|
+
res = @flickr.call_method('flickr.photos.getContext',
|
157
|
+
'photo_id' => photo)
|
158
|
+
return Flickr::Context.from_xml(res)
|
159
|
+
end
|
160
|
+
|
161
|
+
def getCounts(dates=nil,taken_dates=nil)
|
162
|
+
args = {}
|
163
|
+
args['dates'] = dates.map{|d| d.to_i}.join(',') if dates
|
164
|
+
args['taken_dates'] = taken_dates.map{|d| d.to_i}.join(',') if
|
165
|
+
taken_dates
|
166
|
+
res = @flickr.call_method('flickr.photos.getCounts',args)
|
167
|
+
list = []
|
168
|
+
res.elements['/photocounts'].each_element('photocount') do |el|
|
169
|
+
list << Flickr::Count.from_xml(el)
|
170
|
+
end
|
171
|
+
return list
|
172
|
+
end
|
173
|
+
|
174
|
+
def getExif(photo,secret = nil)
|
175
|
+
photo = photo.id if photo.class == Flickr::Photo
|
176
|
+
args = {'photo_id' => photo}
|
177
|
+
args['secret'] = secret if secret
|
178
|
+
res = @flickr.call_method('flickr.photos.getExif',args)
|
179
|
+
return Flickr::Photo.from_xml(res.elements['/photo'],@flickr)
|
180
|
+
end
|
181
|
+
|
182
|
+
def getInfo(photo,secret = nil)
|
183
|
+
photo = (photo.class == Flickr::Photo) ? photo.id : photo
|
184
|
+
args= {'photo_id' => photo}
|
185
|
+
args['secret'] = secret if secret
|
186
|
+
res = @flickr.call_method('flickr.photos.getInfo',args)
|
187
|
+
return Flickr::Photo.from_xml(res.elements['photo'],@flickr)
|
188
|
+
end
|
189
|
+
|
190
|
+
def getNotInSet(extras=nil,per_page = nil, page = nil)
|
191
|
+
args = {}
|
192
|
+
extras = extras.join(',') if extras.class == Array
|
193
|
+
args['extras'] = extras if extras
|
194
|
+
args['per_page'] = per_page if per_page
|
195
|
+
args['page'] = page if page
|
196
|
+
res = @flickr.call_method('flickr.photos.getNotInSet',args)
|
197
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
198
|
+
end
|
199
|
+
|
200
|
+
def getRecent(extras=nil,per_page = nil, page = nil)
|
201
|
+
args = {}
|
202
|
+
extras = extras.join(',') if extras.class == Array
|
203
|
+
args['extras'] = extras if extras
|
204
|
+
args['per_page'] = per_page if per_page
|
205
|
+
args['page'] = page if page
|
206
|
+
res = @flickr.call_method('flickr.photos.getRecent',args)
|
207
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
208
|
+
end
|
209
|
+
|
210
|
+
def getUntagged(extras=nil,per_page = nil, page = nil)
|
211
|
+
args = {}
|
212
|
+
extras = extras.join(',') if extras.class == Array
|
213
|
+
args['extras'] = extras if extras
|
214
|
+
args['per_page'] = per_page if per_page
|
215
|
+
args['page'] = page if page
|
216
|
+
res = @flickr.call_method('flickr.photos.getUntagged',args)
|
217
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
218
|
+
end
|
219
|
+
|
220
|
+
def getSizes(photo)
|
221
|
+
photo_id = (photo.class == Flickr::Photo) ? photo.id : photo
|
222
|
+
photo = (photo.class == Flickr::Photo) ? photo :
|
223
|
+
(@flickr.photo_cache_lookup(photo_id) ||
|
224
|
+
Flickr::Photo.new(@flickr,photo_id))
|
225
|
+
res = @flickr.call_method('flickr.photos.getSizes',
|
226
|
+
'photo_id' => photo_id )
|
227
|
+
photo.sizes = {}
|
228
|
+
res.elements['/sizes'].each_element do |el|
|
229
|
+
size = Flickr::Size.from_xml(el)
|
230
|
+
photo.sizes[size.label.intern] = size
|
231
|
+
end
|
232
|
+
@flickr.photo_cache_store(photo)
|
233
|
+
return photo
|
234
|
+
end
|
235
|
+
|
236
|
+
def setDates(photo,date_posted=nil,date_taken=nil,
|
237
|
+
date_taken_granularity=nil)
|
238
|
+
photo = photo.id if photo.class == Flickr::Photo
|
239
|
+
date_posted = date_posted.to_i if date_posted.class == Time
|
240
|
+
date_taken = @flickr.mysql_datetime(date_taken) if
|
241
|
+
date_taken.class == Time
|
242
|
+
args = {'photo_id' => photo}
|
243
|
+
args['date_posted'] = date_posted if date_posted
|
244
|
+
args['date_taken'] = date_taken if date_taken
|
245
|
+
args['date_taken_granularity'] = date_taken_granularity if
|
246
|
+
date_taken_granularity
|
247
|
+
@flickr.call_method('flickr.photos.setDates',args)
|
248
|
+
end
|
249
|
+
|
250
|
+
def setMeta(photo,title,description)
|
251
|
+
photo = photo.id if photo.class == Flickr::Photo
|
252
|
+
args = {'photo_id' => photo,
|
253
|
+
'title' => title,
|
254
|
+
'description' => description}
|
255
|
+
@flickr.call_method('flickr.photos.setMeta',args)
|
256
|
+
end
|
257
|
+
|
258
|
+
def search(args)
|
259
|
+
args[:user_id] = args[:user_id].nsid if args[:user_id].respond_to?(:nsid)
|
260
|
+
args[:tags] = args[:tags].join(',') if args[:tags].class == Array
|
261
|
+
|
262
|
+
[:min_upload_date, :max_upload_date].each do |k|
|
263
|
+
args[k] = args[k].to_i if args[k].is_a? Time
|
264
|
+
end
|
265
|
+
|
266
|
+
[:min_taken_date, :max_taken_date].each do |k|
|
267
|
+
args[k] = @flickr.mysql_datetime(args[k]) if args[k].is_a? Time
|
268
|
+
end
|
269
|
+
|
270
|
+
args[:license] = args[:license].id if args[:license].is_a? Flickr::License
|
271
|
+
args[:extras] = args[:extras].join(',') if args[:extras].is_a? Array
|
272
|
+
args.each {|k,v| v = args.delete(k); args[k.to_s] = v}
|
273
|
+
|
274
|
+
if block_given?
|
275
|
+
thispage = 1
|
276
|
+
maxpages = 2
|
277
|
+
args['per_page'] ||= 500
|
278
|
+
until thispage > maxpages do
|
279
|
+
args['page'] = thispage
|
280
|
+
res = @flickr.call_method('flickr.photos.search',args)
|
281
|
+
list = Flickr::PhotoList.from_xml(res, @flickr)
|
282
|
+
maxpages = list.pages
|
283
|
+
list.each {|p| yield p}
|
284
|
+
thispage += 1
|
285
|
+
end
|
286
|
+
else
|
287
|
+
res = @flickr.call_method('flickr.photos.search',args)
|
288
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
289
|
+
end
|
290
|
+
rescue StopIteration
|
291
|
+
nil
|
292
|
+
end
|
293
|
+
end
|