ayadn 1.7.7 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be6bf71c51621964932bfa952f50e7622cf90d1f
4
- data.tar.gz: 772b97b6a9f4257ef2e9bc56f67690c238e49ff4
3
+ metadata.gz: 080c008e1d5732b1310756187a89ad3995504abe
4
+ data.tar.gz: 085cae4dcd6c0758c77c77f553d4cb55d24ab0a7
5
5
  SHA512:
6
- metadata.gz: 88b558768373966f568626ddbbfb9c2bc6cec3d96f45f48a0786d374e0d0bb44aef7eefe488cff17badf4f6eff0912e5532d019eab9e741ce1372f7cede6ad6f
7
- data.tar.gz: 75e1ff70e91f48e29340256f2e0db255dfd3555c5fecdbf7271b66281d5133ace8d3f13a275548e51c784f878534dbfd7b68efd1e982ccbe66d57b5d162b2826
6
+ metadata.gz: 96318e16dee9df86808ad68267d9319e589ec7de004c6be8c208917dda19665b496d34560b4a3214a19d9318eae7c57fecf0c0c92c3d209f49eae9b672ed6239
7
+ data.tar.gz: 6a52b3b2cdb1ec73dc647fe47b1625ecfcb25460222c01f29b03d9f0a4045dfb011115715b56dc06efb918c907405e68e91e97d947b85cfbf04622df38b85fa7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 1.8.0 - 2014-10-29 - 'Cascadeur'
2
+
3
+ - New: command to view all unread PMs
4
+ - New: channel commands can update unread status (default: true)
5
+ - Fix: nowplaying iTunes Store results are much more accurate
6
+ - Fix: faster follow/mute/block/delete actions
7
+ - Fix: root post of conversation shows "has replies" symbol
8
+ - Fix: clear screen before showing spinner in scroll
9
+ - Fix: save lists if backup enabled
10
+ - Update: debug info included in posts annotations
11
+ - Update: gem dependencies
12
+
1
13
  # 1.7.7 - 2014-10-26 - 'The Twins'
2
14
 
3
15
  - Fix: max characters information when sending to a channel
data/ayadn.gemspec CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.required_ruby_version = '>= 2.0.0'
24
24
 
25
- spec.add_dependency "thor", "~> 0.18"
26
- spec.add_dependency "rest-client", "~> 1.6"
25
+ spec.add_dependency "thor", "~> 0.19"
26
+ spec.add_dependency "rest-client", "~> 1.7"
27
27
  spec.add_dependency "rainbow", "~> 2.0"
28
28
  spec.add_dependency "terminal-table", "~> 1.4"
29
29
  spec.add_dependency "daybreak", "~> 0.3"
@@ -32,12 +32,12 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "spotlite", "~> 0.8"
33
33
  spec.add_dependency "tvdb_party", "~> 0.7"
34
34
 
35
- spec.add_development_dependency "bundler", "~> 1.5"
36
- spec.add_development_dependency "rake", "~> 10.1"
37
- spec.add_development_dependency "rspec", "~> 2.14"
35
+ spec.add_development_dependency "bundler", "~> 1.6"
36
+ spec.add_development_dependency "rake", "~> 10.3"
37
+ spec.add_development_dependency "rspec", "~> 3.1"
38
38
  spec.add_development_dependency "rb-fsevent", "~> 0.9"
39
- spec.add_development_dependency "guard-rspec", "~> 4.2"
40
- spec.add_development_dependency "coveralls"
39
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
40
+ spec.add_development_dependency "coveralls", "~> 0.7"
41
41
  #spec.add_development_dependency "fakefs", "~> 0.5"
42
42
 
43
43
  spec.post_install_message = "Thank you for installing Ayadn!"
data/doc/05-streams.md CHANGED
@@ -219,8 +219,36 @@ You can replace the channel id with its alias if you previously defined one:
219
219
 
220
220
  `ayadn -ms mychannelalias`
221
221
 
222
+ By default, Ayadn will mark the channel as read after running the `messages` command.
223
+
224
+ You can pass an option to avoid this for the time of the command:
225
+
226
+ `ayadn -ms -z 46217`
227
+
228
+ Or you can set it off permanently:
229
+
230
+ `ayadn set marker update_messages false`
231
+
222
232
  Since version 1.7.7, Ayadn shows the full oembed links in messages if any. As these links can be quite long and complex, you can remove them from the view if you want with `ayadn set timeline show_channel_oembed false`.
