friendfeed 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/tw2ff +89 -17
- data/friendfeed.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
data/bin/tw2ff
CHANGED
@@ -55,10 +55,6 @@ EOM
|
|
55
55
|
exit 1
|
56
56
|
end
|
57
57
|
|
58
|
-
def puterror(message)
|
59
|
-
STDERR.puts MYNAME + ': ' + e.to_s
|
60
|
-
end
|
61
|
-
|
62
58
|
def putinfo(fmt, *args)
|
63
59
|
STDERR.puts sprintf(fmt, *args)
|
64
60
|
end
|
@@ -76,6 +72,42 @@ def Status(key)
|
|
76
72
|
end
|
77
73
|
end
|
78
74
|
|
75
|
+
def agent
|
76
|
+
$agent ||= Mechanize.new
|
77
|
+
end
|
78
|
+
|
79
|
+
def parse_uri(url)
|
80
|
+
case url
|
81
|
+
when URI
|
82
|
+
url
|
83
|
+
else
|
84
|
+
begin
|
85
|
+
URI.parse(url)
|
86
|
+
rescue URI::InvalidURIError
|
87
|
+
dir, file = File.split(url)
|
88
|
+
URI.parse(File.join(dir, URI.escape(file)))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def get_file(url)
|
94
|
+
uri = parse_uri(url)
|
95
|
+
putinfo 'Fetching %s', uri
|
96
|
+
agent.get_file(uri)
|
97
|
+
end
|
98
|
+
|
99
|
+
class FriendFeed::Client
|
100
|
+
def change_picture_to_url(id, url)
|
101
|
+
t = Tempfile.open("picture")
|
102
|
+
t.write get_file(url)
|
103
|
+
t.close
|
104
|
+
File.open(t.path) { |f|
|
105
|
+
change_picture(id, f)
|
106
|
+
}
|
107
|
+
t.unlink
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
79
111
|
def friendfeed_client
|
80
112
|
$ff_client ||=
|
81
113
|
begin
|
@@ -89,13 +121,20 @@ end
|
|
89
121
|
class Twitter::Base
|
90
122
|
def all_friends
|
91
123
|
list = []
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
break if
|
124
|
+
cursor = -1
|
125
|
+
loop {
|
126
|
+
result = friends(:cursor => cursor)
|
127
|
+
break if result.users.nil?
|
128
|
+
list.concat(result.users)
|
129
|
+
cursor = result[:next_cursor]
|
130
|
+
break if cursor.zero?
|
96
131
|
}
|
97
132
|
list
|
98
133
|
end
|
134
|
+
|
135
|
+
def get_profile(name)
|
136
|
+
friends(:screen_name => name).first
|
137
|
+
end
|
99
138
|
end
|
100
139
|
|
101
140
|
def twitter_client
|
@@ -216,25 +255,58 @@ EOF
|
|
216
255
|
putinfo 'Skipping a protected user %s', name
|
217
256
|
}
|
218
257
|
|
219
|
-
agent = Mechanize.new
|
220
|
-
|
221
258
|
to_subscribe.each { |name|
|
222
259
|
putinfo 'Creating an imaginary friend for %s', name
|
223
260
|
id = ffcli.create_imaginary_friend('(%s)' % name)
|
224
261
|
ffcli.add_twitter(id, name)
|
225
|
-
if picture_urls
|
262
|
+
if url = picture_urls[name]
|
226
263
|
putinfo 'Setting the picture of %s', name
|
227
|
-
|
228
|
-
t.write agent.get_file(picture_urls[name])
|
229
|
-
t.close
|
230
|
-
File.open(t.path) { |f|
|
231
|
-
ffcli.change_picture(id, f)
|
232
|
-
}
|
264
|
+
ffcli.change_picture_to_url(id, url)
|
233
265
|
end
|
234
266
|
}
|
235
267
|
end
|
236
268
|
end
|
237
269
|
|
270
|
+
mode 'icons' do
|
271
|
+
description 'Update imaginary friends icons with those of their Twitter accounts'
|
272
|
+
|
273
|
+
def run
|
274
|
+
twcli = twitter_client()
|
275
|
+
|
276
|
+
picture_urls = {}
|
277
|
+
|
278
|
+
twcli.all_friends.each { |friend|
|
279
|
+
name = friend.screen_name.downcase
|
280
|
+
picture_urls[name] = friend.profile_image_url
|
281
|
+
}
|
282
|
+
|
283
|
+
ffcli = friendfeed_client()
|
284
|
+
|
285
|
+
putinfo "Checking imaginary friends in FriendFeed..."
|
286
|
+
ffcli.get_imaginary_friends.each { |profile|
|
287
|
+
profile['services'].each { |service|
|
288
|
+
url = service['profileUrl'] or next
|
289
|
+
if (name = TWITTER_URI.route_to(url).to_s).match(/\A[A-Za-z0-9_]+\z/)
|
290
|
+
name.downcase!
|
291
|
+
if picture_urls.key?(name)
|
292
|
+
url = picture_urls[name]
|
293
|
+
else
|
294
|
+
friend = twcli.get_profile(name) rescue
|
295
|
+
begin
|
296
|
+
putinfo "Failed to get profile of %s", name
|
297
|
+
next
|
298
|
+
end
|
299
|
+
url = friend.profile_image_url
|
300
|
+
end
|
301
|
+
id = profile['id']
|
302
|
+
putinfo 'Changing the picture of %s', name
|
303
|
+
ffcli.change_picture_to_url(id, url)
|
304
|
+
end
|
305
|
+
}
|
306
|
+
}
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
238
310
|
mode 'likes' do
|
239
311
|
description 'Synchronize Twitter favorites and FriendFeed likes as far as possible'
|
240
312
|
|
data/friendfeed.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{friendfeed}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Akinori MUSHA"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-12}
|
13
13
|
s.default_executable = %q{tw2ff}
|
14
14
|
s.description = %q{This is a Ruby library to provide access to FriendFeed API's.
|
15
15
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-12 00:00:00 +09:00
|
13
13
|
default_executable: tw2ff
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|