ayadn 0.6.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +14 -0
- data/Guardfile +26 -0
- data/LICENSE.txt +22 -0
- data/MANUAL.md +946 -0
- data/README.md +26 -411
- data/Rakefile +6 -0
- data/ayadn.gemspec +39 -0
- data/bin/ayadn +3 -3
- data/lib/ayadn.rb +12 -25
- data/lib/ayadn/action.rb +1121 -0
- data/lib/ayadn/alias.rb +106 -0
- data/lib/ayadn/api.rb +312 -301
- data/lib/ayadn/app.rb +429 -365
- data/lib/ayadn/authorize.rb +127 -28
- data/lib/ayadn/blacklist.rb +116 -0
- data/lib/ayadn/cnx.rb +105 -0
- data/lib/ayadn/databases.rb +110 -0
- data/lib/ayadn/descriptions.rb +1043 -0
- data/lib/ayadn/endpoints.rb +220 -153
- data/lib/ayadn/errors.rb +37 -0
- data/lib/ayadn/extend.rb +4 -10
- data/lib/ayadn/fileops.rb +48 -0
- data/lib/ayadn/logs.rb +32 -0
- data/lib/ayadn/pinboard.rb +46 -35
- data/lib/ayadn/post.rb +229 -212
- data/lib/ayadn/scroll.rb +251 -0
- data/lib/ayadn/set.rb +377 -0
- data/lib/ayadn/settings.rb +195 -0
- data/lib/ayadn/status.rb +226 -165
- data/lib/ayadn/switch.rb +72 -0
- data/lib/ayadn/version.rb +4 -0
- data/lib/ayadn/view.rb +506 -269
- data/lib/ayadn/workers.rb +362 -0
- data/spec/helpers.rb +19 -0
- data/spec/mock/@ericd.json +160 -0
- data/spec/mock/@m.json +45 -0
- data/spec/mock/checkins.json +1856 -0
- data/spec/mock/fwr_@ayadn.json +1077 -0
- data/spec/mock/posted.json +1 -0
- data/spec/mock/stream.json +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/unit/api_spec.rb +61 -0
- data/spec/unit/databases_spec.rb +5 -0
- data/spec/unit/descriptions_spec.rb +9 -0
- data/spec/unit/endpoints_spec.rb +35 -0
- data/spec/unit/post_spec.rb +136 -0
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/view_spec.rb +119 -0
- data/spec/unit/workers_spec.rb +147 -0
- metadata +216 -40
- data/CHANGELOG.md +0 -250
- data/CONTRIBUTORS.md +0 -5
- data/LICENSE.md +0 -14
- data/lib/ayadn/adn_files.rb +0 -84
- data/lib/ayadn/client-http.rb +0 -226
- data/lib/ayadn/colors.rb +0 -62
- data/lib/ayadn/config.yml +0 -35
- data/lib/ayadn/debug.rb +0 -36
- data/lib/ayadn/files.rb +0 -184
- data/lib/ayadn/get-api.rb +0 -43
- data/lib/ayadn/help.rb +0 -152
- data/lib/ayadn/list.rb +0 -89
- data/lib/ayadn/main.rb +0 -542
- data/lib/ayadn/requires.rb +0 -12
- data/lib/ayadn/skip.rb +0 -27
- data/lib/ayadn/tools.rb +0 -208
- data/lib/ayadn/user-stream.rb +0 -91
- data/lib/ayadn/view-channels.rb +0 -120
- data/lib/ayadn/view-interactions.rb +0 -57
- data/lib/ayadn/view-object.rb +0 -195
- data/lib/experiments.rb +0 -109
data/lib/ayadn/alias.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
class Alias < Thor
|
4
|
+
|
5
|
+
desc "alias create CHANNEL ALIAS", "Creates an alias for a channel"
|
6
|
+
long_desc Descriptions.alias_create
|
7
|
+
def create(*args)
|
8
|
+
begin
|
9
|
+
init
|
10
|
+
unless args.empty?
|
11
|
+
channel, channel_alias = args[0], args[1]
|
12
|
+
else
|
13
|
+
puts Status.wrong_arguments
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
if channel.is_integer?
|
17
|
+
Databases.create_alias(channel, channel_alias)
|
18
|
+
Logs.rec.info "Added alias '#{channel_alias}' for channel #{channel}."
|
19
|
+
puts Status.done
|
20
|
+
else
|
21
|
+
puts Status.error_missing_channel_id
|
22
|
+
end
|
23
|
+
rescue => e
|
24
|
+
Errors.global_error("alias/create", args, e)
|
25
|
+
ensure
|
26
|
+
Databases.close_all
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "alias delete ALIAS", "Deletes a previously created alias"
|
31
|
+
long_desc Descriptions.alias_delete
|
32
|
+
def delete(*args)
|
33
|
+
begin
|
34
|
+
init
|
35
|
+
unless args.empty?
|
36
|
+
Databases.delete_alias(args[0])
|
37
|
+
Logs.rec.info "Deleted alias '#{args[0]}'."
|
38
|
+
puts Status.done
|
39
|
+
else
|
40
|
+
puts Status.wrong_arguments
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
rescue => e
|
44
|
+
Errors.global_error("alias/delete", args, e)
|
45
|
+
ensure
|
46
|
+
Databases.close_all
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "alias import DATABASE", "Imports an aliases database from a backed up Ayadn account"
|
51
|
+
long_desc Descriptions.alias_import
|
52
|
+
def import(database)
|
53
|
+
begin
|
54
|
+
init
|
55
|
+
unless database.nil?
|
56
|
+
new_db = File.realpath(database)
|
57
|
+
else
|
58
|
+
puts Status.wrong_arguments
|
59
|
+
exit
|
60
|
+
end
|
61
|
+
if File.exist?(new_db)
|
62
|
+
Databases.import_aliases(new_db)
|
63
|
+
Logs.rec.info "Imported '#{new_db}' values in aliases database."
|
64
|
+
puts Status.done
|
65
|
+
else
|
66
|
+
puts "\nFile '#{new_db}' doesn't exist.".color(:red)
|
67
|
+
end
|
68
|
+
rescue => e
|
69
|
+
Errors.global_error("alias/import", database, e)
|
70
|
+
ensure
|
71
|
+
Databases.close_all
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "alias list", "List previously created aliases"
|
76
|
+
long_desc Descriptions.alias_list
|
77
|
+
def list
|
78
|
+
begin
|
79
|
+
init
|
80
|
+
puts "\e[H\e[2J"
|
81
|
+
list = Databases.aliases
|
82
|
+
unless list.empty? || list.nil?
|
83
|
+
puts Workers.new.build_aliases_list(list)
|
84
|
+
puts "\n"
|
85
|
+
else
|
86
|
+
puts Status.empty_list
|
87
|
+
end
|
88
|
+
rescue => e
|
89
|
+
Errors.global_error("alias/list", args, e)
|
90
|
+
ensure
|
91
|
+
Databases.close_all
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def init
|
98
|
+
Settings.load_config
|
99
|
+
Settings.get_token
|
100
|
+
Settings.init_config
|
101
|
+
Logs.create_logger
|
102
|
+
Databases.open_databases
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
data/lib/ayadn/api.rb
CHANGED
@@ -1,302 +1,313 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: utf-8
|
3
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
2
|
+
module Ayadn
|
3
|
+
class API
|
4
|
+
|
5
|
+
def get_unified(options)
|
6
|
+
if options[:new] || options[:scroll]
|
7
|
+
options = {since_id: Databases.pagination['unified']}
|
8
|
+
end
|
9
|
+
get_parsed_response(Endpoints.new.unified(options))
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_checkins(options)
|
13
|
+
if options[:new] || options[:scroll]
|
14
|
+
options = {since_id: Databases.pagination['explore:checkins']}
|
15
|
+
end
|
16
|
+
get_parsed_response(Endpoints.new.checkins(options))
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_global(options)
|
20
|
+
if options[:new] || options[:scroll]
|
21
|
+
options = {since_id: Databases.pagination['global']}
|
22
|
+
end
|
23
|
+
get_parsed_response(Endpoints.new.global(options))
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_trending(options)
|
27
|
+
if options[:new] || options[:scroll]
|
28
|
+
options = {since_id: Databases.pagination['explore:trending']}
|
29
|
+
end
|
30
|
+
get_explore(:trending, options)
|
31
|
+
end
|
32
|
+
def get_photos(options)
|
33
|
+
if options[:new] || options[:scroll]
|
34
|
+
options = {since_id: Databases.pagination['explore:photos']}
|
35
|
+
end
|
36
|
+
get_explore(:photos, options)
|
37
|
+
end
|
38
|
+
def get_conversations(options)
|
39
|
+
if options[:new] || options[:scroll]
|
40
|
+
options = {since_id: Databases.pagination['explore:replies']}
|
41
|
+
end
|
42
|
+
get_explore(:conversations, options)
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_explore(explore, options)
|
46
|
+
url = Endpoints.new.trending(options) if explore == :trending
|
47
|
+
url = Endpoints.new.photos(options) if explore == :photos
|
48
|
+
url = Endpoints.new.conversations(options) if explore == :conversations
|
49
|
+
get_parsed_response(url)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_mentions(username, options)
|
53
|
+
get_parsed_response(Endpoints.new.mentions(username, options))
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_posts(username, options)
|
57
|
+
get_parsed_response(Endpoints.new.posts(username, options))
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_whatstarred(username, options)
|
61
|
+
get_parsed_response(Endpoints.new.whatstarred(username, options))
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_interactions
|
65
|
+
get_parsed_response(Endpoints.new.interactions)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_token_info
|
69
|
+
get_parsed_response(Endpoints.new.token_info)
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_whoreposted(post_id)
|
73
|
+
get_parsed_response(Endpoints.new.whoreposted(post_id))
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_whostarred(post_id)
|
77
|
+
get_parsed_response(Endpoints.new.whostarred(post_id))
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_convo(post_id, options)
|
81
|
+
get_parsed_response(Endpoints.new.convo(post_id, options))
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_hashtag(hashtag)
|
85
|
+
get_parsed_response(Endpoints.new.hashtag(hashtag))
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_search(words, options)
|
89
|
+
get_parsed_response(Endpoints.new.search(words, options))
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_followings(username)
|
93
|
+
build_list(username, :followings)
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_followers(username)
|
97
|
+
build_list(username, :followers)
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_muted
|
101
|
+
build_list(nil, :muted)
|
102
|
+
end
|
103
|
+
|
104
|
+
def get_blocked
|
105
|
+
build_list(nil, :blocked)
|
106
|
+
end
|
107
|
+
|
108
|
+
def get_raw_list(username, target)
|
109
|
+
options = {:count => 200, :before_id => nil}
|
110
|
+
big = []
|
111
|
+
loop do
|
112
|
+
url = get_list_url(username, target, options)
|
113
|
+
resp = get_parsed_response(url)
|
114
|
+
big << resp
|
115
|
+
break if resp['meta']['min_id'] == nil || resp['meta']['more'] == false
|
116
|
+
options = {:count => 200, :before_id => resp['meta']['min_id']}
|
117
|
+
end
|
118
|
+
big
|
119
|
+
end
|
120
|
+
|
121
|
+
def get_user(username)
|
122
|
+
get_parsed_response(Endpoints.new.user(username))
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_details(post_id, options = {})
|
126
|
+
get_parsed_response(Endpoints.new.single_post(post_id, options))
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_files_list(options)
|
130
|
+
array_of_hashes = []
|
131
|
+
unless options[:all]
|
132
|
+
resp = get_parsed_response(Endpoints.new.files_list(options))
|
133
|
+
resp['data'].each { |p| array_of_hashes << p }
|
134
|
+
else
|
135
|
+
options = {:count => 200, :before_id => nil}
|
136
|
+
loop do
|
137
|
+
resp = get_parsed_response(Endpoints.new.files_list(options))
|
138
|
+
resp['data'].each { |p| array_of_hashes << p }
|
139
|
+
break unless resp['meta']['more']
|
140
|
+
options = {:count => 200, :before_id => resp['meta']['min_id']}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
array_of_hashes
|
144
|
+
end
|
145
|
+
|
146
|
+
def get_file(file_id)
|
147
|
+
get_parsed_response(Endpoints.new.file(file_id))
|
148
|
+
end
|
149
|
+
|
150
|
+
def star(post_id)
|
151
|
+
JSON.parse(CNX.post(Endpoints.new.star(post_id)))
|
152
|
+
end
|
153
|
+
|
154
|
+
def follow(post_id)
|
155
|
+
JSON.parse(CNX.post(Endpoints.new.follow(post_id)))
|
156
|
+
end
|
157
|
+
|
158
|
+
def mute(post_id)
|
159
|
+
JSON.parse(CNX.post(Endpoints.new.mute(post_id)))
|
160
|
+
end
|
161
|
+
|
162
|
+
def block(username)
|
163
|
+
JSON.parse(CNX.post(Endpoints.new.block(username)))
|
164
|
+
end
|
165
|
+
|
166
|
+
def repost(post_id)
|
167
|
+
JSON.parse(CNX.post(Endpoints.new.repost(post_id)))
|
168
|
+
end
|
169
|
+
|
170
|
+
def delete_post(post_id)
|
171
|
+
JSON.parse(CNX.delete(Endpoints.new.delete_post(post_id)))
|
172
|
+
end
|
173
|
+
|
174
|
+
def unstar(post_id)
|
175
|
+
JSON.parse(CNX.delete(Endpoints.new.star(post_id)))
|
176
|
+
end
|
177
|
+
|
178
|
+
def unfollow(username)
|
179
|
+
JSON.parse(CNX.delete(Endpoints.new.follow(username)))
|
180
|
+
end
|
181
|
+
|
182
|
+
def unmute(username)
|
183
|
+
JSON.parse(CNX.delete(Endpoints.new.mute(username)))
|
184
|
+
end
|
185
|
+
|
186
|
+
def unblock(username)
|
187
|
+
JSON.parse(CNX.delete(Endpoints.new.block(username)))
|
188
|
+
end
|
189
|
+
|
190
|
+
def unrepost(post_id)
|
191
|
+
resp = JSON.parse(CNX.delete(Endpoints.new.repost(post_id)))
|
192
|
+
if resp['data']['repost_of']
|
193
|
+
JSON.parse(CNX.delete(Endpoints.new.repost(resp['data']['repost_of']['id'])))
|
194
|
+
else
|
195
|
+
resp
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def get_channels
|
200
|
+
options = {:count => 200, :recent_message => 1, :annotations => 1, :before_id => nil}
|
201
|
+
get_parsed_response(Endpoints.new.channels(options))
|
202
|
+
# big = []
|
203
|
+
# loop do
|
204
|
+
# resp = get_parsed_response(Endpoints.new.channels(options))
|
205
|
+
# #check_response_meta_code(resp)
|
206
|
+
# big << resp
|
207
|
+
# break if resp['meta']['more'] == false
|
208
|
+
# options = {:count => 200, :before_id => resp['meta']['min_id']}
|
209
|
+
# end
|
210
|
+
# big
|
211
|
+
end
|
212
|
+
|
213
|
+
def get_messages(channel_id, options)
|
214
|
+
if options[:new] || options[:scroll]
|
215
|
+
options = {since_id: Databases.pagination["channel:#{channel_id}"]}
|
216
|
+
end
|
217
|
+
get_parsed_response(Endpoints.new.messages(channel_id, options))
|
218
|
+
end
|
219
|
+
|
220
|
+
def get_config
|
221
|
+
get_parsed_response(Endpoints.new.config_api_url)
|
222
|
+
end
|
223
|
+
|
224
|
+
def check_response_meta_code(res)
|
225
|
+
if res['meta']['code'] == 200
|
226
|
+
res
|
227
|
+
else
|
228
|
+
Errors.global_error("api/check_response_meta_code", nil, res['meta'])
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def self.build_query(arg)
|
233
|
+
count = Settings.options[:counts][:default]
|
234
|
+
if arg[:count]
|
235
|
+
if arg[:count].to_s.is_integer?
|
236
|
+
count = arg[:count]
|
237
|
+
end
|
238
|
+
end
|
239
|
+
directed = Settings.options[:timeline][:directed]
|
240
|
+
if arg[:directed]
|
241
|
+
if arg[:directed] == 0 || arg[:directed] == 1
|
242
|
+
directed = arg[:directed]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
deleted = Settings.options[:timeline][:deleted]
|
246
|
+
if arg[:deleted]
|
247
|
+
if arg[:deleted] == 0 || arg[:deleted] == 1
|
248
|
+
deleted = arg[:deleted]
|
249
|
+
end
|
250
|
+
end
|
251
|
+
html = Settings.options[:timeline][:html]
|
252
|
+
if arg[:html]
|
253
|
+
if arg[:html] == 0 || arg[:html] == 1
|
254
|
+
html = arg[:html]
|
255
|
+
end
|
256
|
+
end
|
257
|
+
annotations = Settings.options[:timeline][:annotations]
|
258
|
+
if arg[:annotations]
|
259
|
+
if arg[:annotations] == 0 || arg[:annotations] == 1
|
260
|
+
annotations = arg[:annotations]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
if arg[:since_id]
|
264
|
+
"&count=#{count}&include_html=#{html}&include_directed=#{directed}&include_deleted=#{deleted}&include_annotations=#{annotations}&since_id=#{arg[:since_id]}"
|
265
|
+
elsif arg[:recent_message]
|
266
|
+
"&count=#{count}&include_html=#{html}&include_directed=#{directed}&include_deleted=#{deleted}&include_annotations=#{annotations}&include_recent_message=#{arg[:recent_message]}"
|
267
|
+
else
|
268
|
+
"&count=#{count}&include_html=#{html}&include_directed=#{directed}&include_deleted=#{deleted}&include_annotations=#{annotations}"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
private
|
273
|
+
|
274
|
+
def get_parsed_response(url)
|
275
|
+
JSON.parse(CNX.get_response_from(url))
|
276
|
+
end
|
277
|
+
|
278
|
+
def get_original_if_repost(resp)
|
279
|
+
if resp['repost_of']
|
280
|
+
resp['repost_of']
|
281
|
+
else
|
282
|
+
resp
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def build_list(username, target)
|
287
|
+
options = {:count => 200, :before_id => nil}
|
288
|
+
big_hash = {}
|
289
|
+
loop do
|
290
|
+
url = get_list_url(username, target, options)
|
291
|
+
resp = get_parsed_response(url)
|
292
|
+
big_hash.merge!(Workers.extract_users(resp))
|
293
|
+
break if resp['meta']['min_id'] == nil
|
294
|
+
options = {:count => 200, :before_id => resp['meta']['min_id']}
|
295
|
+
end
|
296
|
+
big_hash
|
297
|
+
end
|
298
|
+
|
299
|
+
def get_list_url(username, target, options)
|
300
|
+
case target
|
301
|
+
when :followings
|
302
|
+
Endpoints.new.followings(username, options)
|
303
|
+
when :followers
|
304
|
+
Endpoints.new.followers(username, options)
|
305
|
+
when :muted
|
306
|
+
Endpoints.new.muted(options)
|
307
|
+
when :blocked
|
308
|
+
Endpoints.new.blocked(options)
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
end
|