itunes-client 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -1
- data/README.md +20 -4
- data/lib/itunes/player.rb +1 -0
- data/lib/itunes/track.rb +10 -2
- data/lib/itunes/version.rb +1 -1
- data/lib/itunes/volume.rb +38 -0
- data/scripts/track/finder.tmpl.scpt +5 -1
- data/scripts/volume/down.scpt +5 -0
- data/scripts/volume/mute.scpt +3 -0
- data/scripts/volume/unmute.scpt +3 -0
- data/scripts/volume/up.scpt +5 -0
- data/scripts/volume/value.scpt +3 -0
- data/spec/itunes/volume_spec.rb +46 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f636c50e60a1601b8d1666384714bd4d2501e18
|
4
|
+
data.tar.gz: 680822064d023dca16d84a7a44563e15c8bebb24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f73dd601b66ad9ca14ab81f0c3a6cbf319f255b7765b98a020f1f21c116933caa08ba4a19e2fb761eecbe6aed7997d6920b0c7c8f0c8da9b97e348c76adb98e
|
7
|
+
data.tar.gz: f776209c942f08ee85ad7bf919dbf9767147c418a4c9e3d8853226d3c26b388574cd94a86cd7dffb8f2462c1ecca62cb6434ab0b3979590ffa3df6d4d33e9560
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -29,10 +29,10 @@ $ gem install itunes-client
|
|
29
29
|
|
30
30
|
|
31
31
|
## Supported Ruby
|
32
|
-
- 2.2
|
33
|
-
- 2.1
|
34
|
-
- 2.0
|
35
|
-
|
32
|
+
- 2.2
|
33
|
+
- 2.1
|
34
|
+
- 2.0
|
35
|
+
|
36
36
|
|
37
37
|
## Usage
|
38
38
|
|
@@ -57,6 +57,22 @@ track.play
|
|
57
57
|
|
58
58
|
# Stop track
|
59
59
|
track.stop
|
60
|
+
|
61
|
+
# Control volume
|
62
|
+
volume = Itunes::Volume
|
63
|
+
|
64
|
+
# Decrease and increase the volume
|
65
|
+
volume.down(20)
|
66
|
+
volume.down # default 10
|
67
|
+
volume.up(20)
|
68
|
+
volume.up # default 10
|
69
|
+
|
70
|
+
# Mute and unmute the volume
|
71
|
+
volume.mute
|
72
|
+
volume.unmute
|
73
|
+
|
74
|
+
# Return volume value
|
75
|
+
volume.value
|
60
76
|
```
|
61
77
|
|
62
78
|
## License
|
data/lib/itunes/player.rb
CHANGED
data/lib/itunes/track.rb
CHANGED
@@ -14,7 +14,11 @@ module Itunes
|
|
14
14
|
:artist,
|
15
15
|
:track_count,
|
16
16
|
:track_number,
|
17
|
-
:year
|
17
|
+
:year,
|
18
|
+
:season_number,
|
19
|
+
:episode_number,
|
20
|
+
:show,
|
21
|
+
:video_kind
|
18
22
|
].freeze
|
19
23
|
|
20
24
|
FINDER_ATTRIBUTES = [
|
@@ -120,7 +124,11 @@ module Itunes
|
|
120
124
|
records = []
|
121
125
|
args.each do |key, val|
|
122
126
|
if ATTRIBUTES.include?(key)
|
123
|
-
|
127
|
+
if key == :video_kind
|
128
|
+
records << "set video kind of specified_track to #{val}"
|
129
|
+
else
|
130
|
+
records << "set #{key.to_s.gsub('_', ' ')} of specified_track to \"#{val}\""
|
131
|
+
end
|
124
132
|
end
|
125
133
|
end
|
126
134
|
records.join("\n")
|
data/lib/itunes/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'itunes/util'
|
2
|
+
|
3
|
+
module Itunes
|
4
|
+
class Volume
|
5
|
+
extend Itunes::Util::Executor
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def up(level = 10)
|
9
|
+
execute_script("#{script_dir}/up.scpt", level)
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def down(level = 10)
|
14
|
+
execute_script("#{script_dir}/down.scpt", level)
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
def mute
|
19
|
+
execute_script("#{script_dir}/mute.scpt")
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def unmute
|
24
|
+
execute_script("#{script_dir}/unmute.scpt")
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def value
|
29
|
+
execute_script("#{script_dir}/value.scpt").to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def script_dir
|
34
|
+
'volume'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -12,7 +12,11 @@ tell application "iTunes"
|
|
12
12
|
set end of props to ("\"artist\":\"" & my escape_quote(artist of specified_track) & "\",")
|
13
13
|
set end of props to ("\"track_count\":\"" & track count of specified_track & "\",")
|
14
14
|
set end of props to ("\"track_number\":\"" & track number of specified_track & "\",")
|
15
|
-
set end of props to ("\"year\":\"" & year of specified_track & "\"")
|
15
|
+
set end of props to ("\"year\":\"" & year of specified_track & "\",")
|
16
|
+
set end of props to ("\"video_kind\":\"" & video kind of specified_track & "\",")
|
17
|
+
set end of props to ("\"show\":\"" & show of specified_track & "\",")
|
18
|
+
set end of props to ("\"season_number\":\"" & season number of specified_track & "\",")
|
19
|
+
set end of props to ("\"episode_number\":\"" & episode number of specified_track & "\"")
|
16
20
|
set end of props to "}"
|
17
21
|
|
18
22
|
set json to json & props as string & ","
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'itunes-client'
|
3
|
+
|
4
|
+
include Itunes
|
5
|
+
|
6
|
+
describe Volume do
|
7
|
+
let(:level) { an_instance_of(Fixnum) }
|
8
|
+
|
9
|
+
describe '.up' do
|
10
|
+
it 'calls up.scpt' do
|
11
|
+
expect(Volume).to receive(:execute_script).with('volume/up.scpt', level)
|
12
|
+
Volume.up
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.down' do
|
17
|
+
it 'calls down.scpt' do
|
18
|
+
expect(Volume).to receive(:execute_script).with('volume/down.scpt', level)
|
19
|
+
Volume.down
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.mute' do
|
24
|
+
it 'calls mute.scpt' do
|
25
|
+
expect(Volume).to receive(:execute_script).with('volume/mute.scpt')
|
26
|
+
Volume.mute
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.unmute' do
|
31
|
+
it 'calls unmute.scpt' do
|
32
|
+
expect(Volume).to receive(:execute_script).with('volume/unmute.scpt')
|
33
|
+
Volume.unmute
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.value' do
|
38
|
+
context 'when iTunes returns volume level' do
|
39
|
+
it 'returns current value' do
|
40
|
+
allow(Volume).to receive(:execute_script).with('volume/value.scpt').and_return("30")
|
41
|
+
expect(Volume.value).to eq(30)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryo katsuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/itunes/util.rb
|
175
175
|
- lib/itunes/util/executor.rb
|
176
176
|
- lib/itunes/version.rb
|
177
|
+
- lib/itunes/volume.rb
|
177
178
|
- scripts/player/add.scpt
|
178
179
|
- scripts/player/current_track.scpt
|
179
180
|
- scripts/player/next_track.scpt
|
@@ -189,9 +190,15 @@ files:
|
|
189
190
|
- scripts/track/finder.tmpl.scpt
|
190
191
|
- scripts/track/play.scpt
|
191
192
|
- scripts/track/updater.tmpl.scpt
|
193
|
+
- scripts/volume/down.scpt
|
194
|
+
- scripts/volume/mute.scpt
|
195
|
+
- scripts/volume/unmute.scpt
|
196
|
+
- scripts/volume/up.scpt
|
197
|
+
- scripts/volume/value.scpt
|
192
198
|
- spec/itunes/player_spec.rb
|
193
199
|
- spec/itunes/track_spec.rb
|
194
200
|
- spec/itunes/util/executor_spec.rb
|
201
|
+
- spec/itunes/volume_spec.rb
|
195
202
|
- spec/spec_helper.rb
|
196
203
|
homepage: https://github.com/katsuma/itunes-client
|
197
204
|
licenses:
|
@@ -222,4 +229,5 @@ test_files:
|
|
222
229
|
- spec/itunes/player_spec.rb
|
223
230
|
- spec/itunes/track_spec.rb
|
224
231
|
- spec/itunes/util/executor_spec.rb
|
232
|
+
- spec/itunes/volume_spec.rb
|
225
233
|
- spec/spec_helper.rb
|