anyplayer 1.1.1 → 1.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.
@@ -1,61 +1,67 @@
1
1
  class Anyplayer::Amarok < Anyplayer::Player
2
2
  def playpause
3
- amarok 'PlayPause'
3
+ amarok "PlayPause"
4
4
  end
5
5
 
6
6
  def play
7
- amarok 'Play'
7
+ amarok "Play"
8
8
  end
9
9
 
10
10
  def pause
11
- amarok 'Pause'
11
+ amarok "Pause"
12
12
  end
13
13
 
14
14
  def prev
15
- amarok 'Prev'
15
+ amarok "Prev"
16
16
  super
17
17
  end
18
18
 
19
19
  def next
20
- amarok 'Next'
20
+ amarok "Next"
21
21
  super
22
22
  end
23
23
 
24
24
  def voldown
25
- amarok 'VolumeDown 5'
25
+ amarok "VolumeDown 5"
26
26
  end
27
27
 
28
28
  def volup
29
- amarok 'VolumeUp 5'
29
+ amarok "VolumeUp 5"
30
30
  end
31
31
 
32
32
  def volume
33
- amarok 'VolumeGet'
33
+ amarok "VolumeGet"
34
34
  end
35
35
 
36
36
  def track
37
- amarok_get_meta 'title'
37
+ amarok_get_meta "title"
38
38
  end
39
39
 
40
40
  def artist
41
- amarok_get_meta 'artist'
41
+ amarok_get_meta "artist"
42
42
  end
43
43
 
44
44
  def album
45
- amarok_get_meta 'album'
45
+ amarok_get_meta "album"
46
46
  end
47
47
 
48
48
  def launched?
49
- not %x(qdbus org.kde.amarok 2>&1).match(/does not exist|command not found/)
49
+ not %x(qdbus org.kde.amarok 2>&1).match(
50
+ /does not exist|not found|cannot find the path specified/
51
+ )
52
+ end
53
+
54
+ def platforms
55
+ [:unix, :linux]
50
56
  end
51
57
 
52
58
  private
53
- def amarok(command)
54
- %x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
55
- end
56
59
 
