shellify 1.1.0 → 1.1.1

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
  SHA256:
3
- metadata.gz: 314e6a4441fcb3d6f77285ac44ecd3a5d2d77f04fe015aaefea06ac489f75813
4
- data.tar.gz: 7cf9f6ac9154daab30f54797ada008e80cf5c29914fef6fdf91abf0bd392cc2b
3
+ metadata.gz: c748de7e87dfdb2e9567cac439dc39d3f5db091658150abebfe0e1ac3ce23ab7
4
+ data.tar.gz: 568c613808ae76d1ef896cf6b5c66bb6e46d87e9a1df0a44ff0dc4e569f4fc4c
5
5
  SHA512:
6
- metadata.gz: 8e2a4ad6c4bd8fb83a6e4c8f3af3feec80c05e4ac8e7075e6fb0b9dd09c4b12e97012b7deb8cc672553a2b581fc0d72adf40cb99beee21334f111dc9777c594f
7
- data.tar.gz: 4e44e84dc5dd2fdc9b305636f04a170bf99faf0d88a8a40c158656817ff8b9c28a5ec872eb7d7bed5711a4f8a0c9fab4efcb8bc5e94ba7a4b16000e2ee103eb7
6
+ metadata.gz: e271d469bb73af4ab35d10e405ea03f68d62014e4ed5bcc4fc715dee83683013ecc9e9187233d5876b73c23f672a8992625ee22f919c026fc7e48cda1a4936e5
7
+ data.tar.gz: a80d854ea294d1646136bbd92dbcd2b34bafb4fbd78d11a1e97d415d6fab0d7fb97a6388a375d0a2fca250d41f00bc64d6b84ee2d99a7bdae0f29b2a87b7108a
data/lib/shellify/cli.rb CHANGED
@@ -74,14 +74,16 @@ module Shellify
74
74
  command :like do |c|
75
75
  c.description = 'Save the current song to your library'
76
76
  c.action do
77
- @user.save_tracks!([@user.player.currently_playing])
77
+ exit_with_message(local_track_message, 0) if track_is_local?(playing)
78
+ @user.save_tracks!([playing])
78
79
  end
79
80
  end
80
81
 
81
82
  command :unlike do |c|
82
83
  c.description = 'Remove the current song from your library'
83
84
  c.action do
84
- @user.remove_tracks!([@user.player.currently_playing])
85
+ exit_with_message(local_track_message, 0) if track_is_local?(playing)
86
+ @user.remove_tracks!([playing])
85
87
  end
86
88
  end
87
89
 
@@ -99,10 +101,11 @@ module Shellify
99
101
  c.action do |args, options|
100
102
  return puts " Nothing playing" unless @user.player.playing?
101
103
 
104
+ exit_with_message(local_track_message, 0) if track_is_local?(playing)
102
105
  playlist = @user.playlists.find { |p| p.name == args[0] }
103
106
  return puts " Playlist not found" unless playlist
104
107
 
105
- playlist.add_tracks!([@user.player.currently_playing])
108
+ playlist.add_tracks!([playing])
106
109
  end
107
110
  end
108
111
 
@@ -111,10 +114,11 @@ module Shellify
111
114
  c.action do |args, options|
112
115
  return puts " Nothing playing" unless @user.player.playing?
113
116
 
117
+ exit_with_message(local_track_message, 0) if track_is_local?(playing)
114
118
  playlist = @user.playlists.find { |p| p.name == args[0] }
115
119
  return puts " Playlist not found" unless playlist
116
120
 
117
- playlist.remove_tracks!([@user.player.currently_playing])
121
+ playlist.remove_tracks!([playing])
118
122
  end
119
123
  end
120
124
 
@@ -176,12 +180,25 @@ module Shellify
176
180
 
177
181
  private
178
182
 
183
+ def playing
184
+ @user.player.currently_playing
185
+ end
186
+
187
+ def local_track_message
188
+ " Shellify can't perform this action for local tracks"
189
+ end
190
+
191
+ def track_is_local?(track)
192
+ track.uri.split(':')[1] == 'local'
193
+ end
194
+
179
195
  def print_current_song
180
- playing = @user.player.currently_playing
181
196
  puts ' Now Playing:'
182
197
  puts " #{playing.name} - #{playing.artists.first.name} - "\
183
198
  "#{duration_to_s(@user.player.progress)}/#{duration_to_s(playing.duration_ms)}"\
184
- "#{" - ♥" if @user.saved_tracks?([playing]).first}"
199
+ "#{" - ♥" if !track_is_local?(playing) && @user.saved_tracks?([playing]).first}"\
200
+ "#{" - local" if track_is_local?(playing)}"
201
+
185
202
  end
186
203
 
187
204
  def exit_with_message(message, code = 1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shellify
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Povah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-30 00:00:00.000000000 Z
11
+ date: 2022-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander