spotify_osx_controller 0.1.1 → 0.1.2

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: 5b32ccb34db51d624be9e88475bddd73de2b2828
4
- data.tar.gz: eeccdb9b9ec4f00192687af0f23113cd838d543a
3
+ metadata.gz: 67fcb17ea1040a5fbd1c0d1d9dc429d51d540fc8
4
+ data.tar.gz: 06bdda14f3c34bd949e1f5a4d86dfc573607a093
5
5
  SHA512:
6
- metadata.gz: cc4648e297f4b1debbd3e31f6cf8c9c140cb67c562d2c4e8ecedd56242adbe76e11c4879a8e68df5aee5b5183c888477de3906e7b9ce949550f4398da0003799
7
- data.tar.gz: f0f61b1b383c5afc8bb4721de53cb49f95d230489d718d0d4b19b0bdcdaaa62bce852f30a0830f4b3a2a7174c9c9aaedc7dfcecabff719565fde40aabc837574
6
+ metadata.gz: dddca84e7fe1e59972427c0e2221b29497e9e05c6eb7883ccf4f0f04fc2317c38b1559c010db2b1955426c74ea5447cd2a8d5707de3c96f7675ddbb159075d8a
7
+ data.tar.gz: b4f770a239ffcfba5ae8c2bbab315446f7a7728fdb31b863592913ed0f055d74f1612bb97b12c4fc55d11e901ae8c30bfdd5a99c83bc0e537373e10de21f5f94
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # SpotifyOsxController
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/spotify_osx_controller`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ CLI for Spotify running on OSX
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,15 +18,6 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install spotify_osx_controller
22
20
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
21
 
33
22
  ## Contributing
34
23
 
@@ -1,3 +1,3 @@
1
1
  module SpotifyOsxController
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "spotify_osx_controller"
8
8
  spec.version = SpotifyOsxController::VERSION
9
9
  spec.authors = ["Daniel Swensson"]
10
- spec.email = ["danielswensson@hotmail.com"]
10
+ spec.email = ["daniel@danielswensson.se"]
11
11
  spec.licenses = ['MIT']
12
12
 
13
13
  spec.summary = %q{Ruby wrapper for Spotify applescript API}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotify_osx_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Swensson
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: '10.0'
41
41
  description: Control Spotify running on a Mac
42
42
  email:
43
- - danielswensson@hotmail.com
43
+ - daniel@danielswensson.se
44
44
  executables:
45
45
  - console
46
46
  - setup
@@ -48,19 +48,15 @@ executables:
48
48
  extensions: []
49
49
  extra_rdoc_files: []
50
50
  files:
51
- - ".DS_Store"
52
51
  - ".gitignore"
53
52
  - Gemfile
54
53
  - README.md
55
54
  - Rakefile
56
- - SpotifyControl.rb
57
- - SpotifyControl.scpt
58
55
  - bin/console
59
56
  - bin/setup
60
57
  - bin/spotify_osx_controller
61
58
  - lib/spotify_osx_controller.rb
62
59
  - lib/spotify_osx_controller/version.rb
63
- - spotify_osx_controller-0.1.0.gem
64
60
  - spotify_osx_controller.gemspec
65
61
  homepage: https://github.com/DanielSwensson/SpotifyControl
66
62
  licenses:
data/.DS_Store DELETED
Binary file
data/SpotifyControl.rb DELETED
@@ -1,200 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- class Command
4
-
5
- def self.play(url)
6
- if url
7
- buildScript "tell application \"Spotify\" to play track \"#{url}\"\n"
8
- else
9
- buildScript "tell application \"Spotify\" to play\n"
10
- end
11
- end
12
-
13
- def self.play_pause
14
- buildScript String <<-END
15
- tell application "Spotify" to playpause
16
- END
17
- end
18
-
19
- def self.pause
20
- buildScript "tell application \"Spotify\" to pause"
21
- end
22
-
23
- def self.next
24
- buildScript "tell application \"Spotify\" to next track"
25
- end
26
-
27
- def self.previous
28
- buildScript "tell application \"Spotify\" to previous track"
29
- end
30
-
31
- def self.jump seconds
32
- return if !seconds
33
- buildScript String <<-END
34
- tell application "Spotify"
35
- set jumpTo to #{seconds} as real
36
- set tMax to duration of current track
37
- if jumpTo > tMax
38
- return "Can't jump past end of track."
39
- else if jumpTo < 0
40
- return "Can't jump past start of track."
41
- end if
42
- set nM to round (jumpTo / 60) rounding down
43
- set nS to round (jumpTo mod 60) rounding down
44
- set newTime to nM as text & "min " & nS as text & "s"
45
- set player position to jumpTo
46
- return "Jumped to " & newTime
47
- end tell
48
- END
49
- end
50
-
51
- def self.forward seconds
52
- return if !seconds
53
- buildScript String <<-END
54
- set jump to #{seconds} as real
55
- tell application "Spotify"
56
- set now to player position
57
- set tMax to duration of current track
58
- set jumpTo to now + jump
59
- if jumpTo > tMax
60
- return "Can't jump past end of track."
61
- else if jumpTo < 0
62
- set jumpTo to 0
63
- end if
64
- set nM to round (jumpTo / 60) rounding down
65
- set nS to round (jumpTo mod 60) rounding down
66
- set newTime to nM as text & "min " & nS as text & "s"
67
- set player position to jumpTo
68
- return "Jumped to " & newTime
69
- end tell
70
- END
71
- end
72
-
73
- def self.rewind seconds
74
- return if !seconds
75
- buildScript String <<-END
76
- set jump to #{seconds} as real
77
- tell application "Spotify"
78
- set now to player position
79
- set tMax to duration of current track
80
- set jumpTo to now - jump
81
- if jumpTo > tMax
82
- return "Can't jump past end of track."
83
- else if jumpTo < 0
84
- set jumpTo to 0
85
- end if
86
- set nM to round (jumpTo / 60) rounding down
87
- set nS to round (jumpTo mod 60) rounding down
88
- set newTime to nM as text & "min " & nS as text & "s"
89
- set player position to jumpTo
90
- return "Jumped to " & newTime
91
- end tell
92
- END
93
- end
94
-
95
- def self.volume volume
96
- return if !volume
97
- buildScript String <<-END
98
- set newVolume to #{volume} as real
99
- if newVolume < 0 then set newVolume to 0
100
- if newVolume > 100 then set newVolume to 100
101
- tell application "Spotify"
102
- set sound volume to newVolume
103
- end tell
104
- return "Changed volume to " & newVolume
105
- END
106
- end
107
-
108
- def self.shuffle
109
- buildScript String <<-END
110
- tell application "Spotify"
111
- set shuffling to not shuffling
112
- return "Shuffle is now " & shuffling
113
- end tell
114
- END
115
- end
116
-
117
- def self.repeat
118
- buildScript String <<-END
119
- tell application "Spotify"
120
- set repeating to not repeating
121
- return "Repeat is now " & repeating
122
- end tell
123
- END
124
- end
125
-
126
- def self.info
127
- buildScript String <<-END
128
- set info to "Error."
129
- tell application "Spotify"
130
- set myTrack to name of current track
131
- set myArtist to artist of current track
132
- set myAlbum to album of current track
133
- set tM to round (duration of current track / 60) rounding down
134
- set tS to duration of current track mod 60
135
- set myTime to tM as text & "min " & tS as text & "s"
136
- set nM to round (player position / 60) rounding down
137
- set nS to round (player position mod 60) rounding down
138
- set nowAt to player position
139
- set info to "{"
140
- set info to info & "\\"artist\\": \\"" & myArtist & "\\","
141
- set info to info & "\\"track\\": \\"" & myTrack & "\\","
142
- set info to info & "\\"album\\": \\"" & myAlbum & "\\","
143
- set info to info & "\\"URI\\": \\"" & spotify url of current track & "\\","
144
- set info to info & "\\"duration\\": \\"" & duration of current track & "\\","
145
- set info to info & "\\"player\\": \\"" & player state & "\\","
146
- set info to info & "\\"position\\": \\"" & nowAt & "\\""
147
- set info to info & "}"
148
- end tell
149
- return info
150
- END
151
- end
152
-
153
- private
154
-
155
- def self.buildScript(body)
156
- header = "using terms from application \"Spotify\""
157
- footer = "end using terms from"
158
- osascript <<-END
159
- #{header}
160
- #{body}
161
- #{footer}
162
- END
163
- end
164
-
165
- def self.osascript(script)
166
- system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
167
- end
168
- end
169
-
170
- command = ARGV[0]
171
- arg1 = ARGV[1]
172
- case command.downcase
173
- when 'play', 'start'
174
- Command.play arg1
175
- when 'play/pause'
176
- Command.play_pause
177
- when 'pause', 'stop'
178
- Command.pause
179
- when 'next'
180
- Command.next
181
- when 'previous'
182
- Command.previous
183
- when 'jump'
184
- Command.jump arg1
185
- when 'forward'
186
- Command.forward arg1
187
- when 'rewind'
188
- Command.rewind arg1
189
- when 'volume'
190
- Command.volume arg1
191
- when 'shuffle'
192
- Command.shuffle
193
- when 'repeat'
194
- Command.repeat
195
- when 'info'
196
- Command.info
197
- exit
198
- end
199
-
200
- Command.info
data/SpotifyControl.scpt DELETED
@@ -1,157 +0,0 @@
1
- on run argv
2
- if count of argv is equal to 0 then
3
- set msg to "Use the following commands:\n"
4
- set msg to msg & " start, play [uri] - Start playback / play uri\n"
5
- set msg to msg & " pause, stop - Stop playback\n"
6
- set msg to msg & " play/pause - Toggle playback\n"
7
- set msg to msg & " next - Next track\n"
8
- set msg to msg & " previous, prev - Previous track\n"
9
- set msg to msg & " info - Print track info\n"
10
- set msg to msg & " jump N - Jump to N seconds in the song\n"
11
- set msg to msg & " forward N - Jump N seconds forwards\n"
12
- set msg to msg & " rewind N - Jump N seconds backwards\n"
13
- set msg to msg & " shuffle - Toggle shuffle\n"
14
- set msg to msg & " repeat - Toggle repeat\n"
15
- set msg to msg & " volume N - Set Volume to N (0...100)\n"
16
- return msg
17
- end if
18
- set command to item 1 of argv
19
- using terms from application "Spotify"
20
- set info to "Error."
21
- if command is equal to "play" or command is equal to "start" then
22
- if count of argv is equal to 1 then
23
- tell application "Spotify" to play
24
- else
25
- set uri to item 2 of argv
26
- tell application "Spotify" to play track uri
27
- end if
28
- else if command is equal to "play/pause" then
29
- tell application "Spotify" to playpause
30
- return "Toggled."
31
-
32
- else if command is equal to "pause" or command is equal to "stop" then
33
- tell application "Spotify" to pause
34
- return "Paused."
35
-
36
- else if command is equal to "next" then
37
- tell application "Spotify" to next track
38
-
39
- else if command is equal to "previous" or command is equal to "prev" then
40
- tell application "Spotify" to previous track
41
-
42
- else if command is equal to "jump"
43
- set jumpTo to item 2 of argv as real
44
- tell application "Spotify"
45
- set tMax to duration of current track
46
- if jumpTo > tMax
47
- return "Can't jump past end of track."
48
- else if jumpTo < 0
49
- return "Can't jump past start of track."
50
- end if
51
- set nM to round (jumpTo / 60) rounding down
52
- set nS to round (jumpTo mod 60) rounding down
53
- set newTime to nM as text & "min " & nS as text & "s"
54
- set player position to jumpTo
55
- return "Jumped to " & newTime
56
- end tell
57
-
58
- else if command is equal to "forward"
59
- set jump to item 2 of argv as real
60
- tell application "Spotify"
61
- set now to player position
62
- set tMax to duration of current track
63
- set jumpTo to now + jump
64
- if jumpTo > tMax
65
- return "Can't jump past end of track."
66
- else if jumpTo < 0
67
- set jumpTo to 0
68
- end if
69
- set nM to round (jumpTo / 60) rounding down
70
- set nS to round (jumpTo mod 60) rounding down
71
- set newTime to nM as text & "min " & nS as text & "s"
72
- set player position to jumpTo
73
- return "Jumped to " & newTime
74
- end tell
75
-
76
- else if command is equal to "rewind"
77
- set jump to item 2 of argv as real
78
- tell application "Spotify"
79
- set now to player position
80
- set tMax to duration of current track
81
- set jumpTo to now - jump
82
- if jumpTo > tMax
83
- return "Can't jump past end of track."
84
- else if jumpTo < 0
85
- set jumpTo to 0
86
- end if
87
- set nM to round (jumpTo / 60) rounding down
88
- set nS to round (jumpTo mod 60) rounding down
89
- set newTime to nM as text & "min " & nS as text & "s"
90
- set player position to jumpTo
91
- return "Jumped to " & newTime
92
- end tell
93
-
94
- else if command is equal to "volume" then
95
- set newVolume to item 2 of argv as real
96
- if newVolume < 0 then set newVolume to 0
97
- if newVolume > 100 then set newVolume to 100
98
- tell application "Spotify"
99
- set sound volume to newVolume
100
- end tell
101
- return "Changed volume to " & newVolume
102
-
103
- else if command is equal to "shuffle" then
104
- tell application "Spotify"
105
- set shuffling to not shuffling
106
- return "Shuffle is now " & shuffling
107
- end tell
108
-
109
- else if command is equal to "repeat" then
110
- tell application "Spotify"
111
- set repeating to not repeating
112
- return "Repeat is now " & repeating
113
- end tell
114
-
115
- else if command is equal to "info" then
116
- my getInfo()
117
- end if
118
-
119
- tell application "Spotify"
120
- if player state as text is equal to "playing"
121
- my getInfo()
122
- end if
123
- end tell
124
-
125
-
126
- end using terms from
127
- end run
128
-
129
-
130
- on getInfo()
131
- set info to "Error."
132
- tell application "Spotify"
133
- set myTrack to name of current track
134
- set myArtist to artist of current track
135
- set myAlbum to album of current track
136
- set tM to round (duration of current track / 60) rounding down
137
- set tS to duration of current track mod 60
138
- set myTime to tM as text & "min " & tS as text & "s"
139
- set nM to round (player position / 60) rounding down
140
- set nS to round (player position mod 60) rounding down
141
- set nowAt to player position
142
- set info to "{"
143
- set info to info & "\n \"artist\": \"" & myArtist & "\","
144
- set info to info & "\n \"track\": \"" & myTrack & "\","
145
- set info to info & "\n \"album\": \"" & myAlbum & "\","
146
- set info to info & "\n \"URI\": \"" & spotify url of current track & "\","
147
- set info to info & "\n \"duration\": \"" & mytime & " ("& duration of current track & " seconds)" & "\","
148
- set info to info & "\n \"player\": \"" & player state & "\""
149
- set info to info & "\n \"position\": \"" & nowAt & "\"\n"
150
- set info to info & "}"
151
- end tell
152
- return info
153
- end getInfo
154
-
155
-
156
-
157
-
Binary file