rflickr 2006.02.01
Sign up to get free protection for your applications and to get access to all the features.
- data/GETTING-STARTED +40 -0
- data/lib/flickr.rb +19 -0
- data/lib/flickr/auth.rb +76 -0
- data/lib/flickr/base.rb +793 -0
- data/lib/flickr/blogs.rb +30 -0
- data/lib/flickr/contacts.rb +48 -0
- data/lib/flickr/favorites.rb +59 -0
- data/lib/flickr/groups.rb +82 -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 +285 -0
- data/lib/flickr/photosets.rb +104 -0
- data/lib/flickr/pools.rb +70 -0
- data/lib/flickr/reflection.rb +89 -0
- data/lib/flickr/tags.rb +59 -0
- data/lib/flickr/test.rb +19 -0
- data/lib/flickr/transform.rb +9 -0
- data/lib/flickr/upload.rb +205 -0
- data/lib/flickr/urls.rb +49 -0
- data/sample/album_test.rb +30 -0
- data/sample/comics-reorder.rb +16 -0
- data/sample/loadr.rb +80 -0
- data/sample/relatedness.rb +65 -0
- data/sample/setdumpr.rb +46 -0
- metadata +73 -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,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(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(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,82 @@
|
|
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
|
+
group = res.elements['/group'].attributes['id']
|
49
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
50
|
+
g.name = res.elements['/group/name'].text
|
51
|
+
g.description = res.elements['/group/description'].text
|
52
|
+
g.members = res.elements['/group/members'].text.to_i
|
53
|
+
g.privacy = res.elements['/group/privacy'].text.to_i
|
54
|
+
g.fully_fetched = true
|
55
|
+
|
56
|
+
@flickr.group_cache_store(g)
|
57
|
+
return g
|
58
|
+
end
|
59
|
+
|
60
|
+
def search(text,per_page=nil,page=nil)
|
61
|
+
args = { 'text' => text }
|
62
|
+
args['per_page'] = per_page if per_page
|
63
|
+
args['page'] = page if page
|
64
|
+
res = @flickr.call_method('flickr.groups.search',args)
|
65
|
+
att = res.root.attributes
|
66
|
+
list = Flickr::GroupList.new(att['page'].to_i,att['pages'].to_i,
|
67
|
+
att['perpage'].to_i,att['total'].to_i)
|
68
|
+
res.elements['/groups'].each_element('group') do |e|
|
69
|
+
att = e.attributes
|
70
|
+
nsid = att['nsid']
|
71
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
72
|
+
Flickr::Group.new(@flickr,nsid)
|
73
|
+
g.name = att['name']
|
74
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
75
|
+
|
76
|
+
@flickr.group_cache_store(g)
|
77
|
+
list << g
|
78
|
+
end
|
79
|
+
return list
|
80
|
+
end
|
81
|
+
|
82
|
+
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,285 @@
|
|
1
|
+
require 'flickr/base'
|
2
|
+
|
3
|
+
class Flickr::Photos < Flickr::APIBase
|
4
|
+
def upload
|
5
|
+
require 'flickr/upload'
|
6
|
+
@upload ||= Flickr::Upload.new(@flickr)
|
7
|
+
end
|
8
|
+
|
9
|
+
def licenses
|
10
|
+
require 'flickr/licenses'
|
11
|
+
@licenses ||= Flickr::Licenses.new(@flickr)
|
12
|
+
end
|
13
|
+
|
14
|
+
def notes
|
15
|
+
require 'flickr/notes'
|
16
|
+
@notes ||= Flickr::Notes.new(@flickr)
|
17
|
+
end
|
18
|
+
|
19
|
+
def transform
|
20
|
+
require 'flickr/transform'
|
21
|
+
@transform ||= Flickr::Transform.new(@flickr)
|
22
|
+
end
|
23
|
+
|
24
|
+
# photo can be a Photo or a photo id
|
25
|
+
# tags is an array of tags
|
26
|
+
def addTags(photo,tags)
|
27
|
+
photo = photo.id if photo.class == Flickr::Photo
|
28
|
+
tstr = tags.join(',')
|
29
|
+
@flickr.call_method('flickr.photos.addTags',
|
30
|
+
'photo' => photo, 'tags' => tstr)
|
31
|
+
end
|
32
|
+
|
33
|
+
def removeTag(tag)
|
34
|
+
tag = tag.id if tag.class == Flickr::Tag
|
35
|
+
@flickr.call_method('flickr.photos.removeTag', 'tag_id' => tag)
|
36
|
+
end
|
37
|
+
|
38
|
+
def setTags(tags)
|
39
|
+
tags=tags.map{|t| (t.class == Flickr::Tag) ? t.id : t}.join(' ')
|
40
|
+
photo = photo.id if photo.class == Flickr::Photo
|
41
|
+
@flickr.call_method('flickr.photos.setTags',
|
42
|
+
'photo_id' => photo, 'tags' => tags)
|
43
|
+
end
|
44
|
+
|
45
|
+
# photo can be a Photo or photo id string/number
|
46
|
+
def delete(photo)
|
47
|
+
photo = photo.id if photo.class == Flickr::Photo
|
48
|
+
res = @flickr.call_method('flickr.photos.delete',
|
49
|
+
'photo_id'=>photo)
|
50
|
+
end
|
51
|
+
|
52
|
+
# photo can be a Photo or photo id string/number
|
53
|
+
def getAllContexts(photo)
|
54
|
+
photo = photo.id if photo.class == Flickr::Photo
|
55
|
+
res @flickr.call_method('flickr.photos.getAllContexts',
|
56
|
+
'photo_id'=>photo)
|
57
|
+
list = []
|
58
|
+
res.each_element('set') do |set|
|
59
|
+
att = set.attributes
|
60
|
+
psid = att['id']
|
61
|
+
set = @flickr.photoset_cache_lookup(psid) ||
|
62
|
+
Flickr::PhotoSet.new(att['id'],@flickr)
|
63
|
+
set.title = att['title']
|
64
|
+
|
65
|
+
@flickr.photoset_cache_store(set)
|
66
|
+
list << set
|
67
|
+
end
|
68
|
+
res.each_element('pool') do |set|
|
69
|
+
att = set.attributes
|
70
|
+
ppid = att['id']
|
71
|
+
|
72
|
+
p = @flickr.photopool_cache_lookup(ppid) ||
|
73
|
+
Flickr::PhotoPool.new(ppid,@flickr)
|
74
|
+
p.title = att['title']
|
75
|
+
@flickr.photopool_cache_store(ppid)
|
76
|
+
list << p
|
77
|
+
end
|
78
|
+
return list
|
79
|
+
end
|
80
|
+
|
81
|
+
def getPerms(photo)
|
82
|
+
photo = photo.id if photo.class == Flickr::Photo
|
83
|
+
res = @flickr.call_method('flickr.photos.getPerms',
|
84
|
+
'photo_id' => photo)
|
85
|
+
perms = res.elements['/perms']
|
86
|
+
att = perms.attributes
|
87
|
+
phid = att['id']
|
88
|
+
photo = (photo.class == Flickr::Photo) ? photo :
|
89
|
+
(@flickr.photo_cache_lookup(phid) ||
|
90
|
+
Flickr::Photo.new(@flickr,phid))
|
91
|
+
photo.ispublic = (att['ispublic'].to_i == 1)
|
92
|
+
photo.isfriend = (att['isfriend'].to_i == 1)
|
93
|
+
photo.isfamily = (att['isfamily'].to_i == 1)
|
94
|
+
photo.permcomment = att['permcomment'].to_i
|
95
|
+
photo.permaddmeta = att['permaddmeta'].to_i
|
96
|
+
return photo
|
97
|
+
end
|
98
|
+
|
99
|
+
def setPerms(photo,is_public,is_friend,is_family,perm_comment,
|
100
|
+
perm_addmeta)
|
101
|
+
photo = photo.id if photo.class == Flickr::Photo
|
102
|
+
args = {
|
103
|
+
'photo_id' => photo,
|
104
|
+
'is_public' => (is_public == true || is_public == 1) ? 1 : 0,
|
105
|
+
'is_friend' => (is_friend == true || is_friend == 1) ? 1 : 0,
|
106
|
+
'is_family' => (is_family == true || is_family == 1) ? 1 : 0,
|
107
|
+
'perm_comment' => perm_comment,
|
108
|
+
'perm_addmeta' => perm_addmeta
|
109
|
+
}
|
110
|
+
res = @flickr.call_method('flickr.photos.setPerms',args)
|
111
|
+
end
|
112
|
+
|
113
|
+
def getContactsPhotos(count=nil,just_friends=nil,single_photo=nil,
|
114
|
+
include_self=nil)
|
115
|
+
args = {}
|
116
|
+
args['count'] = count if count
|
117
|
+
args['just_friends'] = just_friends ? '1' : '0' if
|
118
|
+
just_friends != nil
|
119
|
+
args['single_photo'] = single_photo ? '1' : '0' if
|
120
|
+
single_photo != nil
|
121
|
+
args['include_self'] = include_self ? '1' : '0' if
|
122
|
+
include_self != nil
|
123
|
+
res= @flickr.call_method('flickr.photos.getContactsPhotos',args)
|
124
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Person can be a string nsid or anything that responds to the
|
128
|
+
# nsid method.
|
129
|
+
def getContactsPublicPhotos(user, count=nil,just_friends=nil,
|
130
|
+
single_photo=nil, include_self=nil)
|
131
|
+
user = user.nsid if user.respond_to?(:nsid)
|
132
|
+
args = {}
|
133
|
+
args['count'] = count if count
|
134
|
+
args['user_id'] = user
|
135
|
+
args['just_friends'] = just_friends ? '1' : '0' if
|
136
|
+
just_friends != nil
|
137
|
+
args['single_photo'] = single_photo ? '1' : '0' if
|
138
|
+
single_photo != nil
|
139
|
+
args['include_self'] = include_self ? '1' : '0' if
|
140
|
+
include_self != nil
|
141
|
+
res=@flickr.call_method('flickr.photos.getContactsPublicPhotos',
|
142
|
+
args)
|
143
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
144
|
+
end
|
145
|
+
|
146
|
+
def getContext(photo)
|
147
|
+
photo = photo.id if photo.class == Flickr::Photo
|
148
|
+
res = @flickr.call_method('flickr.photos.getContext',
|
149
|
+
'photo_id' => photo)
|
150
|
+
return Flickr::Context.from_xml(res)
|
151
|
+
end
|
152
|
+
|
153
|
+
def getCounts(dates=nil,taken_dates=nil)
|
154
|
+
args = {}
|
155
|
+
args['dates'] = dates.map{|d| d.to_i}.join(',') if dates
|
156
|
+
args['taken_dates'] = taken_dates.map{|d| d.to_i}.join(',') if
|
157
|
+
taken_dates
|
158
|
+
res = @flickr.call_method('flickr.photos.getCounts',args)
|
159
|
+
list = []
|
160
|
+
res.elements['/photocounts'].each_element('photocount') do |el|
|
161
|
+
list << Flickr::Count.from_xml(el)
|
162
|
+
end
|
163
|
+
return list
|
164
|
+
end
|
165
|
+
|
166
|
+
def getExif(photo,secret = nil)
|
167
|
+
photo = photo.id if photo.class == Flickr::Photo
|
168
|
+
args = {'photo_id' => photo}
|
169
|
+
args['secret'] = secret if secret
|
170
|
+
res = @flickr.call_method('flickr.photos.getExif',args)
|
171
|
+
return Flickr::Photo.from_xml(res.elements['/photo'],@flickr)
|
172
|
+
end
|
173
|
+
|
174
|
+
def getInfo(photo,secret = nil)
|
175
|
+
photo = (photo.class == Flickr::Photo) ? photo.id : photo
|
176
|
+
args= {'photo_id' => photo}
|
177
|
+
args['secret'] = secret if secret
|
178
|
+
res = @flickr.call_method('flickr.photos.getInfo',args)
|
179
|
+
return Flickr::Photo.from_xml(res.elements['photo'],@flickr)
|
180
|
+
end
|
181
|
+
|
182
|
+
def getNotInSet(extras=nil,per_page = nil, page = nil)
|
183
|
+
args = {}
|
184
|
+
extras = extras.join(',') if extras.class == Array
|
185
|
+
args['extras'] = extras if extras
|
186
|
+
args['per_page'] = per_page if per_page
|
187
|
+
args['page'] = page if page
|
188
|
+
res = @flickr.call_method('flickr.photos.getNotInSet',args)
|
189
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
190
|
+
end
|
191
|
+
|
192
|
+
def getRecent(extras=nil,per_page = nil, page = nil)
|
193
|
+
args = {}
|
194
|
+
extras = extras.join(',') if extras.class == Array
|
195
|
+
args['extras'] = extras if extras
|
196
|
+
args['per_page'] = per_page if per_page
|
197
|
+
args['page'] = page if page
|
198
|
+
res = @flickr.call_method('flickr.photos.getRecent',args)
|
199
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
200
|
+
end
|
201
|
+
|
202
|
+
def getUntagged(extras=nil,per_page = nil, page = nil)
|
203
|
+
args = {}
|
204
|
+
extras = extras.join(',') if extras.class == Array
|
205
|
+
args['extras'] = extras if extras
|
206
|
+
args['per_page'] = per_page if per_page
|
207
|
+
args['page'] = page if page
|
208
|
+
res = @flickr.call_method('flickr.photos.getUntagged',args)
|
209
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
210
|
+
end
|
211
|
+
|
212
|
+
def getSizes(photo)
|
213
|
+
photo_id = (photo.class == Flickr::Photo) ? photo.id : photo
|
214
|
+
photo = (photo.class == Flickr::Photo) ? photo :
|
215
|
+
(@flickr.photo_cache_lookup(photo_id) ||
|
216
|
+
Flickr::Photo.new(@flickr,photo_id))
|
217
|
+
res = @flickr.call_method('flickr.photos.getSizes',
|
218
|
+
'photo_id' => photo_id )
|
219
|
+
photo.sizes = {}
|
220
|
+
res.elements['/sizes'].each_element do |el|
|
221
|
+
size = Flickr::Size.from_xml(el)
|
222
|
+
photo.sizes[size.label.intern] = size
|
223
|
+
end
|
224
|
+
@flickr.photo_cache_store(photo)
|
225
|
+
return photo
|
226
|
+
end
|
227
|
+
|
228
|
+
def setDates(photo,date_posted=nil,date_taken=nil,
|
229
|
+
date_taken_granularity=nil)
|
230
|
+
photo = photo.id if photo.class == Flickr::Photo
|
231
|
+
date_posted = date_posted.to_i if date_posted.class == Time
|
232
|
+
date_taken = @flickr.mysql_datetime(date_taken) if
|
233
|
+
date_taken.class == Time
|
234
|
+
args = {'photo_id' => photo}
|
235
|
+
args['date_posted'] = date_posted if date_posted
|
236
|
+
args['date_taken'] = date_taken if date_taken
|
237
|
+
args['date_taken_granularity'] = date_taken_granularity if
|
238
|
+
date_taken_granularity
|
239
|
+
@flickr.call_method('flickr.photos.setDates',args)
|
240
|
+
end
|
241
|
+
|
242
|
+
def setMeta(photo,title,description)
|
243
|
+
photo = photo.id if photo.class == Flickr::Photo
|
244
|
+
args = {'photo_id' => photo,
|
245
|
+
'title' => title,
|
246
|
+
'description' => description}
|
247
|
+
@flickr.call_method('flickr.photos.setMeta',args)
|
248
|
+
end
|
249
|
+
|
250
|
+
def search(user=nil,tags=nil,tag_mode=nil,text=nil,min_upload_date=nil,
|
251
|
+
max_upload_date=nil,min_taken_date=nil,max_taken_date=nil,
|
252
|
+
license=nil,extras=nil,per_page=nil,page=nil,sort=nil)
|
253
|
+
|
254
|
+
user = user.nsid if user.respond_to?(:nsid)
|
255
|
+
tags = tags.join(',') if tags.class == Array
|
256
|
+
min_upload_date = min_upload_date.to_i if
|
257
|
+
min_upload_date.class == Time
|
258
|
+
max_upload_date = max_upload_date.to_i if
|
259
|
+
max_upload_date.class == Time
|
260
|
+
min_taken_date = @flickr.mysql_datetime(min_taken_date) if
|
261
|
+
min_taken_date.class == Time
|
262
|
+
max_taken_date = @flickr.mysql_datetime(max_taken_date) if
|
263
|
+
max_taken_date.class == Time
|
264
|
+
license = license.id if license.class == Flickr::License
|
265
|
+
extras = extras.join(',') if extras.class == Array
|
266
|
+
|
267
|
+
args = {}
|
268
|
+
args['user_id'] = user if user
|
269
|
+
args['tags'] = tags if tags
|
270
|
+
args['tag_mode'] = tag_mode if tag_mode
|
271
|
+
args['text'] = text if text
|
272
|
+
args['min_upload_date'] = min_upload_date if min_upload_date
|
273
|
+
args['max_upload_date'] = max_upload_date if max_upload_date
|
274
|
+
args['min_taken_date'] = min_taken_date if min_taken_date
|
275
|
+
args['max_taken_date'] = max_taken_date if max_taken_date
|
276
|
+
args['license'] = license if license
|
277
|
+
args['extras'] = extras if extras
|
278
|
+
args['per_page'] = per_page if per_page
|
279
|
+
args['page'] = page if page
|
280
|
+
args['sort'] = sort if sort
|
281
|
+
|
282
|
+
res = @flickr.call_method('flickr.photos.search',args)
|
283
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
284
|
+
end
|
285
|
+
end
|