223
233
 
234
+ # UNREAD MESSAGES
235
+
236
+ Show *all* unread messages.
237
+
238
+ `ayadn messages_unread`
239
+
240
+ `ayadn -pmu`
241
+
242
+ Ayadn will mark all your PM channels as read after running this command.
243
+
244
+ You can pass an option to avoid this for the time of the command:
245
+
246
+ `ayadn -pmu -z`
247
+
248
+ Or you can set it off permanently:
249
+
250
+ `ayadn set marker update_messages false`
251
+
224
252
  # WHATSTARRED
225
253
 
226
254
  Show posts starred by a specific user.
data/doc/06-post.md CHANGED
@@ -83,7 +83,17 @@ Send a private message to a specific user.
83
83
 
84
84
  `ayadn pm @ericd`
85
85
 
86
- Ayadn will then show you the *write* prompt.
86
+ Ayadn will then show you the *write* prompt.
87
+
88
+ By default, Ayadn will mark this private messages channel as read once the message has been sent.
89
+
90
+ You can pass an option to avoid this for the time of the command:
91
+
92
+ `ayadn pm -z @ericd`
93
+
94
+ Or even invert this behaviour permanently with `set`:
95
+
96
+ `ayadn set marker update_messages false`
87
97
 
88
98
  # SEND
89
99
 
@@ -95,6 +105,16 @@ Send a message to an App.net CHANNEL.
95
105
 
96
106
  Ayadn will then show you the *write* prompt.
97
107
 
108
+ By default, Ayadn will mark this channel as read once the message has been sent.
109
+
110
+ You can pass an option to avoid this for the time of the command:
111
+
112
+ `ayadn -C -z 46217`
113
+
114
+ Or even invert this behaviour permanently with `set`:
115
+
116
+ `ayadn set marker update_messages false`
117
+
98
118
  If you've already created an [alias](#alias) for the channel, you can post to it with:
99
119
 
100
120
  `ayadn send mychannelalias`
data/lib/ayadn/action.rb CHANGED
@@ -11,6 +11,7 @@ module Ayadn
11
11
  @workers = Workers.new
12
12
  @stream = Stream.new(@api, @view, @workers)
13
13
  @search = Search.new(@api, @view, @workers)
14
+ @shell = Thor::Shell::Color.new
14
15
  Settings.load_config
15
16
  Settings.get_token
16
17
  Settings.init_config
@@ -88,7 +89,6 @@ module Ayadn
88
89
  print Status.deleting_post(post_id)
89
90
  resp = @api.delete_post(post_id)
90
91
  Check.has_been_deleted(post_id, resp)
91
- sleep 1 unless ids.length == 1
92
92
  end
93
93
  rescue => e
94
94
  Errors.global_error({error: e, caller: caller, data: [post_id]})
@@ -107,7 +107,6 @@ module Ayadn
107
107
  print Status.deleting_message(message_id)
108
108
  resp = @api.delete_message(channel_id, message_id)
109
109
  Check.message_has_been_deleted(message_id, resp)
110
- sleep 1 unless ids.length == 1
111
110
  end
112
111
  rescue => e
113
112
  Errors.global_error({error: e, caller: caller, data: [message_id]})
@@ -122,7 +121,6 @@ module Ayadn
122
121
  users.each do |user|
123
122
  resp = @api.unfollow(user)
124
123
  Check.has_been_unfollowed(user, resp)
125
- sleep 1 unless users.length == 1
126
124
  end
127
125
  rescue => e
128
126
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -137,7 +135,6 @@ module Ayadn
137
135
  users.each do |user|
138
136
  resp = @api.follow(user)
139
137
  Check.has_been_followed(user, resp)
140
- sleep 1 unless users.length == 1
141
138
  end
142
139
  rescue => e
143
140
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -152,7 +149,6 @@ module Ayadn
152
149
  users.each do |user|
153
150
  resp = @api.unmute(user)
154
151
  Check.has_been_unmuted(user, resp)
155
- sleep 1 unless users.length == 1
156
152
  end
157
153
  rescue => e
158
154
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -167,7 +163,6 @@ module Ayadn
167
163
  users.each do |user|
168
164
  resp = @api.mute(user)
169
165
  Check.has_been_muted(user, resp)
170
- sleep 1 unless users.length == 1
171
166
  end
172
167
  rescue => e
173
168
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -182,7 +177,6 @@ module Ayadn
182
177
  users.each do |user|
