spotify_osx_controller 0.1.5 → 1.0.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: 89bb1950ecc832c36ca545debbf835d377107ead
4
- data.tar.gz: 5d524d64520316e907f751a2d0645bbd9a6d7ade
3
+ metadata.gz: 3a0952ea1a29701c386ce144c4f5913a9eccb455
4
+ data.tar.gz: 4ab0338761fd7482aa23f06ebf371a4ed82e0ac4
5
5
  SHA512:
6
- metadata.gz: 3c12423d950ceed93b214ee995c0ab1ee2d79523ba3bb8e52da59f0a05e8771af6b3cdf3a349148df32ff3b2c2667751927d7ef71b0ae6063dbafa493035efb3
7
- data.tar.gz: 95f359599e19118973a569f737437b14592e749d81082a95c41f4d8963764668ac9ca612af46a96d9bbe73a697ea5391eaba8a4604f005e9ac33fac76ac89a59
6
+ metadata.gz: aa3f2947d98531495e70eee3c2cbd7e3c903c0b381ea38f92a4dd148788840a67b95e4d511c21e0647209f96bdb0f3c99b82959d97f834beb5686e7474861db0
7
+ data.tar.gz: f7d8a6ae7668bf2a9b5e6ae0f89570231c0d4986ca221aa804c6691820cd77303e1f40c104738b7181822b8d3a7def19735b873d5027e24c8bba54b9c56c1b36
data/README.md CHANGED
@@ -4,6 +4,24 @@ CLI for Spotify running on OSX
4
4
 
