rtunes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -0
  2. data/bin/rtunes +15 -0
  3. data/lib/rtunes.rb +66 -0
  4. metadata +57 -0
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,15 @@
1
+ #!/usr/local/bin/ruby -ws
2
+
3
+ require 'rtunes'
4
+
5
+ if (cmd = ARGV[0]).nil?
6
+ puts 'Must pass a command (e.g. play, pause)'
7
+ exit
8
+ end
9
+
10
+ unless (rt = Reltunes.new).respond_to?(cmd)
11
+ puts "Invalid command '#{cmd}'"
12
+ exit
13
+ end
14
+
15
+ ARGV[1].nil? ? rt.send(cmd) : rt.send(cmd, ARGV[1])
@@ -0,0 +1,66 @@
1
+ require 'rbosa'
2
+
3
+ class Reltunes
4
+ VERSION = '1.0.0'
5
+ attr_accessor :itunes
6
+
7
+ def initialize
8
+ @itunes = OSA.app('iTunes', :machine => '192.168.1.251', :username => 'john_doe', :password => 'secret')
9
+ end
10
+
11
+ def play; itunes.play; say("Tunes are playing"); end
12
+ def pause; itunes.pause; say("Tunes are paused"); end
13
+ def mute; itunes.mute = true; say("Tunes are muted"); end
14
+ def unmute; itunes.mute = false; say("Tunes are unmuted"); end
15
+
16
+ def current
17
+ say itunes.current_track.name
18
+ end
19
+
20
+ def next
21
+ itunes.next_track
22
+ say itunes.current_track.name
23
+ end
24
+
25
+ def back
26
+ itunes.back_track
27
+ say itunes.current_track.name
28
+ end
29
+
30
+ def volume
31
+ say itunes.sound_volume
32
+ end
33
+
34
+ def volume=(value)
35
+ itunes.sound_volume = value.to_i
36
+ say "Volume set to #{value}"
37
+ end
38
+
39
+ def sources
40
+ sources = itunes.sources
41
+ say sources.every(:name)
42
+ sources
43
+ end
44
+
45
+ def playlists(value="Library")
46
+ playlists = sources.detect { |e| e.name == value }.playlists
47
+ say playlists.every(:name)
48
+ playlists
49
+ end
50
+
51
+ def tracks(value="Music")
52
+ tracks = playlists.detect { |e| e.name == value }.tracks
53
+ say tracks.every(:name)
54
+ tracks
55
+ end
56
+
57
+ def search(value)
58
+ if (tracks = itunes.search(value)).any?
59
+ say tracks.every(:name)
60
+ else
61
+ say "Nothing found for '#{value}'"
62
+ end
63
+ end
64
+
65
+ alias :say :puts
66
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtunes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adeptware
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-03 00:00:00 -05:00
13
+ default_executable: rtunes
14
+ dependencies: []
15
+
16
+ description: Control iTunes remotely using Ruby OSA calls.
17
+ email: contact@adeptware.com
18
+ executables:
19
+ - rtunes
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - VERSION
26
+ - bin/rtunes
27
+ - lib/rtunes.rb
28
+ has_rdoc: true
29
+ homepage: http://github.com/adeptware/rtunes
30
+ licenses: []
31
+
32
+ post_install_message:
33
+ rdoc_options:
34
+ - --charset=UTF-8
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project:
52
+ rubygems_version: 1.3.5
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Control iTunes remotely using Ruby OSA calls.
56
+ test_files: []
57
+