183
178
  resp = @api.unblock(user)
184
179
  Check.has_been_unblocked(user, resp)
185
- sleep 1 unless users.length == 1
186
180
  end
187
181
  rescue => e
188
182
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -197,7 +191,6 @@ module Ayadn
197
191
  users.each do |user|
198
192
  resp = @api.block(user)
199
193
  Check.has_been_blocked(user, resp)
200
- sleep 1 unless users.length == 1
201
194
  end
202
195
  rescue => e
203
196
  Errors.global_error({error: e, caller: caller, data: [usernames]})
@@ -451,6 +444,67 @@ module Ayadn
451
444
  end
452
445
  end
453
446
 
447
+ def messages_unread(options)
448
+ begin
449
+ if options[:silent]
450
+ Settings.options[:marker][:update_messages] = false
451
+ end
452
+ puts "\n"
453
+ @shell.say_status :searching, "channels with unread PMs"
454
+ response = @api.get_channels
455
+ unread_channels = []
456
+ response['data'].map do |ch|
457
+ if ch['type'] == "net.app.core.pm" && ch['has_unread'] == true
458
+ unread_channels << ch['id']
459
+ end
460
+ end
461
+ abort(Status.no_new_messages) if unread_channels.empty?
462
+ unread_messages = {}
463
+ unread_channels.each do |id|
464
+ @shell.say_status :downloading, "messages from channel #{id}"
465
+ since = Databases.pagination["channel:#{id}"]
466
+ unless since.nil?
467
+ api_options = {count: 20, since_id: since}
468
+ else
469
+ api_options = {count: 20}
470
+ end
471
+ ch = @api.get_messages(id, api_options)
472
+ last_read_id = ch['meta']['marker']['last_read_id'].to_i
473
+ last_message_id = ch['meta']['max_id']
474
+ messages = []
475
+ ch['data'].each do |msg|
476
+ messages << msg if msg['id'].to_i > last_read_id
477
+ end
478
+ unread_messages[id] = [messages, last_message_id]
479
+ end
480
+ if Settings.options[:marker][:update_messages] == true
481
+ unread_messages.each do |k,v|
482
+ name = "channel:#{k}"
483
+ Databases.pagination[name] = v[1]
484
+ resp = @api.update_marker(name, v[1])
485
+ res = JSON.parse(resp)
486
+ if res['meta']['code'] != 200
487
+ @shell.say_status :error, "couldn't update channel #{k} as read", :red
488
+ else
489
+ @shell.say_status :updated, "channel #{k} as read", :green
490
+ end
491
+ end
492
+ end
493
+ @view.clear_screen
494
+ unread_messages.each do |k,v|
495
+ if v[0].length == 1
496
+ puts "\nUnread message from channel #{k}:\n".color(Settings.options[:colors][:unread]).inverse
497
+ else
498
+ puts "\nUnread messages from channel #{k}:\n".color(Settings.options[:colors][:unread]).inverse
499
+ end
500
+ @view.show_posts(v[0])
501
+ end
502
+ puts "\n" if Settings.options[:timeline][:compact]
503
+ rescue => e
504
+ Errors.global_error({error: e, caller: caller, data: [options]})
505
+ end
506
+ end
507
+
454
508
  def pin(post_id, usertags)
455
509
  require 'pinboard'
456
510
  require 'base64'
@@ -530,6 +584,9 @@ module Ayadn
530
584
 
531
585
  def pmess(username, options = {})
532
586
  begin
587
+ if options[:silent]
588
+ Settings.options[:marker][:update_messages] = false
589
+ end
533
590
  Check.no_username(username)
534
591
  username = [@workers.add_arobase(username)]
535
592
  writer = Post.new
@@ -545,6 +602,18 @@ module Ayadn
545
602
  options = NowWatching.new.get_poster(settings[:poster], settings)
546
603
  end
547
604
  resp = writer.pm({options: options, text: text, username: username})
605
+ if Settings.options[:marker][:update_messages] == true
606
+ if resp['meta']['code'] == 200
607
+ data = resp['data']
608
+ name = "channel:#{data['channel_id']}"
609
+ Databases.pagination[name] = data['id']
610
+ marked = @api.update_marker(name, data['id'])
611
+ updated = JSON.parse(marked)
612
+ if updated['meta']['code'] != 200
613
+ raise "couldn't update channel #{data['channel_id']} as read"
614
+ end
615
+ end
616
+ end
548
617
  FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