5
5
  Apple script forked from: [dronir/SpotifyControl](https://github.com/dronir/SpotifyControl)
6
6
 
7
+ ## Command-line options
8
+
9
+ ```
10
+ -p, --play <s>: Start playback of the given track, where <s> is the spotify URI
11
+ -P, --play-pause: Play/pause playback
12
+ -s, --stop: Stop playback
13
+ -n, --next: Play next track
14
+ -N, --previous: Play previous track
15
+ -j, --jump <i>: Jump to position given position of the current track, where <i> is track position in
16
+ seconds
17
+ -f, --forward <i>: Jump <i> number of seconds ahead
18
+ -r, --rewind <i>: Rewind <i> number of seconds backwards
19
+ -v, --volume <i>: Set playback volume to <i>, where <i> is number between 0 and 100
20
+ -S, --shuffle: Toggle shuffle
21
+ -R, --repeat: Toggle repeat
22
+ -i, --info: Display information about the current track
23
+ ```
24
+
7
25
  ## Installation
8
26
 
9
27
  Add this line to your application's Gemfile:
@@ -1,34 +1,58 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "spotify_osx_controller"
3
+ require "trollop"
3
4
 
4
- command = ARGV[0]
5
- arg1 = ARGV[1]
6
- case command.downcase
7
- when 'play', 'start'
8
- SpotifyOsxController.play arg1
9
- when 'play/pause'
10
- SpotifyOsxController.play_pause
11
- when 'pause', 'stop'
12
- SpotifyOsxController.pause
13
- when 'next'
14
- SpotifyOsxController.next
15
- when 'previous'
16
- SpotifyOsxController.previous
17
- when 'jump'
18
- SpotifyOsxController.jump arg1
19
- when 'forward'
20
- SpotifyOsxController.forward arg1
21
- when 'rewind'
22
- SpotifyOsxController.rewind arg1
23
- when 'volume'
24
- SpotifyOsxController.volume arg1
25
- when 'shuffle'
26
- SpotifyOsxController.shuffle
27
- when 'repeat'
28
- SpotifyOsxController.repeat
29
- when 'info'
30
- SpotifyOsxController.info
31
- exit
5
+
6
+ opts = Trollop::options do
7
+ banner <<-EOS
8
+ OSX CLI for Spotify
9
+
10
+ Usage:
11
+ spotify_osx_controller [command]
12
+
13
+ Where [command] is one of the following:
14
+
15
+ EOS
16
+ opt :play, 'Start playback of the given track, where <s> is the spotify URI', type: :string, short: 'p', default: nil
17
+ opt :play_pause, 'Play/pause playback', type: :boolean, short: 'P'
18
+ opt :stop, 'Stop playback'
19
+ opt :next, 'Play next track'
20
+ opt :previous, 'Play previous track', short: 'N'
21
+ opt :jump, 'Jump to position given position of the current track, where <i> is track position in seconds', type: :integer
22
+ opt :forward, 'Jump <i> number of seconds ahead', type: :integer
23
+ opt :rewind, 'Rewind <i> number of seconds backwards', type: :integer
24
+ opt :volume, 'Set playback volume to <i>, where <i> is number between 0 and 100', type: :integer
25
+ opt :shuffle, 'Toggle shuffle', type: :boolean, short: 'S'
26
+ opt :repeat, 'Toggle repeat', type: :boolean, short: 'R'
27
+ opt :info, 'Display information about the current track'
28
+ conflicts :play, :play_pause, :next, :previous, :jump, :forward, :rewind, :volume, :shuffle, :repeat, :info
32
29
  end
33
30
 
34
- SpotifyOsxController.info
31
+
32
+
33
+ if opts[:play]
34
+ SpotifyOsxController.play opts[:play]
35
+ elsif opts[:play_pause]
36
+ SpotifyOsxController.play_pause
37
+ elsif opts[:stop]
38
+ SpotifyOsxController.pause
39
+ elsif opts[:next]
40
+ SpotifyOsxController.next
41
+ elsif opts[:previous]
42
+ SpotifyOsxController.previous
43
+ elsif opts[:jump]
44
+ SpotifyOsxController.jump opts[:jump]
45
+ elsif opts[:forward]
46
+ SpotifyOsxController.forward opts[:forward]
47
+ elsif opts[:rewind]
48
+ SpotifyOsxController.rewind opts[:rewind]
49
+ elsif opts[:volume]
50
+ Trollop::die :volume, "must be between 0 and 100" if opts[:volume] < 0 or opts[:volume] > 100
51
+ SpotifyOsxController.volume opts[:volume]
52
+ elsif opts[:shuffle]
53
+ SpotifyOsxController.shuffle
54
+ elsif opts[:repeat]
55
+ SpotifyOsxController.repeat
56
+ elsif opts[:info]
57
+ SpotifyOsxController.info
58
+ end
@@ -1,3 +1,3 @@
1
1
  module SpotifyOsxController
2
- VERSION = "0.1.5"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -126,7 +126,37 @@ module SpotifyOsxController
126
126
  END
127
127
  end
128
128
 
129
- def self.info
129
+
130
+ def self.info
131
+ buildScript String <<-END
132
+ set info to "Error."
133
+ tell application "Spotify"
134
+ set myTrack to name of current track
135
+ set myArtist to artist of current track
136
+ set myAlbum to album of current track
137
+ set tM to round ((duration of current track / 1000) / 60) rounding down
138
+ set tS to round ((duration of current track / 1000) mod 60) rounding down
139
+ set myTime to tM as text & "min " & tS as text & "s"
140
+ set nM to round (player position / 60) rounding down
141
+ set nS to round (player position mod 60) rounding down
142
+ set nowAt to nM as text & "min " & nS as text & "s"
143
+ set info to "Current track:"
144
+ set info to info & "\n Artist: " & myArtist
145
+ set info to info & "\n Track: " & myTrack
146
+ set info to info & "\n Album: " & myAlbum
147
+ set info to info & "\n URI: " & spotify url of current track
148
+ set info to info & "\n Duration: " & mytime & " ("& (round ((duration of current track / 1000)) rounding down) & " seconds)"
149
+ set info to info & "\n Now at: " & nowAt
150
+ set info to info & "\n Player: " & player state
151
+ set info to info & "\n Volume: " & sound volume
152
+ if shuffling then set info to info & "\n Shuffle is on."
153
+ if repeating then set info to info & "\n Repeat is on."
154
+ end tell
155
+ return info
156
+ END
157
+ end
158
+
159
+ def self.info_json
130
160
  buildScript String <<-END
131
161
  set info to "Error."
132
162
  tell application "Spotify"
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
-
25
+ spec.add_dependency "trollop"
26
26
  spec.add_development_dependency "bundler", "~> 1.9"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
+
28
29
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify_osx_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Swensson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: trollop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,8 +58,6 @@ description: |2
44
58
  email:
45
59
  - daniel@danielswensson.se
46
60
  executables:
47
- - console
48
- - setup
49
61
  - spotify_osx_controller
50
62
  extensions: []
51
63
  extra_rdoc_files: []
@@ -54,8 +66,6 @@ files:
54
66
  - Gemfile
55
67
  - README.md
56
68
  - Rakefile
57
- - bin/console
58
- - bin/setup
59
69
  - bin/spotify_osx_controller
60
70
  - lib/spotify_osx_controller.rb
61
71
  - lib/spotify_osx_controller/version.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "spotify_osx_controller"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here