aric 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -1
- data/lib/aric/command.rb +11 -8
- data/lib/aric/job/player.rb +12 -3
- data/lib/aric/job_handler.rb +9 -1
- data/lib/aric/resource/playlist.rb +1 -1
- data/lib/aric/resource/track.rb +1 -1
- data/lib/aric/script_runner.rb +1 -4
- data/lib/aric/version.rb +1 -1
- data/scripts/create_playlist.js +22 -0
- data/scripts/finder/find_loved_tracks.js +18 -13
- data/scripts/finder/find_track_by_id.js +15 -10
- data/scripts/finder/find_tracks.js +19 -13
- data/scripts/play_music.js +37 -0
- data/scripts/play_playlist.js +7 -0
- data/scripts/{play.js → play_track.js} +0 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38efb585c476f6e9486d2c1f81f4a0fc05f96d33
|
4
|
+
data.tar.gz: 00542d977dd68357eb3e8e8288373d774821c022
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f96564319f5ddd6eefc31541a3d0f0139fc44534b24fffb47d15407b29380c858fc124dec26fb6a452c3b22a95351a4f78a0dc1ae25848ac5961252529c2ed7
|
7
|
+
data.tar.gz: e201d72434d0828eb1d7a43b65f29ecfbc021f40be6512a87b1726be21427a41fb787ffaf9e171c9e7e4643f2702cb23dbe6030f8679ee680d7b590e01851ac8
|
data/README.md
CHANGED
@@ -5,6 +5,11 @@
|
|
5
5
|
|
6
6
|
Awesome Ruby Itunes Client
|
7
7
|
|
8
|
+
## Requirements
|
9
|
+
|
10
|
+
* OSX Yosemite or higher
|
11
|
+
* Ruby 2.2 or higher
|
12
|
+
|
8
13
|
## Installation
|
9
14
|
|
10
15
|
Add this line to your application's Gemfile:
|
@@ -23,7 +28,49 @@ Or install it yourself as:
|
|
23
28
|
|
24
29
|
## Usage
|
25
30
|
|
26
|
-
|
31
|
+
### Command Line
|
32
|
+
|
33
|
+
Show avalable jobs.
|
34
|
+
|
35
|
+
```sh
|
36
|
+
$ aric --list
|
37
|
+
```
|
38
|
+
|
39
|
+
Execute jobs as follow.
|
40
|
+
|
41
|
+
```sh
|
42
|
+
// play trakcs
|
43
|
+
$ aric play
|
44
|
+
|
45
|
+
// next tracks
|
46
|
+
$ aric next
|
47
|
+
|
48
|
+
// volume up by 10
|
49
|
+
$ aric up 10
|
50
|
+
|
51
|
+
// volume up by 10
|
52
|
+
$ aric up 10
|
53
|
+
|
54
|
+
// show tracks in current playlists
|
55
|
+
$ aric current_playlist_tracks
|
56
|
+
|
57
|
+
// set state to track love
|
58
|
+
$ aric love
|
59
|
+
|
60
|
+
// open iTunes
|
61
|
+
$ aric activate
|
62
|
+
```
|
63
|
+
|
64
|
+
Play founded tracks with `-p` option.
|
65
|
+
|
66
|
+
```sh
|
67
|
+
// play loved tracks
|
68
|
+
$ aric -p find_loved_tracks
|
69
|
+
|
70
|
+
// play found tracks
|
71
|
+
|
72
|
+
$ aric -p find_tracks <track_name>
|
73
|
+
```
|
27
74
|
|
28
75
|
## Development
|
29
76
|
|
data/lib/aric/command.rb
CHANGED
@@ -13,29 +13,31 @@ module Aric
|
|
13
13
|
case
|
14
14
|
when list?
|
15
15
|
puts JobHandler.jobs
|
16
|
+
when play?
|
17
|
+
JobHandler.play(*@args)
|
16
18
|
else
|
17
|
-
puts
|
19
|
+
puts JobHandler.new(job).run(*values)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
25
|
def values
|
24
|
-
@
|
26
|
+
@args.drop(1)
|
25
27
|
end
|
26
28
|
|
27
29
|
def job
|
28
|
-
@
|
29
|
-
end
|
30
|
-
|
31
|
-
def handler
|
32
|
-
@handler ||= JobHandler.new(job)
|
30
|
+
@args.first or raise JobNameRequired
|
33
31
|
end
|
34
32
|
|
35
33
|
def list?
|
36
34
|
options['list']
|
37
35
|
end
|
38
36
|
|
37
|
+
def play?
|
38
|
+
options['play']
|
39
|
+
end
|
40
|
+
|
39
41
|
def options
|
40
42
|
@options ||= option_parser.getopts(@argv)
|
41
43
|
end
|
@@ -47,7 +49,8 @@ module Aric
|
|
47
49
|
|
48
50
|
opt.separator 'Options:'
|
49
51
|
opt.on('-l', '--list', 'show available methods')
|
50
|
-
opt.on('-
|
52
|
+
opt.on('-p', '--play', 'play found tracks')
|
53
|
+
# opt.on('-d', 'demonize')
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
data/lib/aric/job/player.rb
CHANGED
@@ -3,10 +3,19 @@ require 'aric/job/base'
|
|
3
3
|
module Aric
|
4
4
|
module Job
|
5
5
|
class Player < Base
|
6
|
-
def
|
7
|
-
run(:
|
6
|
+
def play_music(*argv)
|
7
|
+
run(:play_music, argv)
|
8
|
+
end
|
9
|
+
|
10
|
+
def play_track(id = nil)
|
11
|
+
run(:play_track, id)
|
12
|
+
end
|
13
|
+
alias_method :play, :play_track
|
14
|
+
alias_method :start, :play_track
|
15
|
+
|
16
|
+
def play_playlist(id)
|
17
|
+
run(:play_playlist, id)
|
8
18
|
end
|
9
|
-
alias_method :start, :play
|
10
19
|
|
11
20
|
def pause
|
12
21
|
run(:pause)
|
data/lib/aric/job_handler.rb
CHANGED
@@ -5,6 +5,14 @@ module Aric
|
|
5
5
|
class JobNotFound < StandardError; end
|
6
6
|
|
7
7
|
class << self
|
8
|
+
def play(*args)
|
9
|
+
if args.first && jobs.include?(args.first.to_sym)
|
10
|
+
new(:play_music).run(*args)
|
11
|
+
else
|
12
|
+
raise JobNotFound
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
8
16
|
def jobs
|
9
17
|
@jobs ||= job_class_hash.values.flat_map(&:itself)
|
10
18
|
end
|
@@ -27,7 +35,7 @@ module Aric
|
|
27
35
|
end
|
28
36
|
|
29
37
|
def run(*args)
|
30
|
-
#
|
38
|
+
# Check argument number
|
31
39
|
job_class.run(@job_name, *args)
|
32
40
|
end
|
33
41
|
|
data/lib/aric/resource/track.rb
CHANGED
data/lib/aric/script_runner.rb
CHANGED
@@ -15,10 +15,7 @@ module Aric
|
|
15
15
|
def run(args = [])
|
16
16
|
args = Array(args).join(' ')
|
17
17
|
stdout, stderr, status = Open3.capture3("osascript -l JavaScript #{script_file_path} #{args}")
|
18
|
-
|
19
|
-
p stdout, stderr, status
|
20
|
-
puts '<============================================================ DEBUG OUTPUT CLOSE HERE', nil
|
21
|
-
raise stderr unless status.success?
|
18
|
+
raise "#{stderr} at osascript -l JavaScript #{script_file_path} #{args}" unless status.success?
|
22
19
|
stdout.strip
|
23
20
|
end
|
24
21
|
|
data/lib/aric/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
function run(argv) {
|
2
|
+
var app = Application("iTunes");
|
3
|
+
var plName = argv[0];
|
4
|
+
var pl = app.playlist[plName];
|
5
|
+
|
6
|
+
if (!pl) {
|
7
|
+
pl = new app.Playlist;
|
8
|
+
pl.make();
|
9
|
+
pl.name = plName;
|
10
|
+
}
|
11
|
+
|
12
|
+
argv.shift();
|
13
|
+
argv.forEach(function(id) {
|
14
|
+
var v = app.tracks().find(function(x){
|
15
|
+
return x.persistentID() == id;
|
16
|
+
});
|
17
|
+
|
18
|
+
if (v) {
|
19
|
+
v.duplicate({to: pl});
|
20
|
+
}
|
21
|
+
});
|
22
|
+
}
|
@@ -1,16 +1,21 @@
|
|
1
|
-
function run(argv) {
|
1
|
+
function run(argv, playMode) {
|
2
2
|
var app = Application("iTunes");
|
3
|
-
var tracks = app.tracks().filter(function(x){ return x.loved(); }).map(function(track){
|
4
|
-
return {
|
5
|
-
class: track.class(),
|
6
|
-
container: track.container(),
|
7
|
-
id: track.id(),
|
8
|
-
index: track.index(),
|
9
|
-
name: track.name(),
|
10
|
-
persistentID: track.persistentID(),
|
11
|
-
properties: track.properties()
|
12
|
-
};
|
13
|
-
});;
|
14
3
|
|
15
|
-
|
4
|
+
if (playMode === true) {
|
5
|
+
return app.tracks().filter(function(x){ return x.loved(); });
|
6
|
+
} else {
|
7
|
+
var tracks = app.tracks().filter(function(x){ return x.loved(); }).map(function(track){
|
8
|
+
return {
|
9
|
+
class: track.class(),
|
10
|
+
container: track.container(),
|
11
|
+
id: track.id(),
|
12
|
+
index: track.index(),
|
13
|
+
name: track.name(),
|
14
|
+
persistentID: track.persistentID(),
|
15
|
+
properties: track.properties()
|
16
|
+
};
|
17
|
+
});;
|
18
|
+
|
19
|
+
return JSON.stringify(tracks);
|
20
|
+
}
|
16
21
|
}
|
@@ -1,16 +1,21 @@
|
|
1
|
-
function run(argv) {
|
1
|
+
function run(argv, playMode) {
|
2
2
|
var app = Application("iTunes");
|
3
|
+
|
3
4
|
var track = app.tracks().find(function(x){
|
4
5
|
return x.persistentID() == argv[0];
|
5
6
|
});
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
if (playMode == true) {
|
9
|
+
return track;
|
10
|
+
} else {
|
11
|
+
return JSON.stringify({
|
12
|
+
class: track.class(),
|
13
|
+
container: track.container(),
|
14
|
+
id: track.id(),
|
15
|
+
index: track.index(),
|
16
|
+
name: track.name(),
|
17
|
+
persistentID: track.persistentID(),
|
18
|
+
properties: track.properties()
|
19
|
+
});
|
20
|
+
}
|
16
21
|
}
|
@@ -1,18 +1,24 @@
|
|
1
|
-
function run(argv) {
|
1
|
+
function run(argv, playMode) {
|
2
2
|
var app = Application("iTunes");
|
3
3
|
var pl = app.playlists().find(function(x){
|
4
4
|
return x.name() == "ミュージック" || x.name() == "Music";
|
5
5
|
});
|
6
|
-
var tracks = app.search(pl, {for: argv[0]})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
var tracks = app.search(pl, {for: argv[0]});
|
7
|
+
|
8
|
+
if (playMode === true) {
|
9
|
+
return tracks;
|
10
|
+
} else {
|
11
|
+
var t = tracks.map(function(track){
|
12
|
+
return {
|
13
|
+
class: track.class(),
|
14
|
+
container: track.container(),
|
15
|
+
id: track.id(),
|
16
|
+
index: track.index(),
|
17
|
+
name: track.name(),
|
18
|
+
persistentID: track.persistentID(),
|
19
|
+
properties: track.properties()
|
20
|
+
};
|
21
|
+
});
|
22
|
+
return JSON.stringify(t);
|
23
|
+
}
|
18
24
|
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
function run(argv) {
|
2
|
+
var app = Application("iTunes");
|
3
|
+
var ret = loadAndEval(argv);
|
4
|
+
var pl = createPlayList(app, "_aric_tmp");
|
5
|
+
|
6
|
+
ret.forEach(function (x) {
|
7
|
+
x.duplicate({to: pl});
|
8
|
+
});
|
9
|
+
|
10
|
+
app.play(pl);
|
11
|
+
}
|
12
|
+
|
13
|
+
function createPlayList(app, name) {
|
14
|
+
var pl = app.playlists().find(function (x) { return x.name() === name; });
|
15
|
+
console.log(pl);
|
16
|
+
|
17
|
+
if (pl) {
|
18
|
+
pl.delete(); // to overwrite
|
19
|
+
}
|
20
|
+
|
21
|
+
pl = new app.Playlist;
|
22
|
+
pl.make();
|
23
|
+
pl.name = name;
|
24
|
+
return pl;
|
25
|
+
}
|
26
|
+
|
27
|
+
function loadAndEval(argv) {
|
28
|
+
ObjC.import('Foundation');
|
29
|
+
|
30
|
+
var path = 'scripts/finder/' + argv[0] + '.js';
|
31
|
+
var fm = $.NSFileManager.defaultManager;
|
32
|
+
var contents = fm.contentsAtPath(path.toString());
|
33
|
+
contents = $.NSString.alloc.initWithDataEncoding(contents, $.NSUTF8StringEncoding);
|
34
|
+
|
35
|
+
eval(ObjC.unwrap(contents));
|
36
|
+
return run([argv[1]], true);
|
37
|
+
}
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ganmacs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/aric/version.rb
|
104
104
|
- scripts/activate.js
|
105
105
|
- scripts/back_track.js
|
106
|
+
- scripts/create_playlist.js
|
106
107
|
- scripts/current_playlist.js
|
107
108
|
- scripts/current_playlist_tracks.js
|
108
109
|
- scripts/current_track.js
|
@@ -122,7 +123,9 @@ files:
|
|
122
123
|
- scripts/mute.js
|
123
124
|
- scripts/next_track.js
|
124
125
|
- scripts/pause.js
|
125
|
-
- scripts/
|
126
|
+
- scripts/play_music.js
|
127
|
+
- scripts/play_playlist.js
|
128
|
+
- scripts/play_track.js
|
126
129
|
- scripts/player_position.js
|
127
130
|
- scripts/player_state.js
|
128
131
|
- scripts/previous_track.js
|
@@ -151,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
154
|
version: '0'
|
152
155
|
requirements: []
|
153
156
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.4.5
|
157
|
+
rubygems_version: 2.4.5
|
155
158
|
signing_key:
|
156
159
|
specification_version: 4
|
157
160
|
summary: Awesome Ruby Ituens Client
|