549
618
  @view.clear_screen
550
619
  puts Status.yourmessage(username[0])
@@ -598,6 +667,9 @@ module Ayadn
598
667
 
599
668
  def send_to_channel(channel_id, options = {})
600
669
  begin
670
+ if options[:silent]
671
+ Settings.options[:marker][:update_messages] = false
672
+ end
601
673
  channel_id = @workers.get_channel_id_from_alias(channel_id)
602
674
  writer = Post.new
603
675
  puts Status.writing
@@ -611,12 +683,24 @@ module Ayadn
611
683
  options = NowWatching.new.get_poster(settings[:poster], settings)
612
684
  end
613
685
  resp = writer.message({options: options, id: channel_id, text: lines_array.join("\n")})
686
+ if Settings.options[:marker][:update_messages] == true
687
+ if resp['meta']['code'] == 200
688
+ data = resp['data']
689
+ name = "channel:#{data['channel_id']}"
690
+ Databases.pagination[name] = data['id']
691
+ marked = @api.update_marker(name, data['id'])
692
+ updated = JSON.parse(marked)
693
+ if updated['meta']['code'] != 200
694
+ raise "couldn't update channel #{data['channel_id']} as read"
695
+ end
696
+ end
697
+ end
614
698
  FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
615
699
  @view.clear_screen
616
700
  puts Status.yourpost
617
701
  @view.show_posted(resp)
618
702
  rescue => e
619
- Errors.global_error({error: e, caller: caller, data: [channel_id]})
703
+ Errors.global_error({error: e, caller: caller, data: [channel_id, options]})
620
704
  end
621
705
  end
622
706
 
@@ -23,8 +23,13 @@ module Ayadn
23
23
  "type" => "com.ayadn.user",
24
24
  "value" => {
25
25
  "+net.app.core.user" => {
26
- "user_id" => "#{Settings.config[:identity][:handle]}",
26
+ "user_id" => Settings.config[:identity][:handle],
27
27
  "format" => "basic"
28
+ },
29
+ "env" => {
30
+ "platform" => Settings.config[:platform],
31
+ "ruby" => Settings.config[:ruby],
32
+ "locale" => Settings.config[:locale]
28
33
  }
29
34
  }
30
35
  },
@@ -38,7 +43,7 @@ module Ayadn
38
43
  "id" => "69904",
39
44
  "email" => "eric@aya.io"
40
45
  },
41
- "version" => "#{Settings.config[:version]}"
46
+ "version" => Settings.config[:version]
42
47
  }
43
48
  }
44
49
  ]
data/lib/ayadn/api.rb CHANGED
@@ -225,7 +225,7 @@ module Ayadn
225
225
  # big
226
226
  end
227
227
 
228
- def get_channel channel_id, options
228
+ def get_channel channel_id, options = {}
229
229
  options = {:recent_message => 1, :annotations => 1, :before_id => nil}
230
230
  get_parsed_response(Endpoints.new.channel(channel_id, options))
231
231
  end
@@ -247,6 +247,15 @@ module Ayadn
247
247
  end
248
248
  end
249
249
 
250
+ def update_marker(name, last_read_id)
251
+ obj = {
252
+ 'name' => name,
253
+ 'id' => last_read_id
254
+ }
255
+ url = Endpoints.new.update_marker
256
+ CNX.post(url, obj)
257
+ end
258
+
250
259
  def self.build_query(arg)
251
260
  if arg[:count].to_s.is_integer?
252
261
  count = arg[:count]
data/lib/ayadn/app.rb CHANGED
@@ -366,10 +366,19 @@ module Ayadn
366
366
  option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
367
367
  option :count, aliases: "-c", type: :numeric, desc: "Specify the number of messages to retrieve"
368
368
  option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
369
+ option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read"
369
370
  def messages(channel_id)
370
371
  Action.new.messages(channel_id, options)
371
372
  end
372
373
 
374
+ desc "messages_unread", "Show your unread private messages (-pmu)"
375
+ map "-pmu" => :messages_unread
376
+ option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channels as read"
377
+ long_desc Descriptions.messages_unread
378
+ def messages_unread
379
+ Action.new.messages_unread(options)
380
+ end
381
+
373
382
  desc "pin POST TAG(S)", "Export a post's link and text with tags to Pinboard"
374
383
  long_desc Descriptions.pin
375
384
  def pin(post_id, *tags)
