hearken 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ = next
2
+
3
+ * Fixed bug in setup_scrobbling command
4
+
5
+ = 0.0.2
6
+
7
+ * First functioning version - combination of features from audio_library and songbirdsh
8
+
9
+ = 0.0.1
10
+
11
+ * Released empty gem (to claim the name before proceeding any further)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Mark Ryall
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -20,6 +20,8 @@ Tags are currently extracted using ffmpeg. On mac os x, this can be installed e
20
20
 
21
21
  brew install ffmpeg
22
22
 
23
+ Growl notification (as new tracks are played) will work but only if 'growlnotify' is detected on the path.
24
+
23
25
  == Indexing tracks
24
26
 
25
27
  hearken index DIRECTORY
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "hearken/version"
3
+ require 'hearken'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "hearken"
@@ -29,6 +29,7 @@ EOF
29
29
  s.add_dependency 'shell_shock', '~>0'
30
30
  s.add_dependency 'simple_scrobbler', '~> 0'
31
31
  s.add_dependency 'rainbow', '~> 1'
32
+ s.add_dependency 'ruby-growl', '~> 3.0'
32
33
 
33
34
  s.add_development_dependency 'rake', '~>0'
34
35
  s.add_development_dependency 'rspec', '~>2'
@@ -1 +1,3 @@
1
- require 'hearken/version'
1
+ module Hearken
2
+ VERSION = '0.0.3'
3
+ end
@@ -1,24 +1,22 @@
1
1
  require 'thor'
2
2
 
3
- require 'hearken/version'
3
+ require 'hearken'
4
4
  require 'hearken/indexing'
5
5
  require 'hearken/console'
6
6
 
7
- module Hearken
8
- class Cli < Thor
9
- desc 'version', 'Prints the current version'
10
- def version
11
- puts "Current version is "+Hearken::VERSION
12
- end
7
+ class Hearken::Cli < Thor
8
+ desc 'version', 'Prints the current version'
9
+ def version
10
+ puts "Current version is "+Hearken::VERSION
11
+ end
13
12
 
14
- desc 'index DIRECTORY', 'Reindexes a music collection'
15
- def index directory
16
- Hearken::Indexing::Indexer.new(directory).execute
17
- end
13
+ desc 'index DIRECTORY', 'Reindexes a music collection'
14
+ def index directory
15
+ Hearken::Indexing::Indexer.new(directory).execute
16
+ end
18
17
 
19
- desc 'console', 'Enters console for queuing and playing tracks'
20
- def console
21
- Hearken::Console.new.push
22
- end
18
+ desc 'console', 'Enters console for queuing and playing tracks'
19
+ def console
20
+ Hearken::Console.new.push
23
21
  end
24
22
  end
@@ -20,6 +20,5 @@ EOF
20
20
  end
21
21
  puts "Found #{matches.size} matches (ids have been placed on clipboard)"
22
22
  matches.join(' ').to_clipboard
23
- @player.matches = matches
24
23
  end
25
24
  end
@@ -0,0 +1,13 @@
1
+ module Hearken::Notification
2
+ end
3
+
4
+ class Hearken::Notification::GrowlNotifier
5
+ def initialize preferences
6
+ @growlnotify = !`which growlnotify`.chomp.empty?
7
+ @image_path = File.expand_path File.dirname(__FILE__)+'/../../../media/ice_cream.png'
8
+ end
9
+
10
+ def started track
11
+ `growlnotify -t "Hearken" --image #{@image_path} -m '#{track.to_short_s}'` if @growlnotify
12
+ end
13
+ end
@@ -2,17 +2,19 @@ require 'splat'
2
2
 
3
3
  require 'hearken/queue'
4
4
  require 'hearken/scrobbler'
5
+ require 'hearken/notification/growl_notifier'
5
6
  require 'hearken/library'
6
7
 
7
8
  module Hearken
8
9
  class Player
9
10
  include Queue
10
11
  attr_reader :library, :scrobbler
11
- attr_accessor :scrobbling, :matches
12
12
 
13
13
  def initialize preferences
14
14
  @scrobbler = Scrobbler.new preferences
15
- @scrobbling = true
15
+ @scrobbler.enabled = true
16
+ @growl = Hearken::Notification::GrowlNotifier.new preferences
17
+ @notifiers = [@scrobbler, @growl]
16
18
  @library = Library.new preferences
17
19
  @library.reload
18
20
  end
@@ -41,11 +43,20 @@ module Hearken
41
43
  File.open('current_song', 'w') {|f| f.print track.to_yaml }
42
44
  end
43
45
 
46
+ def notify_started track
47
+ @notifiers.each {|notifier| notifier.started track if notifier.respond_to? :started}
48
+ end
49
+
50
+ def notify_finished track
51
+ @notifiers.each {|notifier| notifier.finished track if notifier.respond_to? :finished}
52
+ end
53
+
54
+ def scrobbling tf
55
+ @scrobbler.enabled = tf
56
+ end
57
+
44
58
  def start
45
- if @pid
46
- puts "Already started (pid #{@pid})"
47
- return
48
- end
59
+ return if @pid
49
60
  @pid = fork do
50
61
  player_pid = nil
51
62
  Signal.trap('TERM') do
@@ -66,15 +77,14 @@ module Hearken
66
77
  next
67
78
  end