57
- def amarok_get_meta(name)
58
- amarok('GetMetadata').match(/#{name}: (\S.*)/)[1] rescue nil
59
- end
60
- end
60
+ def amarok(command)
61
+ %x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
62
+ end
61
63
 
64
+ def amarok_get_meta(name)
65
+ amarok("GetMetadata").match(/#{name}: (\S.*)/)[1] rescue nil
66
+ end
67
+ end
@@ -1,66 +1,71 @@
1
1
  class Anyplayer::ItunesMac < Anyplayer::Player
2
2
  def play
3
- itunes 'play'
3
+ itunes "play"
4
4
  end
5
5
 
6
6
  def pause
7
- itunes 'pause'
7
+ itunes "pause"
8
8
  end
9
9
 
10
10
  def playpause
11
- itunes 'playpause'
11
+ itunes "playpause"
12
12
  end
13
13
 
14
14
  def prev
15
- itunes 'previous track'
15
+ itunes "previous track"
16
16
  super
17
17
  end
18
18
 
19
19
  def next
20
- itunes 'next track'
20
+ itunes "next track"
21
21
  super
22
22
  end
23
23
 
24
24
  def voldown
25
- itunes 'set sound volume to sound volume - 10'
25
+ itunes "set sound volume to sound volume - 10"
26
26
  end
27
27
 
28
28
  def volup
29
- itunes 'set sound volume to sound volume + 10'
29
+ itunes "set sound volume to sound volume + 10"
30
30
  end
31
31
 
32
32
  def volume
33
- itunes 'return sound volume'
33
+ itunes "return sound volume"
34
34
  end
35
35
 
36
36
  def track
37
- itunes 'return name of current track'
37
+ itunes "return name of current track"
38
38
  end
39
39
 
40
40
  def artist
41
- itunes 'return artist of current track'
41
+ itunes "return artist of current track"
42
42
  end
43
43
 
44
44
  def album
45
- itunes 'return album of current track'
45
+ itunes "return album of current track"
46
46
  end
47
47
 
48
48
  def playing?
49
- playing = itunes 'return player state is playing'
49
+ playing = itunes "return player state is playing"
50
50
  playing == "true"
51
51
  end
52
52
 
53
53
  def launched?
54
- nb = %x(osascript -e 'tell app "System Events" to count (every process whose name is "iTunes")' 2>/dev/null).rstrip
55
- nb.match(/^\d+/) and nb.to_i > 0 ? true : false
54
+ %x(osascript -e 'app "iTunes" is running').rstrip == "true"
56
55
  end
57
56
 
58
57
  def name
59
58
  "iTunes Mac"
60
59
  end
61
60
 
61
+ def platforms
62
+ [:mac]
63
+ end
64
+
65
+
62
66
  private
63
- def itunes(command)
64
- %x(osascript -e 'tell app "iTunes" to #{command}').rstrip
65
- end
67
+
68
+ def itunes(command)
69
+ %x(osascript -e 'tell app "iTunes" to #{command}').rstrip
70
+ end
66
71
  end
@@ -1,7 +1,7 @@
1
1
  begin
2
- require 'win32ole'
2
+ require "win32ole"
3
3
  rescue LoadError => e
4
- raise LoadError.new("#{e.message} -- You probably aren't on Windows")
4
+ raise LoadError.new("#{e.message} - You probably aren't on Windows")
5
5
  end
6
6
 
7
7
  class Anyplayer::ItunesWindows < Anyplayer::Player
@@ -59,10 +59,13 @@ class Anyplayer::ItunesWindows < Anyplayer::Player
59
59
  "iTunes Windows"
60
60
  end
61
61
 
62
+ def platforms
63
+ [:windows]
64
+ end
65
+
62
66
  private
63
67
 
64
- def itunes
65
- itunes ||= WIN32OLE.new("iTunes.Application")
66
- end
68
+ def itunes
69
+ itunes ||= WIN32OLE.new("iTunes.Application")
70
+ end
67
71
  end
68
-
@@ -1,11 +1,10 @@
1
1
  # encoding: utf-8
2
2
  begin
3
- require 'ruby-mpd'
3
+ require "ruby-mpd"
4
4
  rescue LoadError => e
5
- raise LoadError.new "#{e.message} — please install ruby-mpd gem"
5
+ raise LoadError.new "#{e.message} — Please install the ruby-mpd gem"
6
6
  end
7
7
 
8
-
9
8
  class Anyplayer::Mpd < Anyplayer::Player
10
9
  def initialize
11
10
  @mpc = false
@@ -51,15 +50,18 @@ class Anyplayer::Mpd < Anyplayer::Player
51
50
  end
52
51
 
53
52
  def track
54
- mpc.current_song && mpc.current_song.title
53
+ song = current_song
54
+ return unless song
55
+
56
+ song.title || File.basename(song.file)
55
57
  end
56
58
 
57
59
  def artist
58
- mpc.current_song && mpc.current_song.artist
60
+ current_song&.artist
59
61
  end
60
62
 
61
63
  def album
62
- mpc.current_song && mpc.current_song.album
64
+ current_song&.album
63
65
  end
64
66
 
65
67
  def launched?
@@ -67,10 +69,15 @@ class Anyplayer::Mpd < Anyplayer::Player
67
69
  end
68
70
 
69
71
  def host
70
- ENV['MPD_HOST'] || super
72
+ ENV["MPD_HOST"] || super
71
73
  end
72
74
 
73
75
  private
76
+
77
+ def current_song
78
+ mpc.current_song
79
+ end
80
+
74
81
  def connect
75
82
  @mpc ||= MPD.new
76
83
  @mpc.connect
@@ -83,4 +90,3 @@ class Anyplayer::Mpd < Anyplayer::Player
83
90
  @mpc
84
91
  end
85
92
  end
86
-
@@ -1,5 +1,6 @@
1
1
  class Anyplayer::Noplayer < Anyplayer::Player
2
- def playpause
2
+ def playing?
3
+ true
3
4
  end
4
5
 
5
6
  def play
@@ -42,4 +43,3 @@ class Anyplayer::Noplayer < Anyplayer::Player
42
43
  true
43
44
  end
44
45
  end
45
-
@@ -1,66 +1,70 @@
1
1
  class Anyplayer::RdioMac < Anyplayer::Player
2
2
  def play
3
- rdio 'play'
3
+ rdio "play"
4
4
  end
5
5
 
6
6
  def pause
7
- rdio 'pause'
7
+ rdio "pause"
8
8
  end
9
9
 
10
10
  def playpause
11
- rdio 'playpause'
11
+ rdio "playpause"
12
12
  end
13
13
 
14
14
  def prev
15
- rdio 'previous track'
15
+ rdio "previous track"
16
16
  super
17
17
  end
18
18
 
19
19
  def next
20
- rdio 'next track'
20
+ rdio "next track"
21
21
  super
22
22
  end
23
23
 
24
24
  def voldown
25
- rdio 'set sound volume to sound volume - 10'
25
+ rdio "set sound volume to sound volume - 10"
26
26
  end
27
27
 
28
28
  def volup
29
- rdio 'set sound volume to sound volume + 10'
29
+ rdio "set sound volume to sound volume + 10"
30
30
  end
31
31
 
32
32
  def volume
33
- rdio 'return sound volume'
33
+ rdio "return sound volume"
34
34
  end
35
35
 
36
36
  def track
37
- rdio 'return name of current track'
37
+ rdio "return name of current track"
38
38
  end
39
39
 
40
40
  def artist
41
- rdio 'return artist of current track'
41
+ rdio "return artist of current track"
42
42
  end
43
43
 
44
44
  def album
45
- rdio 'return album of current track'
45
+ rdio "return album of current track"
46
46
  end
47
47
 
48
48
  def playing?
49
- playing = rdio 'return player state is playing'
49
+ playing = rdio "return player state is playing"
50
50
  playing == "true"
51
51
  end
52
52
 
53
53
  def launched?
54
- nb = %x(osascript -e 'tell app "System Events" to count (every process whose name is "rdio")' 2>/dev/null).rstrip
55
- nb.match(/^\d+/) and nb.to_i > 0 ? true : false
54
+ %x(osascript -e 'app "rdio" is running').rstrip == "true"
56
55
  end
57
56
 
58
57
  def name
59
58
  "Rdio Mac"
60
59
  end
61
60
 
61
+ def platforms
62
+ [:mac]
63
+ end
64
+
62
65
  private
63
- def rdio(command)
64
- %x(osascript -e 'tell app "rdio" to #{command}').rstrip
65
- end
66
- end
66
+
67
+ def rdio(command)
68
+ %x(osascript -e 'tell app "rdio" to #{command}').rstrip
69
+ end
70
+ end
@@ -1,48 +1,48 @@
1
1
  class Anyplayer::Rhythmbox < Anyplayer::Player
2
2
  def playpause
3
- rhythmbox 'play-pause'
3
+ rhythmbox "play-pause"
4
4
  end
5
5
 
6
6
  def play
7
- rhythmbox 'play'
7
+ rhythmbox "play"
8
8
  end
9
9
 
10
10
  def pause
11
- rhythmbox 'pause'
11
+ rhythmbox "pause"
12
12
  end
13
13
 
14
14
  def prev
15
- rhythmbox 'previous'
15
+ rhythmbox "previous"
16
16
  super
17
17
  end
18
18
 
19
19
  def next
20
- rhythmbox 'next'
20
+ rhythmbox "next"
21
21
  super
22
22
  end
23
23
 
24
24
  def voldown
25
- rhythmbox 'volume-down'
25
+ rhythmbox "volume-down"
26
26
  end
27
27
 
28
28
  def volup
29
- rhythmbox 'volume-up'
29
+ rhythmbox "volume-up"
30
30
  end
31
31
 
32
32
  def volume
33
- rhythmbox 'print-volume'
33
+ rhythmbox "print-volume"
34
34
  end
35
35
 
36
36
  def track
37
- rhythmbox 'print-playing-format=%tt'
37
+ rhythmbox "print-playing-format=%tt"
38
38
  end
39
39
 
40
40
  def artist
41
- rhythmbox 'print-playing-format=%ta'
41
+ rhythmbox "print-playing-format=%ta"
42
42
  end
43
43
 
44
44
  def album
45
- rhythmbox 'print-playing-format=%at'
45
+ rhythmbox "print-playing-format=%at"
46
46
  end
47
47
 
48
48
  def launched?
@@ -50,8 +50,8 @@ class Anyplayer::Rhythmbox < Anyplayer::Player
50
50
  end
51
51
 
52
52
  private
53
- def rhythmbox(command)
54
- %x(rhythmbox-client --no-start --#{command}).rstrip
55
- end
56
- end
57
53
 
54
+ def rhythmbox(command)
55
+ %x(rhythmbox-client --no-start --#{command}).rstrip
56
+ end
57
+ end
@@ -1,66 +1,70 @@
1
1
  class Anyplayer::SpotifyMac < Anyplayer::Player
2
2
  def play
3
- spotify 'play'
3
+ spotify "play"
4
4
  end
5
5
 
6
6
  def pause
7
- spotify 'pause'
7
+ spotify "pause"
8
8
  end
9
9
 
10
10
  def playpause
11
- spotify 'playpause'
11
+ spotify "playpause"
12
12
  end
13
13
 
14
14
  def prev
15
- spotify 'previous track'
15
+ spotify "previous track"
16
16
  super
17
17
  end
18
18
 
19
19
  def next
20
- spotify 'next track'
20
+ spotify "next track"
21
21
  super
22
22
  end
23
23
 
24
24
  def voldown
25
- spotify 'set sound volume to sound volume - 10'
25
+ spotify "set sound volume to sound volume - 10"
26
26
  end
27
27
 
28
28
  def volup
29
- spotify 'set sound volume to sound volume + 10'
29
+ spotify "set sound volume to sound volume + 10"
30
30
  end
31
31
 
32
32
  def volume
33
- spotify 'return sound volume'
33
+ spotify "return sound volume"
34
34
  end
35
35
 
36
36
  def track
37
- spotify 'return name of current track'
37
+ spotify "return name of current track"
38
38
  end
39
39
 
40
40
  def artist
41
- spotify 'return artist of current track'
41
+ spotify "return artist of current track"
42
42
  end
43
43
 
44
44
  def album
45
- spotify 'return album of current track'
45
+ spotify "return album of current track"
46
46
  end
47
47
 
48
48
  def playing?
49
- playing = spotify 'return player state is playing'
49
+ playing = spotify "return player state is playing"
50
50
  playing == "true"
51
51
  end
52
52
 
53
53
  def launched?
54
- nb = %x(osascript -e 'tell app "System Events" to count (every process whose name is "Spotify")' 2>/dev/null).rstrip
55
- nb.match(/^\d+/) and nb.to_i > 0 ? true : false
54
+ %x(osascript -e 'app "Spotify" is running').rstrip == "true"
56
55
  end
57
56
 
58
57
  def name
59
58
  "Spotify Mac"
60
59
  end
61
60
 
61
+ def platforms
62
+ [:mac]
63
+ end
64
+
62
65
  private
63
- def spotify(command)
64
- %x(osascript -e 'tell app "spotify" to #{command}').rstrip
65
- end
66
+
67
+ def spotify(command)
68
+ %x(osascript -e 'tell app "Spotify" to #{command}').rstrip
69
+ end
66
70
  end