hearken 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +6 -0
- data/README.rdoc +47 -2
- data/lib/hearken.rb +1 -1
- data/lib/hearken/command/shuffle.rb +2 -2
- data/lib/hearken/console.rb +2 -2
- data/lib/hearken/library.rb +4 -4
- data/lib/hearken/paths.rb +6 -1
- data/lib/hearken/player.rb +19 -19
- data/lib/hearken/queue.rb +1 -2
- data/spec/hearken/command/shuffle_spec.rb +7 -3
- metadata +3 -4
- data/lib/hearken/command/show_properties.rb +0 -9
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
= 0.0.5
|
2
|
+
|
3
|
+
* fixed 'recent' command - the library is sorted on file modification date
|
4
|
+
* moved 'current_song' from working directory to .hearken directory
|
5
|
+
* Changed dequeue to return track instead of id - this fixed a bug where reindexing would cause player to start playing the wrong files.
|
6
|
+
|
1
7
|
= 0.0.4
|
2
8
|
|
3
9
|
* Partially fixed bug with growl (correctly escaping characters in message)
|
data/README.rdoc
CHANGED
@@ -26,14 +26,20 @@ Growl notification (as new tracks are played) will work but only if 'growlnotify
|
|
26
26
|
|
27
27
|
hearken index DIRECTORY
|
28
28
|
|
29
|
-
Will create a track index at ~/.music. Note that this might take a while the first time you run it.
|
29
|
+
Will create a track index at ~/.hearken/music. Note that this might take a while the first time you run it.
|
30
30
|
|
31
31
|
Subsequent runs will only query tags for new or modified files so should be fairly fast.
|
32
32
|
|
33
|
+
The index can be regenerated while the console is running and reloaded using the 'reload' command.
|
34
|
+
|
33
35
|
== Console
|
34
36
|
|
35
37
|
hearken console
|
36
38
|
|
39
|
+
This enters an interactive prompt where you can start/stop the player, search and enqueue tracks.
|
40
|
+
|
41
|
+
The queue will be persisted to ~/.hearken/queue
|
42
|
+
|
37
43
|
== Commands
|
38
44
|
|
39
45
|
?
|
@@ -44,8 +50,47 @@ will list all commands
|
|
44
50
|
|
45
51
|
will describe the use and purpose of a particular command
|
46
52
|
|
53
|
+
== Main commands
|
54
|
+
|
55
|
+
search iver bon
|
56
|
+
|
57
|
+
Searches for tracks with 'bon' and 'iver' in the track, artist or album name (this is case insensitive).
|
58
|
+
|
59
|
+
Results will be displayed and the ids will be added to the clipboard (for convenient pasting to the '+' command).
|
60
|
+
|
61
|
+
+ abc-f 123 456
|
62
|
+
|
63
|
+
Enqueues tracks with ids abc, abd, abe, abf, 123 and 456
|
64
|
+
|
65
|
+
start
|
66
|
+
|
67
|
+
Starts the player
|
68
|
+
|
69
|
+
stop
|
70
|
+
|
71
|
+
Stops the player
|
72
|
+
|
73
|
+
next
|
74
|
+
|
75
|
+
Stops and restarts the player (which will kill the currently playing track)
|
76
|
+
|
77
|
+
setup_scrobbling
|
78
|
+
|
79
|
+
Runs through a wizard to configure scrobbling to last.fm
|
80
|
+
|
81
|
+
scrobbling on
|
82
|
+
|
83
|
+
Turns scrobbling on (has no effect if scrobbling has not been configured)
|
84
|
+
|
85
|
+
scrobbling off
|
86
|
+
|
87
|
+
Turns scrobbling off
|
88
|
+
|
47
89
|
= Future plans for world domination
|
48
90
|
|
49
|
-
*
|
91
|
+
* add a '-' command to remove tracks from queue
|
92
|
+
* add a command to launch last.fm profile (for track history)
|
93
|
+
* put some content on wiki to explain usage (especially use of track ranges '+ eft-z')
|
94
|
+
* eliminate last.fm setup command once setup and add lastfm commands only when setup
|
50
95
|
* Get working on linux
|
51
96
|
* Get working on windows
|
data/lib/hearken.rb
CHANGED
@@ -5,8 +5,8 @@ class Hearken::Command::Shuffle
|
|
5
5
|
help 'shuffles the current queue'
|
6
6
|
execute do |ignored=nil|
|
7
7
|
ids = []
|
8
|
-
while
|
9
|
-
ids << id
|
8
|
+
while track = @player.dequeue
|
9
|
+
ids << track.id
|
10
10
|
end
|
11
11
|
ids.sort_by { rand }.each {|id| @player.enqueue id }
|
12
12
|
end
|
data/lib/hearken/console.rb
CHANGED
@@ -25,10 +25,10 @@ module Hearken
|
|
25
25
|
at_exit { @player.stop }
|
26
26
|
@prompt = "hearken > "
|
27
27
|
with :status, "'"
|
28
|
-
with :show_properties, 'show'
|
29
28
|
with :restart, 'next'
|
29
|
+
with :list, 'ls'
|
30
30
|
with :enqueue, '+'
|
31
|
-
with_all *%w{reload search start stop scrobbling shuffle
|
31
|
+
with_all *%w{reload search start stop scrobbling shuffle setup_scrobbling recent flush}
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/hearken/library.rb
CHANGED
@@ -23,10 +23,6 @@ class Hearken::Library
|
|
23
23
|
@tracks[id]
|
24
24
|
end
|
25
25
|
|
26
|
-
def path row
|
27
|
-
row.path
|
28
|
-
end
|
29
|
-
|
30
26
|
def with_track id
|
31
27
|
yield @tracks[id]
|
32
28
|
end
|
@@ -42,6 +38,10 @@ class Hearken::Library
|
|
42
38
|
@tracks << track
|
43
39
|
id += 1
|
44
40
|
end
|
41
|
+
@tracks.sort! do |a, b|
|
42
|
+
tc = a.timestamp <=> b.timestamp
|
43
|
+
tc == 0 ? a.id <=> b.id : tc
|
44
|
+
end
|
45
45
|
end if File.exist? index_path
|
46
46
|
end
|
47
47
|
end
|
data/lib/hearken/paths.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Hearken::Paths
|
4
|
-
attr_reader :preferences_path, :queue_path, :index_path
|
4
|
+
attr_reader :base_path, :preferences_path, :queue_path, :index_path
|
5
5
|
|
6
6
|
def create_paths
|
7
|
+
@base_path = '.hearken'.from_home
|
7
8
|
@preferences_path = '.hearken/config'.from_home
|
8
9
|
@queue_path = '.hearken/queue'.from_home
|
9
10
|
@index_path = '.hearken/music'.from_home
|
@@ -16,4 +17,8 @@ module Hearken::Paths
|
|
16
17
|
def in_queue_dir
|
17
18
|
Dir.chdir(queue_path) { yield }
|
18
19
|
end
|
20
|
+
|
21
|
+
def in_base_dir
|
22
|
+
Dir.chdir(base_path) { yield }
|
23
|
+
end
|
19
24
|
end
|
data/lib/hearken/player.rb
CHANGED
@@ -37,12 +37,16 @@ module Hearken
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def current
|
40
|
-
|
40
|
+
in_base_dir do
|
41
|
+
(@pid and File.exist?('current_song')) ? YAML.load_file('current_song') : nil
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def register track
|
44
46
|
track.started = Time.now.to_i
|
45
|
-
|
47
|
+
in_base_dir do
|
48
|
+
File.open('current_song', 'w') {|f| f.print track.to_yaml }
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
def notify_started track
|
@@ -57,6 +61,10 @@ module Hearken
|
|
57
61
|
@scrobbler.enabled = tf
|
58
62
|
end
|
59
63
|
|
64
|
+
def random_track
|
65
|
+
@library.row (rand * @library.count).to_i
|
66
|
+
end
|
67
|
+
|
60
68
|
def start
|
61
69
|
return if @pid
|
62
70
|
@pid = fork do
|
@@ -65,26 +73,18 @@ module Hearken
|
|
65
73
|
Process.kill 'TERM', player_pid if player_pid
|
66
74
|
exit
|
67
75
|
end
|
68
|
-
total_tracks = @library.count
|
69
76
|
loop do
|
70
|
-
|
71
|
-
|
72
|
-
unless
|
73
|
-
puts "track
|
77
|
+
track = dequeue || random_track
|
78
|
+
next unless track
|
79
|
+
unless File.exist? track.path
|
80
|
+
puts "skipping track as #{track.path} does not exist"
|
74
81
|
next
|
75
82
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@library.with_track(id) do |track|
|
82
|
-
notify_started track
|
83
|
-
register track
|
84
|
-
player_pid = path.escape2("\`").to_player
|
85
|
-
Process.wait player_pid
|
86
|
-
notify_finished track
|
87
|
-
end
|
83
|
+
notify_started track
|
84
|
+
register track
|
85
|
+
player_pid = track.path.escape2("\`").to_player
|
86
|
+
Process.wait player_pid
|
87
|
+
notify_finished track
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
data/lib/hearken/queue.rb
CHANGED
@@ -13,9 +13,13 @@ describe Hearken::Command::Shuffle do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should dequeue all tracks, shuffle then enqueue them' do
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
track = stub 'track'
|
17
|
+
track.should_receive(:id).and_return 1
|
18
|
+
track.should_receive(:id).and_return 2
|
19
|
+
track.should_receive(:id).and_return 3
|
20
|
+
@player.should_receive(:dequeue).and_return track
|
21
|
+
@player.should_receive(:dequeue).and_return track
|
22
|
+
@player.should_receive(:dequeue).and_return track
|
19
23
|
@player.should_receive(:dequeue).and_return nil
|
20
24
|
|
21
25
|
@player.should_receive(:enqueue).with 3
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hearken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
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
|
13
|
+
date: 2011-08-07 00:00:00 +10:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -138,7 +138,6 @@ files:
|
|
138
138
|
- lib/hearken/command/scrobbling.rb
|
139
139
|
- lib/hearken/command/search.rb
|
140
140
|
- lib/hearken/command/setup_scrobbling.rb
|
141
|
-
- lib/hearken/command/show_properties.rb
|
142
141
|
- lib/hearken/command/shuffle.rb
|
143
142
|
- lib/hearken/command/start.rb
|
144
143
|
- lib/hearken/command/status.rb
|
@@ -198,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
197
|
requirements: []
|
199
198
|
|
200
199
|
rubyforge_project: hearken
|
201
|
-
rubygems_version: 1.
|
200
|
+
rubygems_version: 1.6.2
|
202
201
|
signing_key:
|
203
202
|
specification_version: 3
|
204
203
|
summary: command line music player
|