friendfeed 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/bin/tw2ff +68 -1
- data/friendfeed.gemspec +67 -0
- data/lib/friendfeed.rb +31 -27
- data/lib/friendfeed/unofficial.rb +2 -2
- metadata +24 -4
data/.gitignore
CHANGED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -16,6 +16,8 @@ manipulating friends, groups and services for your personal purposes.
|
|
16
16
|
gem.homepage = "http://github.com/knu/ruby-friendfeed"
|
17
17
|
gem.authors = ["Akinori MUSHA"]
|
18
18
|
gem.rubyforge_project = "friendfeed"
|
19
|
+
gem.add_dependency "json"
|
20
|
+
gem.add_dependency "mechanize", ">= 1.0.0"
|
19
21
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
20
22
|
end
|
21
23
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
data/bin/tw2ff
CHANGED
@@ -216,7 +216,7 @@ EOF
|
|
216
216
|
putinfo 'Skipping a protected user %s', name
|
217
217
|
}
|
218
218
|
|
219
|
-
agent =
|
219
|
+
agent = Mechanize.new
|
220
220
|
|
221
221
|
to_subscribe.each { |name|
|
222
222
|
putinfo 'Creating an imaginary friend for %s', name
|
@@ -235,6 +235,73 @@ EOF
|
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
238
|
+
mode 'likes' do
|
239
|
+
description 'Synchronize Twitter favorites and FriendFeed likes as far as possible'
|
240
|
+
|
241
|
+
def run
|
242
|
+
require 'set'
|
243
|
+
require 'pp'
|
244
|
+
|
245
|
+
ffcli = friendfeed_client()
|
246
|
+
ff_me = ffcli.nickname
|
247
|
+
|
248
|
+
twcli = twitter_client()
|
249
|
+
|
250
|
+
favorited = Set[]
|
251
|
+
|
252
|
+
twcli.favorites.each { |favorite|
|
253
|
+
id = favorite['id']
|
254
|
+
# p [id, favorite.user.screen_name]
|
255
|
+
favorited << id
|
256
|
+
}
|
257
|
+
|
258
|
+
liked = Set[]
|
259
|
+
tw_url = {}
|
260
|
+
|
261
|
+
ffcli.get_user_liked_entries.each { |like|
|
262
|
+
url = like['link']
|
263
|
+
case TWITTER_URI.route_to(url).to_s
|
264
|
+
when %r{\A([A-Za-z0-9_]+)/statuses/([0-9]+)\z}
|
265
|
+
id = $2.to_i
|
266
|
+
liked << id
|
267
|
+
tw_url[id] = url
|
268
|
+
end
|
269
|
+
}
|
270
|
+
|
271
|
+
# Favorite FriendFeed-liked entry in Twitter
|
272
|
+
(liked - favorited).each { |id|
|
273
|
+
putinfo "Adding a favorite in Twitter: %s", tw_url[id]
|
274
|
+
twcli.favorite_create(id)
|
275
|
+
}
|
276
|
+
|
277
|
+
# Find Twitter-liked entries in FriendFeed that aren't liked yet
|
278
|
+
(
|
279
|
+
ffcli.get_user_friend_entries('num' => 1000) +
|
280
|
+
ffcli.get_user_discussed_entries
|
281
|
+
).sort_by { |entry|
|
282
|
+
entry["published"]
|
283
|
+
}.each { |entry|
|
284
|
+
# Just in case this entry is not covered by the 'liked' list
|
285
|
+
next if entry['likes'].any? { |like| like['user']['nickname'] == ff_me }
|
286
|
+
|
287
|
+
# Is the source Twitter?
|
288
|
+
url = entry['service']['profileUrl'] or next
|
289
|
+
m = TWITTER_URI.route_to(url).to_s.match(%r{\A([A-Za-z0-9_]+)/statuses/([0-9]+)\z}) or next
|
290
|
+
id = m[2].to_i
|
291
|
+
|
292
|
+
# A different entry with the same source may be liked already
|
293
|
+
next if liked.include?(id)
|
294
|
+
|
295
|
+
if favorited.include?(id)
|
296
|
+
entryid = entry['id']
|
297
|
+
putinfo "Adding a like in FriendFeed: %s", entry['link']
|
298
|
+
ffcli.add_like(entryid)
|
299
|
+
liked << id
|
300
|
+
end
|
301
|
+
}
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
238
305
|
mode 'replies' do
|
239
306
|
description 'Produce an RSS feed for Twitter replies from non-friends'
|
240
307
|
|
data/friendfeed.gemspec
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{friendfeed}
|
8
|
+
s.version = "0.1.9"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Akinori MUSHA"]
|
12
|
+
s.date = %q{2010-02-09}
|
13
|
+
s.default_executable = %q{tw2ff}
|
14
|
+
s.description = %q{This is a Ruby library to provide access to FriendFeed API's.
|
15
|
+
|
16
|
+
It implements official API's as well as unofficial API's to allow
|
17
|
+
manipulating friends, groups and services for your personal purposes.
|
18
|
+
}
|
19
|
+
s.email = %q{knu@idaemons.org}
|
20
|
+
s.executables = ["tw2ff"]
|
21
|
+
s.extra_rdoc_files = [
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc"
|
24
|
+
]
|
25
|
+
s.files = [
|
26
|
+
".document",
|
27
|
+
".gitignore",
|
28
|
+
"LICENSE",
|
29
|
+
"README.rdoc",
|
30
|
+
"Rakefile",
|
31
|
+
"VERSION",
|
32
|
+
"bin/tw2ff",
|
33
|
+
"friendfeed.gemspec",
|
34
|
+
"lib/friendfeed.rb",
|
35
|
+
"lib/friendfeed/compat.rb",
|
36
|
+
"lib/friendfeed/unofficial.rb",
|
37
|
+
"test/friendfeed_test.rb",
|
38
|
+
"test/test_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/knu/ruby-friendfeed}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubyforge_project = %q{friendfeed}
|
44
|
+
s.rubygems_version = %q{1.3.5}
|
45
|
+
s.summary = %q{A Ruby library to provide access to FriendFeed API's}
|
46
|
+
s.test_files = [
|
47
|
+
"test/friendfeed_test.rb",
|
48
|
+
"test/test_helper.rb"
|
49
|
+
]
|
50
|
+
|
51
|
+
if s.respond_to? :specification_version then
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
53
|
+
s.specification_version = 3
|
54
|
+
|
55
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<mechanize>, [">= 1.0.0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<json>, [">= 0"])
|
60
|
+
s.add_dependency(%q<mechanize>, [">= 1.0.0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<json>, [">= 0"])
|
64
|
+
s.add_dependency(%q<mechanize>, [">= 1.0.0"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/friendfeed.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#--
|
3
3
|
# friendfeed.rb - provides access to FriendFeed API's
|
4
4
|
#++
|
5
|
-
# Copyright (c) 2009 Akinori MUSHA <knu@iDaemons.org>
|
5
|
+
# Copyright (c) 2009, 2010 Akinori MUSHA <knu@iDaemons.org>
|
6
6
|
#
|
7
7
|
# All rights reserved. You can redistribute and/or modify it under the same
|
8
8
|
# terms as Ruby.
|
@@ -30,7 +30,7 @@ module FriendFeed
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def get_api_agent
|
33
|
-
@api_agent ||=
|
33
|
+
@api_agent ||= Mechanize.new
|
34
34
|
end
|
35
35
|
|
36
36
|
def validate
|
@@ -46,7 +46,7 @@ module FriendFeed
|
|
46
46
|
|
47
47
|
uri = API_URI + path
|
48
48
|
|
49
|
-
agent =
|
49
|
+
agent = Mechanize.new
|
50
50
|
agent.auth('username', @nickname)
|
51
51
|
JSON.parse(agent.post(uri, { 'apikey' => @remote_key }).body)
|
52
52
|
end
|
@@ -155,77 +155,79 @@ module FriendFeed
|
|
155
155
|
end
|
156
156
|
|
157
157
|
# Gets an array of the most recent public entries.
|
158
|
-
def get_public_entries()
|
159
|
-
call_api('feed/public')['entries']
|
158
|
+
def get_public_entries(options = nil)
|
159
|
+
call_api('feed/public', options)['entries']
|
160
160
|
end
|
161
161
|
|
162
162
|
# Gets an array of the entries the authenticated user would see on
|
163
163
|
# their home page.
|
164
|
-
def get_home_entries()
|
164
|
+
def get_home_entries(options = nil)
|
165
165
|
require_api_login
|
166
|
-
call_api('feed/home')['entries']
|
166
|
+
call_api('feed/home', options)['entries']
|
167
167
|
end
|
168
168
|
|
169
169
|
# Gets an array of the entries for the authenticated user's list
|
170
170
|
# of a given +nickname+
|
171
|
-
def get_list_entries(nickname)
|
171
|
+
def get_list_entries(nickname, options = nil)
|
172
172
|
require_api_login
|
173
|
-
call_api('feed/list/%s' % URI.encode(nickname))['entries']
|
173
|
+
call_api('feed/list/%s' % URI.encode(nickname), options)['entries']
|
174
174
|
end
|
175
175
|
|
176
176
|
# Gets an array of the most recent entries from a user of a given
|
177
177
|
# +nickname+ (defaulted to the authenticated user).
|
178
|
-
def get_user_entries(nickname = @nickname)
|
178
|
+
def get_user_entries(nickname = @nickname, options = nil)
|
179
179
|
nickname or require_api_login
|
180
|
-
call_api('feed/user/%s' % URI.encode(nickname))['entries']
|
180
|
+
call_api('feed/user/%s' % URI.encode(nickname), options)['entries']
|
181
181
|
end
|
182
182
|
|
183
183
|
# Gets an array of the most recent entries from users of given
|
184
184
|
# +nicknames+.
|
185
|
-
def get_multi_user_entries(nicknames)
|
186
|
-
|
185
|
+
def get_multi_user_entries(nicknames, options = nil)
|
186
|
+
new_options = { 'nickname' => nicknames }
|
187
|
+
new_options.merge!(options) if options
|
188
|
+
call_api('feed/user', new_options)['entries']
|
187
189
|
end
|
188
190
|
|
189
191
|
# Gets an array of the most recent entries a user of a given
|
190
192
|
# +nickname+ (defaulted to the authenticated user) has commented
|
191
193
|
# on.
|
192
|
-
def get_user_commented_entries(nickname = @nickname)
|
194
|
+
def get_user_commented_entries(nickname = @nickname, options = nil)
|
193
195
|
nickname or require_api_login
|
194
|
-
call_api('feed/user/%s/comments' % URI.encode(nickname))['entries']
|
196
|
+
call_api('feed/user/%s/comments' % URI.encode(nickname), options)['entries']
|
195
197
|
end
|
196
198
|
|
197
199
|
# Gets an array of the most recent entries a user of a given
|
198
200
|
# +nickname+ (defaulted to the authenticated user) has like'd.
|
199
|
-
def get_user_liked_entries(nickname = @nickname)
|
201
|
+
def get_user_liked_entries(nickname = @nickname, options = nil)
|
200
202
|
nickname or require_api_login
|
201
|
-
call_api('feed/user/%s/likes' % URI.encode(nickname))['entries']
|
203
|
+
call_api('feed/user/%s/likes' % URI.encode(nickname), options)['entries']
|
202
204
|
end
|
203
205
|
|
204
206
|
# Gets an array of the most recent entries a user of a given
|
205
207
|
# +nickname+ (defaulted to the authenticated user) has commented
|
206
208
|
# on or like'd.
|
207
|
-
def get_user_discussed_entries(nickname = @nickname)
|
209
|
+
def get_user_discussed_entries(nickname = @nickname, options = nil)
|
208
210
|
nickname or require_api_login
|
209
|
-
call_api('feed/user/%s/discussion' % URI.encode(nickname))['entries']
|
211
|
+
call_api('feed/user/%s/discussion' % URI.encode(nickname), options)['entries']
|
210
212
|
end
|
211
213
|
|
212
214
|
# Gets an array of the most recent entries from friends of a user
|
213
215
|
# of a given +nickname+ (defaulted to the authenticated user).
|
214
|
-
def get_user_friend_entries(nickname = @nickname)
|
216
|
+
def get_user_friend_entries(nickname = @nickname, options = nil)
|
215
217
|
nickname or require_api_login
|
216
|
-
call_api('feed/user/%s/friends' % URI.encode(nickname))['entries']
|
218
|
+
call_api('feed/user/%s/friends' % URI.encode(nickname), options)['entries']
|
217
219
|
end
|
218
220
|
|
219
221
|
# Gets an array of the most recent entries in a room of a given
|
220
222
|
# +nickname+.
|
221
|
-
def get_room_entries(nickname)
|
222
|
-
call_api('feed/room/%s' % URI.encode(nickname))['entries']
|
223
|
+
def get_room_entries(nickname, options = nil)
|
224
|
+
call_api('feed/room/%s' % URI.encode(nickname), options)['entries']
|
223
225
|
end
|
224
226
|
|
225
227
|
# Gets an array of the entries the authenticated user would see on
|
226
228
|
# their rooms page.
|
227
|
-
def get_rooms_entries()
|
228
|
-
call_api('feed/rooms')['entries']
|
229
|
+
def get_rooms_entries(options = nil)
|
230
|
+
call_api('feed/rooms', options)['entries']
|
229
231
|
end
|
230
232
|
|
231
233
|
# Gets an entry of a given +entryid+. An exception is raised when
|
@@ -241,8 +243,10 @@ module FriendFeed
|
|
241
243
|
end
|
242
244
|
|
243
245
|
# Gets an array of entries that match a given +query+.
|
244
|
-
def search(query)
|
245
|
-
|
246
|
+
def search(query, options = nil)
|
247
|
+
new_options = { 'q' => query }
|
248
|
+
new_options.merge!(options) if options
|
249
|
+
call_api('feed/search', 'q' => new_options)['entries']
|
246
250
|
end
|
247
251
|
|
248
252
|
# Gets an array of entries that link to a given +url+.
|
@@ -36,7 +36,7 @@ module FriendFeed
|
|
36
36
|
def login(nickname, password)
|
37
37
|
@nickname = nickname
|
38
38
|
@password = password
|
39
|
-
@login_agent =
|
39
|
+
@login_agent = Mechanize.new
|
40
40
|
|
41
41
|
page = @login_agent.get(LOGIN_URI)
|
42
42
|
|
@@ -81,7 +81,7 @@ module FriendFeed
|
|
81
81
|
raise message
|
82
82
|
if html_frag = json['html']
|
83
83
|
html_body = '<html><body>' << html_frag << '</body></html>'
|
84
|
-
json['html_parser'] =
|
84
|
+
json['html_parser'] = Mechanize.html_parser.parse(html_body)
|
85
85
|
end
|
86
86
|
json
|
87
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendfeed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
@@ -9,10 +9,29 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-09 00:00:00 +09:00
|
13
13
|
default_executable: tw2ff
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mechanize
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
version:
|
16
35
|
description: |
|
17
36
|
This is a Ruby library to provide access to FriendFeed API's.
|
18
37
|
|
@@ -35,6 +54,7 @@ files:
|
|
35
54
|
- Rakefile
|
36
55
|
- VERSION
|
37
56
|
- bin/tw2ff
|
57
|
+
- friendfeed.gemspec
|
38
58
|
- lib/friendfeed.rb
|
39
59
|
- lib/friendfeed/compat.rb
|
40
60
|
- lib/friendfeed/unofficial.rb
|