@@ -405,6 +414,7 @@ module Ayadn
405
414
  option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new message"
406
415
  option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new message"
407
416
  option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new message"
417
+ option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read"
408
418
  def pm(*username)
409
419
  Action.new.pmess(username, options)
410
420
  end
@@ -416,6 +426,7 @@ module Ayadn
416
426
  option :youtube, aliases: "-Y", type: :array, desc: "Embed a Youtube video in the new message"
417
427
  option :vimeo, aliases: "-V", type: :array, desc: "Embed a Vimeo video in the new message"
418
428
  option :poster, aliases: "-M", type: :array, desc: "Embed a movie poster, from title, in the new message"
429
+ option :silent, aliases: "-z", type: :boolean, desc: "Do not mark the channel as read"
419
430
  def send_to_channel(channel_id)
420
431
  Action.new.send_to_channel(channel_id, options)
421
432
  end
@@ -4,7 +4,7 @@ module Ayadn
4
4
  class Databases
5
5
 
6
6
  class << self
7
- attr_accessor :users, :index, :pagination, :aliases, :blacklist, :bookmarks, :nicerank
7
+ attr_accessor :users, :index, :pagination, :aliases, :blacklist, :bookmarks, :nicerank, :channels
8
8
  end
9
9
 
10
10
  def self.open_databases
@@ -18,13 +18,14 @@ module Ayadn
18
18
  @blacklist = self.init "#{Settings.config[:paths][:db]}/blacklist.db"
19
19
  @bookmarks = self.init "#{Settings.config[:paths][:db]}/bookmarks.db"
20
20
  @nicerank = self.init "#{Settings.config[:paths][:db]}/nicerank.db"
21
+ @channels = self.init "#{Settings.config[:paths][:db]}/channels.db"
21
22
  if Settings.options[:timeline][:show_debug] == true
22
23
  puts "\n-Done-\n"
23
24
  end
24
25
  end
25
26
 
26
27
  def self.all_dbs
27
- [@users, @index, @pagination, @aliases, @blacklist, @bookmarks, @nicerank]
28
+ [@users, @index, @pagination, @aliases, @blacklist, @bookmarks, @nicerank, @channels]
28
29
  end
29
30
 
30
31
  def self.close_all
@@ -176,6 +177,14 @@ module Ayadn
176
177
  @bookmarks[post_id][:title] = new_title
177
178
  end
178
179
 
180
+ def self.add_channel_object channel
181
+ @channels[channel['id']] = channel
182
+ end
183
+
184
+ def self.remove_channel channel_id
185
+ @channels.delete channel_id
186
+ end
187
+
179
188
  end
180
189
 
181
190
  end
@@ -733,7 +733,41 @@ module Ayadn
733
733
 
734
734
  ayadn -ms -s 46217
735
735
 
736
- If you've set an alias for the channel, you can display its messages with 'ayadn -ms my_alias'
736
+ Ayadn will mark this PM channel as read after running this command.
737
+
738
+ You can pass an option, `-z`, to avoid this for the time of the command:
739
+
740
+ ayadn -ms -z 46217
741
+
742
+ Or you can set it off permanently:
743
+
744
+ ayadn set marker update_messages false
745
+
746
+ If you've set an alias for the channel, you can use it instead of the channel id:
747
+
748
+ ayadn -ms my_alias
749
+ \n\n
750
+ USAGE
751
+ end
752
+ def self.messages_unread
753
+ <<-USAGE
754
+ Shows your unread private messages.
755
+
756
+ Usage:
757
+
758
+ ayadn messages_unread
759
+
760
+ ayadn -pmu
761
+
762
+ Ayadn will mark all your PM channels as read after running this command.
763
+
764
+ You can pass an option, `-z`, to avoid this for the time of the command:
765
+
766
+ ayadn -pmu -z
767
+
768
+ Or you can set it off permanently:
769
+
770
+ ayadn set marker update_messages false
737
771
  \n\n
738
772
  USAGE
739
773
  end
@@ -1195,13 +1229,19 @@ module Ayadn
1195
1229
  <<-USAGE
1196
1230
  Post the track you're listening to.
1197
1231
 
1198
- Usage:
1232
+ Ayadn will insert the album cover, a link and a description.
1233
+
1234
+ Usage with iTunes (Mac Os X only):
1199
1235
 
1200
1236
  ayadn nowplaying
1201
1237
 
1202
1238
  ayadn -np
1203
1239
 
