dustin-r2flickr 0.1.1.6 → 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/README +12 -4
- data/examples/album_test.rb +2 -2
- data/examples/loadr.rb +24 -24
- data/examples/relatedness.rb +52 -52
- data/examples/setdumpr.rb +18 -18
- data/lib/flickr/auth.rb +52 -53
- data/lib/flickr/base.rb +734 -736
- data/lib/flickr/blogs.rb +22 -22
- data/lib/flickr/favorites.rb +55 -55
- data/lib/flickr/groups.rb +67 -66
- data/lib/flickr/interestingness.rb +15 -15
- data/lib/flickr/licenses.rb +19 -19
- data/lib/flickr/notes.rb +18 -18
- data/lib/flickr/people.rb +64 -64
- data/lib/flickr/photos.rb +262 -259
- data/lib/flickr/photosets.rb +87 -89
- data/lib/flickr/pools.rb +62 -59
- data/lib/flickr/reflection.rb +76 -76
- data/lib/flickr/tags.rb +49 -49
- data/lib/flickr/test.rb +15 -14
- data/lib/flickr/token_cache.rb +20 -20
- data/lib/flickr/transform.rb +7 -5
- data/lib/flickr/upload.rb +186 -186
- data/lib/flickr/urls.rb +41 -40
- metadata +1 -1
data/lib/flickr/blogs.rb
CHANGED
@@ -2,29 +2,29 @@ require 'flickr/base'
|
|
2
2
|
|
3
3
|
class Flickr::Blogs < Flickr::APIBase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
args={'blog'=>blog,'photo'=>photo,'title'=>title,
|
25
|
+
description=>'description'}
|
26
|
+
args['blogs_password'] = blog_password if blog_password
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
@flickr.call_method('flickr.blogs.postPhoto',args)
|
29
|
+
end
|
30
30
|
end
|
data/lib/flickr/favorites.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::Favorites < Flickr::APIBase
|
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
|
-
|
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
59
|
end
|
data/lib/flickr/groups.rb
CHANGED
@@ -1,82 +1,83 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::Groups < Flickr::APIBase
|
4
|
-
|
4
|
+
def pools() @pools ||= Flickr::Pools.new(@flickr,self) end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
23
|
|
24
|
-
|
25
|
-
|
24
|
+
g = @flickr.group_cache_lookup(nsid)
|
25
|
+
g ||= Flickr::Group.new(@flickr,nsid)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
@flickr.group_cache_store(g)
|
34
|
+
cat.groups << g
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
return cat
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
45
|
|
46
|
-
|
47
|
-
|
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
|
46
|
+
res = @flickr.call_method('flickr.groups.getInfo',
|
47
|
+
'group_id' => group)
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
57
|
+
@flickr.group_cache_store(g)
|
58
|
+
return g
|
59
|
+
end
|
75
60
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
81
82
|
|
82
83
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::Interestingness < Flickr::APIBase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
19
|
end
|
data/lib/flickr/licenses.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::Licenses < Flickr::APIBase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
23
|
end
|
data/lib/flickr/notes.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::Notes < Flickr::APIBase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
24
|
end
|
data/lib/flickr/people.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
1
1
|
require 'flickr/base'
|
2
2
|
|
3
3
|
class Flickr::People < Flickr::APIBase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
38
|
|
39
|
-
|
40
|
-
|
39
|
+
g = @flickr.group_cache_lookup(nsid) ||
|
40
|
+
Flickr::Group.new(@flickr,nsid)
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
g.name = att['name']
|
43
|
+
g.eighteenplus = att['eighteenplus'].to_i == 1
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
@flickr.group_cache_store(g)
|
46
|
+
list << g
|
47
|
+
end
|
48
|
+
return list
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
def getPublicPhotos(user,extras=nil,per_page=nil,page=nil)
|
52
|
+
args = {}
|
53
53
|
|
54
|
-
|
54
|
+
user = user.nsid if user.class == Flickr::Person
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
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
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
79
|
end
|