digitalpardoe-rflickr 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +22 -0
- data/lib/flickr.rb +39 -0
- data/lib/flickr/auth.rb +96 -0
- data/lib/flickr/base.rb +813 -0
- data/lib/flickr/blogs.rb +50 -0
- data/lib/flickr/contacts.rb +68 -0
- data/lib/flickr/favorites.rb +79 -0
- data/lib/flickr/groups.rb +102 -0
- data/lib/flickr/interestingness.rb +39 -0
- data/lib/flickr/licenses.rb +43 -0
- data/lib/flickr/notes.rb +44 -0
- data/lib/flickr/people.rb +99 -0
- data/lib/flickr/photos.rb +305 -0
- data/lib/flickr/photosets.rb +124 -0
- data/lib/flickr/pools.rb +90 -0
- data/lib/flickr/reflection.rb +109 -0
- data/lib/flickr/tags.rb +79 -0
- data/lib/flickr/transform.rb +29 -0
- data/lib/flickr/upload.rb +225 -0
- data/lib/flickr/urls.rb +69 -0
- metadata +73 -0
data/lib/flickr/blogs.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Blogs < Flickr::APIBase
|
24
|
+
|
25
|
+
def getList()
|
26
|
+
return @flickr.blog_cache_lookup if @flickr.blog_cache_lookup
|
27
|
+
res = @flickr.call_method('flickr.blogs.getList')
|
28
|
+
list = []
|
29
|
+
res.elements['/blogs'].each_element do |e|
|
30
|
+
att = e.attributes
|
31
|
+
list << Flickr::Blog.new(att['id'], att['name'],
|
32
|
+
att['needspassword'].to_i == 1, att['url'])
|
33
|
+
end
|
34
|
+
@flickr.blog_cache_store(list)
|
35
|
+
return list
|
36
|
+
end
|
37
|
+
|
38
|
+
# blog can be either an integer blog ID or a Blog object
|
39
|
+
# photo can be either an integer photo ID or a Photo object
|
40
|
+
def postPhoto(blog, photo, title, description, blog_password=nil)
|
41
|
+
blog = blog.id if blog.class == Flickr::Blog
|
42
|
+
photo = photo.id if photo.class == Flickr::Photo
|
43
|
+
|
44
|
+
args={'blog'=>blog,'photo'=>photo,'title'=>title,
|
45
|
+
description=>'description'}
|
46
|
+
args['blogs_password'] = blog_password if blog_password
|
47
|
+
|
48
|
+
@flickr.call_method('flickr.blogs.postPhoto',args)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Contacts < Flickr::APIBase
|
24
|
+
def getList(filter=nil)
|
25
|
+
res = filter ?
|
26
|
+
@flickr.call_method('flickr.contacts.getList') :
|
27
|
+
@flickr.call_method('flickr.contacts.getList',
|
28
|
+
'filter'=>filter)
|
29
|
+
list = []
|
30
|
+
res.elements['/contacts'].each_element do |e|
|
31
|
+
att = e.attributes
|
32
|
+
nsid = att['nsid']
|
33
|
+
|
34
|
+
person = @flickr.person_cache_lookup(nsid)
|
35
|
+
person ||= Flickr::Person.new(nsid,att['username'])
|
36
|
+
|
37
|
+
person.realname = att['realname']
|
38
|
+
person.friend = (att['friend'].to_i == 1)
|
39
|
+
person.family = (att['family'].to_i == 1)
|
40
|
+
person.ignored = (att['ignored'].to_i == 1)
|
41
|
+
|
42
|
+
list << person
|
43
|
+
|
44
|
+
@flickr.person_cache_store(person)
|
45
|
+
end
|
46
|
+
return list
|
47
|
+
end
|
48
|
+
|
49
|
+
# User can be either the NSID String or a Contact
|
50
|
+
def getPublicList(user)
|
51
|
+
user = user.nsid if user.class == Flickr::Person
|
52
|
+
res = @flickr.call_method('flickr.contacts.getPublicList',
|
53
|
+
'user_id'=>user)
|
54
|
+
list = []
|
55
|
+
res.elements['/contacts'].each_element do |e|
|
56
|
+
att = e.attributes
|
57
|
+
nsid = att['nsid']
|
58
|
+
|
59
|
+
person = @flickr.person_cache_lookup(nsid)
|
60
|
+
person ||= Flickr::Person.new(nsid,att['username'])
|
61
|
+
|
62
|
+
person.ignored = (att['ignored'].to_i == 1)
|
63
|
+
@flickr.person_cache_store(person)
|
64
|
+
list << person
|
65
|
+
end
|
66
|
+
return list
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Favorites < Flickr::APIBase
|
24
|
+
# photo can be either a Photo or numeric id
|
25
|
+
def add(photo)
|
26
|
+
photo = photo.id if photo.class == Flickr::Photo
|
27
|
+
return @flickr.call_method('flickr.favorites.add',
|
28
|
+
'photo_id' => photo)
|
29
|
+
end
|
30
|
+
|
31
|
+
# photo can be either a Photo or numeric id
|
32
|
+
def remove(photo)
|
33
|
+
photo = photo.id if photo.class == Flickr::Photo
|
34
|
+
return @flickr.call_method('flickr.favorites.remove',
|
35
|
+
'photo_id' => photo)
|
36
|
+
end
|
37
|
+
|
38
|
+
# This is a little weird because all the parametrs are optional,
|
39
|
+
# let's go with it, ok?
|
40
|
+
# user can be a Person or a user NSID
|
41
|
+
# No caching because it's just too hard.
|
42
|
+
def getList(user=nil,extras=nil,per_page=nil,page=nil)
|
43
|
+
args = {}
|
44
|
+
|
45
|
+
user = user.nsid if user.class == Flickr::Person
|
46
|
+
args['user_id'] = user if user
|
47
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
48
|
+
args['per_page'] = per_page if per_page
|
49
|
+
args['page'] = page if page
|
50
|
+
|
51
|
+
res = @flickr.call_method('flickr.favorites.getList',args)
|
52
|
+
att = res.root.attributes
|
53
|
+
return Flickr::PhotoList.from_xml(res,@flickr)
|
54
|
+
end
|
55
|
+
|
56
|
+
# This is a little weird because all the parametrs are optional,
|
57
|
+
# let's go with it, ok?
|
58
|
+
# user can be a Person or a user NSID
|
59
|
+
# No caching because it's just too hard.
|
60
|
+
def getPublicList(user,extras=nil,per_page=nil,page=nil)
|
61
|
+
args = {}
|
62
|
+
|
63
|
+
user = user.nsid if user.class == Flickr::Person
|
64
|
+
|
65
|
+
args['user_id'] = user if user
|
66
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
67
|
+
args['per_page'] = per_page if per_page
|
68
|
+
args['page'] = page if page
|
69
|
+
|
70
|
+
res = @flickr.call_method('flickr.favorites.getPublicList',args)
|
71
|
+
att = res.root.attributes
|
72
|
+
list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
|
73
|
+
att['perpage'].to_i,att['total'].to_i)
|
74
|
+
res.elements['/photos'].each_element do |e|
|
75
|
+
list << Flick::Photo.from_xml(e,@flickr)
|
76
|
+
end
|
77
|
+
return list
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Groups < Flickr::APIBase
|
24
|
+
def pools() @pools ||= Flickr::Pools.new(@flickr,self) end
|
25
|
+
|
26
|
+
# category can be a Category or nsid string
|
27
|
+
def browse(category=nil)
|
28
|
+
category=category.id if (category.class == Flickr::Category ||
|
29
|
+
category.class == Flickr::SubCategory )
|
30
|
+
|
31
|
+
args = category ? {'cat_id' => category } : {}
|
32
|
+
res = @flickr.call_method('flickr.groups.browse',args)
|
33
|
+
att = res.root.attributes
|
34
|
+
cat=Flickr::Category.new(att['name'],att['path'],att['pathids'])
|
35
|
+
res.elements['/category'].each_element('subcat') do |e|
|
36
|
+
att = e.attributes
|
37
|
+
cat.subcats << Flickr::SubCategory.new(att['name'],
|
38
|
+
att['id'],att['count'].to_i)
|
39
|
+
end
|
40
|
+
res.elements['/category'].each_element('group') do |e|
|
41
|
+
att = e.attributes
|
42
|
+
nsid = att['nsid']
|
43
|
+
|
44
|
+
g = @flickr.group_cache_lookup(nsid)
|
45
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
46
|
+
|
47
|
+
g.name = att['name']
|
48
|
+
g.members = att['members'].to_i
|
49
|
+
g.online = att['online'].to_i
|
50
|
+
g.chatnsid = att['chatnsid']
|
51
|
+
g.inchat = att['inchat'].to_i
|
52
|
+
|
53
|
+
@flickr.group_cache_store(g)
|
54
|
+
cat.groups << g
|
55
|
+
end
|
56
|
+
|
57
|
+
return cat
|
58
|
+
end
|
59
|
+
|
60
|
+
# group can be a Group or group nsid
|
61
|
+
def getInfo(group)
|
62
|
+
group = group.nsid if group.class == Flickr::Group
|
63
|
+
g = @flickr.group_cache_lookup(group)
|
64
|
+
return g if g && g.fully_fetched
|
65
|
+
|
66
|
+
res = @flickr.call_method('flickr.groups.getInfo',
|
67
|
+
'group_id' => group)
|
68
|
+
group = res.elements['/group'].attributes['id']
|
69
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
70
|
+
g.name = res.elements['/group/name'].text
|
71
|
+
g.description = res.elements['/group/description'].text
|
72
|
+
g.members = res.elements['/group/members'].text.to_i
|
73
|
+
g.privacy = res.elements['/group/privacy'].text.to_i
|
74
|
+
g.fully_fetched = true
|
75
|
+
|
76
|
+
@flickr.group_cache_store(g)
|
77
|
+
return g
|
78
|
+
end
|
79
|
+
|
80
|
+
def search(text,per_page=nil,page=nil)
|
81
|
+
args = { 'text' => text }
|
82
|
+
args['per_page'] = per_page if per_page
|
83
|
+
args['page'] = page if page
|
84
|
+
res = @flickr.call_method('flickr.groups.search',args)
|
85
|
+
att = res.root.attributes
|
86
|
+
list = Flickr::GroupList.new(att['page'].to_i,att['pages'].to_i,
|
87
|
+
att['perpage'].to_i,att['total'].to_i)
|
88
|
+
res.elements['/groups'].each_element('group') do |e|
|
89
|
+
att = e.attributes
|
90
|
+
nsid = att['nsid']
|
91
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
92
|
+
Flickr::Group.new(@flickr,nsid)
|
93
|
+
g.name = att['name']
|
94
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
95
|
+
|
96
|
+
@flickr.group_cache_store(g)
|
97
|
+
list << g
|
98
|
+
end
|
99
|
+
return list
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Interestingness < Flickr::APIBase
|
24
|
+
def getList(date=nil,extras=nil,per_page=nil,page=nil)
|
25
|
+
args = {}
|
26
|
+
if date
|
27
|
+
args['date'] = date if date.is_a?(String)
|
28
|
+
args['date'] = date.to_s if date.is_a?(Date)
|
29
|
+
args['date'] = @flickr.mysql_date(date) if
|
30
|
+
date.is_a?(Time)
|
31
|
+
end
|
32
|
+
extras = extras.join(',') if extras.class == Array
|
33
|
+
args['extras'] = extras if extras
|
34
|
+
args['per_page'] = per_page if per_page
|
35
|
+
args['page'] = page if page
|
36
|
+
res = @flickr.call_method('flickr.interestingness.getList',args)
|
37
|
+
return Flickr::PhotoSet.from_xml(res.root,@flickr)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Licenses < Flickr::APIBase
|
24
|
+
def getInfo
|
25
|
+
return @flickr.license_cache_lookup if
|
26
|
+
@flickr.license_cache_lookup
|
27
|
+
list = {}
|
28
|
+
res = @flickr.call_method('flickr.photos.licenses.getInfo')
|
29
|
+
res.elements['/licenses'].each_element do |el|
|
30
|
+
lic = Flickr::License.from_xml(el)
|
31
|
+
list[lic.id] = lic
|
32
|
+
end
|
33
|
+
@flickr.license_cache_store(list)
|
34
|
+
return list
|
35
|
+
end
|
36
|
+
|
37
|
+
def setLicense(photo,license)
|
38
|
+
photo = photo.id if photo.class == Flickr::Photo
|
39
|
+
license = license.id if license.class == Flickr::License
|
40
|
+
@flickr.call_method('flickr.photos.licenses.setLicense',
|
41
|
+
'photo_id' => photo, 'license_id' => license)
|
42
|
+
end
|
43
|
+
end
|
data/lib/flickr/notes.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::Notes < Flickr::APIBase
|
24
|
+
def add(photo,x,y,w,h,text)
|
25
|
+
photo = photo.id if photo.class == Flickr::Photo
|
26
|
+
res = @flickr.call_method('flickr.photos.notes.add',
|
27
|
+
'photo_id' => photo, 'note_x' => x, 'note_y' => y,
|
28
|
+
'note_w' => w, 'note_h' => h, 'note_text' => text)
|
29
|
+
return res.elements['/note'].attributes['id']
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete(note)
|
33
|
+
note = note.id if note.class == Flickr::Note
|
34
|
+
res = @flickr.call_method('flickr.photos.notes.delete',
|
35
|
+
'note_id' => note)
|
36
|
+
end
|
37
|
+
|
38
|
+
def edit(note,x,y,w,h,text)
|
39
|
+
note = note.id if note.class == Flickr::Note
|
40
|
+
res = @flickr.call_method('flickr.photos.notes.edit',
|
41
|
+
'note_id' => note, 'note_x' => x, 'note_y' => y,
|
42
|
+
'note_w' => w, 'note_h' => h, 'note_text' => text)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# rFlickr: A Ruby based Flickr API implementation.
|
2
|
+
# Copyright (C) 2009, Alex Pardoe (digital:pardoe)
|
3
|
+
#
|
4
|
+
# Derrived from work by Trevor Schroeder, see here:
|
5
|
+
# http://rubyforge.org/projects/rflickr/.
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or
|
8
|
+
# modify it under the terms of the GNU General Public License
|
9
|
+
# as published by the Free Software Foundation; either version 2
|
10
|
+
# of the License, or (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20
|
+
|
21
|
+
require 'flickr/base'
|
22
|
+
|
23
|
+
class Flickr::People < Flickr::APIBase
|
24
|
+
def findByEmail(find_email)
|
25
|
+
res = @flickr.call_method('flickr.people.findByEmail',
|
26
|
+
'find_email' => find_email)
|
27
|
+
p = Flickr::Person.from_xml(res,@flickr)
|
28
|
+
return p
|
29
|
+
end
|
30
|
+
|
31
|
+
def findByUsername(username)
|
32
|
+
res = @flickr.call_method('flickr.people.findByUsername',
|
33
|
+
'username' => username)
|
34
|
+
p = Flickr::Person.from_xml(res,@flickr)
|
35
|
+
return p
|
36
|
+
end
|
37
|
+
|
38
|
+
# user can be a Person or an nsid
|
39
|
+
def getInfo(user)
|
40
|
+
user = user.nsid if user.class == Flickr::Person
|
41
|
+
res = @flickr.call_method('flickr.people.getInfo',
|
42
|
+
'user_id'=>user)
|
43
|
+
person = Flickr::Person.from_xml(res,@flickr)
|
44
|
+
return person
|
45
|
+
end
|
46
|
+
|
47
|
+
# user can be a Person or an nsid
|
48
|
+
def getPublicGroups(user)
|
49
|
+
require 'flickr/groups'
|
50
|
+
groups = @flickr.groups
|
51
|
+
user = user.nsid if user.class == Flickr::Person
|
52
|
+
res = @flickr.call_method('flickr.people.getPublicGroups',
|
53
|
+
'user_id' => user)
|
54
|
+
list = []
|
55
|
+
res.elements['/groups'].each_element('group') do |e|
|
56
|
+
att = e.attributes
|
57
|
+
nsid = att['nsid']
|
58
|
+
|
59
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
60
|
+
Flickr::Group.new(@flickr,nsid)
|
61
|
+
|
62
|
+
g.name = att['name']
|
63
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
64
|
+
|
65
|
+
@flickr.group_cache_store(g)
|
66
|
+
list << g
|
67
|
+
end
|
68
|
+
return list
|
69
|
+
end
|
70
|
+
|
71
|
+
def getPublicPhotos(user,extras=nil,per_page=nil,page=nil)
|
72
|
+
args = {}
|
73
|
+
|
74
|
+
user = user.nsid if user.class == Flickr::Person
|
75
|
+
|
76
|
+
args['user_id'] = user if user
|
77
|
+
args['extras'] = extras.join(',') if extras.class == Array
|
78
|
+
args['per_page'] = per_page if per_page
|
79
|
+
args['page'] = page if page
|
80
|
+
|
81
|
+
res = @flickr.call_method('flickr.people.getPublicPhotos',args)
|
82
|
+
att = res.root.attributes
|
83
|
+
list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
|
84
|
+
att['perpage'].to_i,att['total'].to_i)
|
85
|
+
res.elements['/photos'].each_element do |e|
|
86
|
+
list << Flickr::Photo.from_xml(e,@flickr)
|
87
|
+
end
|
88
|
+
return list
|
89
|
+
end
|
90
|
+
|
91
|
+
# user can be a Person or an nsid
|
92
|
+
def getUploadStatus(user)
|
93
|
+
user = user.nsid if user.class == Flickr::Person
|
94
|
+
res = @flickr.call_method('flickr.people.getUploadStatus',
|
95
|
+
'user_id'=>user)
|
96
|
+
person = Flickr::Person.from_xml(res,@flickr)
|
97
|
+
return person
|
98
|
+
end
|
99
|
+
end
|