68
79
  @library.with_track(id) do |track|
69
- @scrobbler.update track if @scrobbling
80
+ notify_started track
70
81
  register track
71
82
  player_pid = path.to_player
72
83
  Process.wait player_pid
73
- @scrobbler.scrobble track if @scrobbling
84
+ notify_finished track
74
85
  end
75
86
  end
76
87
  end
77
- puts "Started (pid #{@pid})"
78
88
  end
79
89
 
80
90
  def stop
@@ -8,19 +8,23 @@ module Hearken
8
8
 
9
9
  def initialize preferences
10
10
  @preferences = preferences
11
- if preferences['lastfm']
12
- debug "Configuring scrobbler with #{preferences['lastfm'].inspect}"
13
- @scrobbler = SimpleScrobbler.new *%w{api_key secret user session_key}.map{|k| preferences['lastfm'][k]}
11
+ end
12
+
13
+ def enabled= tf
14
+ @scrobbler = nil
15
+ if @preferences['lastfm'] and tf
16
+ debug "Configuring scrobbler with #{@preferences['lastfm'].inspect}"
17
+ @scrobbler = SimpleScrobbler.new *%w{api_key secret user session_key}.map{|k| @preferences['lastfm'][k]}
14
18
  end
15
19
  end
16
20
 
17
- def scrobble track
21
+ def finished track
18
22
  return unless @scrobbler
19
23
  debug "Scrobbling to last fm: #{track}"
20
24
  send_to_scrobbler :submit, track
21
25
  end
22
26
 
23
- def update track
27
+ def started track
24
28
  return unless @scrobbler
25
29
  debug "Updating now listening with last fm: #{track}"
26
30
  send_to_scrobbler :now_playing, track
@@ -28,7 +32,7 @@ module Hearken
28
32
 
29
33
  def ask question
30
34
  print question
31
- gets.chomp
35
+ $stdin.gets.chomp
32
36
  end
33
37
 
34
38
  def setup
@@ -21,9 +21,6 @@ class Hearken::Track
21
21
  id.to_s 36
22
22
  end
23
23
 
24
- def duration
25
- end
26
-
27
24
  def search_string
28
25
  "#{self.artist.to_s.downcase}#{self.album.to_s.downcase}#{self.title.to_s.downcase}"
29
26
  end
@@ -32,6 +29,10 @@ class Hearken::Track
32
29
  "#{my(:search_id,:white)}: #{my(:artist, :yellow)} - #{my(:album,:cyan)} - #{my(:track,:magenta)} #{my(:title,:green)} (#{my(:time,:white)})"
33
30
  end
34
31
 
32
+ def to_short_s
33
+ "#{track} #{title}\n#{artist}\n#{album}"
34
+ end
35
+
35
36
  def my field, colour
36
37
  self.send(field).to_s.foreground(colour)
37
38
  end
Binary file
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hearken
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Ryall
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-05 00:00:00 +10:00
13
+ date: 2011-07-06 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -69,27 +69,38 @@ dependencies:
69
69
  type: :runtime
70
70
  version_requirements: *id005
71
71
  - !ruby/object:Gem::Dependency
72
- name: rake
72
+ name: ruby-growl
73
73
  prerelease: false
74
74
  requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "3.0"
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
75
86
  none: false
76
87
  requirements:
77
88
  - - ~>
78
89
  - !ruby/object:Gem::Version
79
90
  version: "0"
80
91
  type: :development
81
- version_requirements: *id006
92
+ version_requirements: *id007
82
93
  - !ruby/object:Gem::Dependency
83
94
  name: rspec
84
95
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
96
+ requirement: &id008 !ruby/object:Gem::Requirement
86
97
  none: false
87
98
  requirements:
88
99
  - - ~>
89
100
  - !ruby/object:Gem::Version
90
101
  version: "2"
91
102
  type: :development
92
- version_requirements: *id007
103
+ version_requirements: *id008
93
104
  description: |
94
105
  A command line tool to enqueue and play music tracks.
95
106
 
@@ -109,6 +120,8 @@ files:
109
120
  - .gitignore
110
121
  - .rvmrc
111
122
  - Gemfile
123
+ - HISTORY.rdoc
124
+ - MIT-LICENSE
112
125
  - README.rdoc
113
126
  - Rakefile
114
127
  - bin/hearken
@@ -142,6 +155,7 @@ files:
142
155
  - lib/hearken/indexing/persistant_traverser.rb
143
156
  - lib/hearken/indexing/persisted_traverser.rb
144
157
  - lib/hearken/library.rb
158
+ - lib/hearken/notification/growl_notifier.rb
145
159
  - lib/hearken/player.rb
146
160
  - lib/hearken/preferences.rb
147
161
  - lib/hearken/queue.rb
@@ -149,8 +163,8 @@ files:
149
163
  - lib/hearken/scrobbler.rb
150
164
  - lib/hearken/tagged.rb
151
165
  - lib/hearken/track.rb
152
- - lib/hearken/version.rb
153
166
  - media/applause.mp3
167
+ - media/ice_cream.png
154
168
  - spec/hearken/command/enqueue_spec.rb
155
169
  - spec/hearken/command/list_spec.rb
156
170
  - spec/hearken/command/reload_spec.rb
@@ -1,3 +0,0 @@
1
- module Hearken
2
- VERSION = '0.0.2'
3
- end