1204
- (works only with iTunes and Mac Os X)
1240
+ Usage with Last.fm:
1241
+
1242
+ ayadn nowplaying -l
1243
+
1244
+ ayadn -np -l
1205
1245
  \n\n
1206
1246
  USAGE
1207
1247
  end
@@ -257,11 +257,11 @@ module Ayadn
257
257
  end
258
258
 
259
259
  def channel(channel_id, options = {})
260
- "#{@channels_url}?ids=#{channel_id.join(',')}&access_token=#{Settings.user_token}#{API.build_query(options)}"
260
+ "#{@channels_url}?ids=#{channel_id.join(',')}&access_token=#{Settings.user_token}#{API.build_query(options)}&include_marker=1"
261
261
  end
262
262
 
263
263
  def messages(channel_id, options = {})
264
- "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}&include_machine=1"
264
+ "#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}&include_machine=1&include_marker=1"
265
265
  end
266
266
 
267
267
  def avatar
@@ -272,5 +272,9 @@ module Ayadn
272
272
  "#{@users_url}me/cover"
273
273
  end
274
274
 
275
+ def update_marker
276
+ "#{@posts_url}marker?access_token=#{Settings.user_token}"
277
+ end
278
+
275
279
  end
276
280
  end
data/lib/ayadn/fileops.rb CHANGED
@@ -83,9 +83,7 @@ module Ayadn
83
83
  end
84
84
  end
85
85
 
86
- private
87
-
88
- def get_users(list)
86
+ def self.get_users(list)
89
87
  h = {}
90
88
  list.each {|k,v| h[k] = { username: v[0], name: v[1] }}
91
89
  h
@@ -65,10 +65,10 @@ module Ayadn
65
65
  end
66
66
  abort(Status.canceled) unless STDIN.getch == ("y" || "Y")
67
67
  puts "\n#{Status.yourpost}"
68
- unless store.nil? || options[:no_url]
69
- visible, track, artwork, artwork_thumb, link, artist = true, store['track'], store['artwork'], store['artwork_thumb'], store['link'], store['artist']
70
- else
68
+ if store.nil? || options[:no_url]
71
69
  visible, track, artwork, artwork_thumb, link, artist = false
70
+ else
71
+ visible, track, artwork, artwork_thumb, link, artist = true, store['track'], store['artwork'], store['artwork_thumb'], store['link'], store['artist']
72
72
  end
73
73
  options = options.dup
74
74
  options[:nowplaying] = true
@@ -130,9 +130,35 @@ module Ayadn
130
130
 
131
131
  def get_itunes_store url, artist, track
132
132
  results = JSON.load(CNX.download(URI.escape(url)))['results']
133
+
133
134
  unless results.empty? || results.nil?
134
135
 
135
- resp = results.select {|obj| obj['artistName'] == artist && obj['trackName'] == track}
136
+ results.keep_if do |obj|
137
+ unless obj['artistName'].nil?
138
+ obj['artistName'].downcase == artist.downcase
139
+ end
140
+ end
141
+
142
+ if results.empty?
143
+ return {
144
+ 'code' => 404,
145
+ 'request' => url
146
+ }
147
+ end
148
+
149
+ if results.length > 1
150
+ resp = results.select {|obj| obj['trackName'].downcase == track.downcase}
151
+ else
152
+ resp = results
153
+ end
154
+
155
+ if resp.empty?
156
+ return {
157
+ 'code' => 404,
158
+ 'request' => url
159
+ }
160
+ end
161
+
136
162
  candidate = resp[0] || results[0]
137
163
 
138
164
  return {
data/lib/ayadn/scroll.rb CHANGED
@@ -93,6 +93,15 @@ module Ayadn
93
93
  stream = @api.get_messages(channel_id, options)
94
94
  Debug.stream stream, options, channel_id
95
95
  show_if_new(stream, options, "channel:#{channel_id}")
96
+ if Settings.options[:marker][:update_messages] == true
97
+ unless resp['meta']['max_id'].nil?
98
+ marked = @api.update_marker("channel:#{channel_id}", stream['meta']['max_id'])
99
+ updated = JSON.parse(marked)
100
+ if updated['meta']['code'] != 200
101
+ Errors.warn "couldn't update channel #{channel_id} as read"
102
+ end
103
+ end
104
+ end
96
105
  options = save_then_return(stream, options, "channel:#{channel_id}")
97
106
  countdown
98
107
  rescue Interrupt