hearken 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +14 -0
- data/.tool-versions +1 -0
- data/Gemfile +7 -1
- data/Gemfile.lock +95 -0
- data/{README.rdoc → README.md} +12 -50
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/hearken +9 -0
- data/exe/hearken_index +13 -0
- data/hearken.gemspec +35 -35
- data/lib/hearken/command/enqueue.rb +35 -10
- data/lib/hearken/command/reload.rb +18 -6
- data/lib/hearken/command/search.rb +31 -20
- data/lib/hearken/console.rb +11 -28
- data/lib/hearken/debug.rb +6 -6
- data/lib/hearken/indexing/indexer.rb +32 -24
- data/lib/hearken/library.rb +49 -41
- data/lib/hearken/monkey_violence.rb +9 -7
- data/lib/hearken/paths.rb +13 -19
- data/lib/hearken/range_expander.rb +18 -13
- data/lib/hearken/tagged.rb +15 -11
- data/lib/hearken/track.rb +53 -41
- data/lib/hearken.rb +2 -2
- metadata +26 -105
- data/.gitignore +0 -5
- data/HISTORY.rdoc +0 -38
- data/MIT-LICENSE +0 -20
- data/bin/hearken +0 -7
- data/bin/hearken_index +0 -12
- data/bin/hearken_scrobble +0 -35
- data/bin/hearken_tags +0 -11
- data/lib/hearken/command/list.rb +0 -32
- data/lib/hearken/command/love.rb +0 -7
- data/lib/hearken/command/profile.rb +0 -7
- data/lib/hearken/command/recent.rb +0 -38
- data/lib/hearken/command/remove.rb +0 -15
- data/lib/hearken/command/restart.rb +0 -7
- data/lib/hearken/command/scrobbling.rb +0 -14
- data/lib/hearken/command/setup_scrobbling.rb +0 -7
- data/lib/hearken/command/shuffle.rb +0 -13
- data/lib/hearken/command/start.rb +0 -7
- data/lib/hearken/command/status.rb +0 -7
- data/lib/hearken/command/stop.rb +0 -7
- data/lib/hearken/command.rb +0 -35
- data/lib/hearken/notification/growl_notifier.rb +0 -15
- data/lib/hearken/player.rb +0 -130
- data/lib/hearken/preferences.rb +0 -33
- data/lib/hearken/queue.rb +0 -33
- data/lib/hearken/scrobbler.rb +0 -82
- data/lib/hearken/simple_scrobbler.rb +0 -94
- data/media/ice_cream.png +0 -0
- data/spec/hearken/command/enqueue_spec.rb +0 -24
- data/spec/hearken/command/list_spec.rb +0 -31
- data/spec/hearken/command/reload_spec.rb +0 -21
- data/spec/hearken/command/shuffle_spec.rb +0 -33
- data/spec/hearken/player_spec.rb +0 -38
- data/spec/hearken/range_expander_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 761d514192be6b3c770a1e81f2ac0a72dfe0de27ede2a5e76fd02d61d1058b15
|
4
|
+
data.tar.gz: 22001a8cdd6df13c97e9bbaf79a32822afdcdba15e2504fde2051b0ebcb849ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ba4d3631c06bc18146bfab3b12ad7dd8fbac92c99fd5dc6105fb73019f5a880147a6563353ff3e4ea7e6a41cd4579b8c0bf65167a51fdad219e627a96ae392e
|
7
|
+
data.tar.gz: 83f77b3a824a01bc87c263e1325695174ffdb8772fd1ded3e4712c6280a6e1f94945dc577d13a9a1d65d57cfe0c38b31535989c2e20320f92c63546778f65d7b
|
data/.rubocop.yml
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.1.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hearken (0.1.3)
|
5
|
+
rainbow (~> 2)
|
6
|
+
shell_shock
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
backport (1.2.0)
|
13
|
+
benchmark (0.2.0)
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
e2mmap (0.1.0)
|
16
|
+
jaro_winkler (1.5.4)
|
17
|
+
json (2.6.2)
|
18
|
+
kramdown (2.4.0)
|
19
|
+
rexml
|
20
|
+
kramdown-parser-gfm (1.1.0)
|
21
|
+
kramdown (~> 2.0)
|
22
|
+
nokogiri (1.13.8-x86_64-darwin)
|
23
|
+
racc (~> 1.4)
|
24
|
+
parallel (1.22.1)
|
25
|
+
parser (3.1.2.1)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
racc (1.6.0)
|
28
|
+
rainbow (2.2.2)
|
29
|
+
rake
|
30
|
+
rake (13.0.6)
|
31
|
+
regexp_parser (2.5.0)
|
32
|
+
reverse_markdown (2.1.1)
|
33
|
+
nokogiri
|
34
|
+
rexml (3.2.5)
|
35
|
+
rspec (3.11.0)
|
36
|
+
rspec-core (~> 3.11.0)
|
37
|
+
rspec-expectations (~> 3.11.0)
|
38
|
+
rspec-mocks (~> 3.11.0)
|
39
|
+
rspec-core (3.11.0)
|
40
|
+
rspec-support (~> 3.11.0)
|
41
|
+
rspec-expectations (3.11.1)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.11.0)
|
44
|
+
rspec-mocks (3.11.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.11.0)
|
47
|
+
rspec-support (3.11.1)
|
48
|
+
rubocop (1.36.0)
|
49
|
+
json (~> 2.3)
|
50
|
+
parallel (~> 1.10)
|
51
|
+
parser (>= 3.1.2.1)
|
52
|
+
rainbow (>= 2.2.2, < 4.0)
|
53
|
+
regexp_parser (>= 1.8, < 3.0)
|
54
|
+
rexml (>= 3.2.5, < 4.0)
|
55
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
56
|
+
ruby-progressbar (~> 1.7)
|
57
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
58
|
+
rubocop-ast (1.21.0)
|
59
|
+
parser (>= 3.1.1.0)
|
60
|
+
ruby-progressbar (1.11.0)
|
61
|
+
shell_shock (0.0.5)
|
62
|
+
solargraph (0.47.0)
|
63
|
+
backport (~> 1.2)
|
64
|
+
benchmark
|
65
|
+
bundler (>= 1.17.2)
|
66
|
+
diff-lcs (~> 1.4)
|
67
|
+
e2mmap
|
68
|
+
jaro_winkler (~> 1.5)
|
69
|
+
kramdown (~> 2.3)
|
70
|
+
kramdown-parser-gfm (~> 1.1)
|
71
|
+
parser (~> 3.0)
|
72
|
+
reverse_markdown (>= 1.0.5, < 3)
|
73
|
+
rubocop (>= 0.52)
|
74
|
+
thor (~> 1.0)
|
75
|
+
tilt (~> 2.0)
|
76
|
+
yard (~> 0.9, >= 0.9.24)
|
77
|
+
thor (1.2.1)
|
78
|
+
tilt (2.0.11)
|
79
|
+
unicode-display_width (2.3.0)
|
80
|
+
webrick (1.7.0)
|
81
|
+
yard (0.9.28)
|
82
|
+
webrick (~> 1.7.0)
|
83
|
+
|
84
|
+
PLATFORMS
|
85
|
+
x86_64-darwin-21
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
hearken!
|
89
|
+
rake
|
90
|
+
rspec
|
91
|
+
rubocop
|
92
|
+
solargraph
|
93
|
+
|
94
|
+
BUNDLED WITH
|
95
|
+
2.3.3
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,32 +1,27 @@
|
|
1
|
-
|
1
|
+
# Hearken
|
2
2
|
|
3
|
-
This is a command line shell for queuing
|
3
|
+
This is a command line shell for queuing music tracks to be played
|
4
|
+
by [vlcraptor](https://github.com/markryall/vlcraptor).
|
4
5
|
|
5
6
|
It also extracts id3 tags from audio files for faster search.
|
6
7
|
|
7
8
|
This may may be platform independent but at this stage has only been used on mac os x
|
8
9
|
|
9
|
-
|
10
|
+
# Usage
|
10
11
|
|
11
12
|
Here you sit expectantly in front of a computer at the command line.
|
12
13
|
|
13
|
-
|
14
|
+
## Install
|
14
15
|
|
15
16
|
gem install hearken
|
16
17
|
|
17
|
-
|
18
|
+
## Dependencies
|
18
19
|
|
19
20
|
Tags are currently extracted using ffmpeg. On mac os x, this can be installed easily using brew:
|
20
21
|
|
21
22
|
brew install ffmpeg
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
brew install sox
|
26
|
-
|
27
|
-
Growl notification (as new tracks are played) will work but only if 'growlnotify' is detected on the path.
|
28
|
-
|
29
|
-
== Indexing tracks
|
24
|
+
## Indexing tracks
|
30
25
|
|
31
26
|
hearken_index DIRECTORY
|
32
27
|
|
@@ -37,15 +32,15 @@ runs will only query tags for new or modified files so will be very fast.
|
|
37
32
|
|
38
33
|
The index can be regenerated while the console is running and reloaded using the 'reload' command.
|
39
34
|
|
40
|
-
|
35
|
+
## Console
|
41
36
|
|
42
37
|
hearken
|
43
38
|
|
44
|
-
This enters an interactive prompt where you can
|
39
|
+
This enters an interactive prompt where you can search and enqueue tracks.
|
45
40
|
|
46
41
|
The queue will be persisted to ~/.hearken/queue
|
47
42
|
|
48
|
-
|
43
|
+
## Commands
|
49
44
|
|
50
45
|
?
|
51
46
|
|
@@ -55,7 +50,7 @@ will list all commands
|
|
55
50
|
|
56
51
|
will describe the use and purpose of a particular command
|
57
52
|
|
58
|
-
|
53
|
+
## Main commands
|
59
54
|
|
60
55
|
search iver bon
|
61
56
|
|
@@ -63,39 +58,6 @@ Searches for tracks with 'bon' and 'iver' in the track, artist or album name (th
|
|
63
58
|
|
64
59
|
Results will be displayed and the ids will be added to the clipboard (for convenient pasting to the '+' command).
|
65
60
|
|
66
|
-
|
61
|
+
enqueue abc-f 123 456
|
67
62
|
|
68
63
|
Enqueues tracks with ids abc, abd, abe, abf, 123 and 456
|
69
|
-
|
70
|
-
play
|
71
|
-
|
72
|
-
Starts the player
|
73
|
-
|
74
|
-
stop
|
75
|
-
|
76
|
-
Stops the player
|
77
|
-
|
78
|
-
next
|
79
|
-
|
80
|
-
Stops and restarts the player (which will kill the currently playing track)
|
81
|
-
|
82
|
-
love
|
83
|
-
|
84
|
-
Tells last.fm that you love the current track (this will do nothing if last.fm is not configured or the player is
|
85
|
-
stopped)
|
86
|
-
|
87
|
-
rm iver bon
|
88
|
-
|
89
|
-
Removes any enqueued track with 'bon' and 'iver' in the track, artist or album name
|
90
|
-
|
91
|
-
setup_scrobbling
|
92
|
-
|
93
|
-
Runs through a wizard to configure scrobbling to last.fm
|
94
|
-
|
95
|
-
scrobbling on
|
96
|
-
|
97
|
-
Turns scrobbling on (has no effect if scrobbling has not been configured)
|
98
|
-
|
99
|
-
scrobbling off
|
100
|
-
|
101
|
-
Turns scrobbling off
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "hearken"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/hearken
ADDED
data/exe/hearken_index
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH << ("#{File.dirname(__FILE__)}/../lib")
|
5
|
+
|
6
|
+
require "hearken/indexing"
|
7
|
+
|
8
|
+
unless ARGV.size == 1
|
9
|
+
puts "usage: hearken_index path_to_directory_containing_music_collection"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
Hearken::Indexing::Indexer.new(ARGV.shift).execute
|
data/hearken.gemspec
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
#
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require 'hearken'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
6
|
-
s.name = "hearken"
|
7
|
-
s.version = Hearken::VERSION
|
8
|
-
s.authors = ["Mark Ryall"]
|
9
|
-
s.email = ["mark@ryall.name"]
|
10
|
-
s.homepage = "http://github.com/markryall/hearken"
|
11
|
-
s.summary = "command line music player"
|
12
|
-
s.description = <<EOF
|
13
|
-
A command line tool to enqueue and play music tracks.
|
3
|
+
require_relative "lib/hearken"
|
14
4
|
|
15
|
-
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "hearken"
|
7
|
+
spec.version = Hearken::VERSION
|
8
|
+
spec.authors = ["Mark Ryall"]
|
9
|
+
spec.email = ["mark@ryall.name"]
|
10
|
+
spec.homepage = "http://github.com/markryall/hearken"
|
11
|
+
spec.summary = "command line music player"
|
12
|
+
spec.description = <<~EOF
|
13
|
+
A command line tool to enqueue and play music trackspec.
|
16
14
|
|
17
|
-
This
|
18
|
-
EOF
|
15
|
+
This also extracts the tags from a collection of folderspec.
|
19
16
|
|
20
|
-
|
21
|
-
|
17
|
+
This replaces and combines the functionality from a couple of other gems (audio_library and songbirdsh).
|
18
|
+
EOF
|
22
19
|
|
23
|
-
|
20
|
+
spec.post_install_message = <<~EOF
|
21
|
+
Hey - thanks for installing hearken.
|
24
22
|
|
25
|
-
|
23
|
+
Before doing anything else, you should index your music collection by running:
|
26
24
|
|
27
|
-
|
25
|
+
hearken_index path_to_your_music_collection
|
28
26
|
|
29
|
-
|
30
|
-
EOF
|
27
|
+
This could take a while if you have a large collection - you should hear some applause when it's done
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
After that just run hearken to start searching for and then queueing tracks.
|
30
|
+
EOF
|
34
31
|
|
35
|
-
|
36
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
37
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
38
|
-
s.require_paths = ["lib"]
|
32
|
+
spec.required_ruby_version = ">= 2.6.0"
|
39
33
|
|
40
|
-
|
34
|
+
# Specify which files should be added to the gem when it is released.
|
35
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
36
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
37
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
38
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
spec.bindir = "exe"
|
42
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
43
|
+
spec.require_paths = ["lib"]
|
41
44
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
s.add_development_dependency 'rake', '~>0'
|
47
|
-
s.add_development_dependency 'rspec', '~>3'
|
45
|
+
spec.add_dependency "rainbow", "~> 2"
|
46
|
+
spec.add_dependency "shell_shock"
|
47
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
48
48
|
end
|
@@ -1,12 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "hearken/range_expander"
|
5
|
+
|
6
|
+
module Hearken
|
7
|
+
module Command
|
8
|
+
class Enqueue
|
9
|
+
attr_reader :usage, :help
|
10
|
+
|
11
|
+
def initialize(library)
|
12
|
+
@usage = "*<id>"
|
13
|
+
@help = "enqueues the list of songs with the specified ids"
|
14
|
+
@expander = Hearken::RangeExpander.new
|
15
|
+
@library = library
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute(text)
|
19
|
+
`mkdir -p /tmp/queue`
|
20
|
+
count = (Time.now.to_f * 1000).to_i
|
21
|
+
@expander.expand(text).each do |id|
|
22
|
+
@library.with_track id do |track|
|
23
|
+
meta = {
|
24
|
+
title: track.title,
|
25
|
+
artist: track.artist,
|
26
|
+
album: track.album,
|
27
|
+
length: track.time.to_i,
|
28
|
+
path: track.path
|
29
|
+
}
|
30
|
+
File.open("/tmp/queue/#{count}.yml", "w") { |f| f.puts meta.to_yaml }
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
11
36
|
end
|
12
37
|
end
|
@@ -1,7 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
module Hearken
|
4
|
+
module Command
|
5
|
+
class Reload
|
6
|
+
def initialize(library)
|
7
|
+
@library = library
|
8
|
+
end
|
9
|
+
|
10
|
+
def help
|
11
|
+
"reload the contents of the music library for fast searching"
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute(_text)
|
15
|
+
@library.reload
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,24 +1,35 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
EOF
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
matches
|
3
|
+
module Hearken
|
4
|
+
module Command
|
5
|
+
class Search
|
6
|
+
attr_reader :help
|
7
|
+
|
8
|
+
def initialize(library)
|
9
|
+
@help = <<~EOF
|
10
|
+
searches for tracks containing the specified words (in artist, title or album)
|
11
|
+
ids are placed on the clipboard for convenient use with +
|
12
|
+
EOF
|
13
|
+
@library = library
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute(text)
|
17
|
+
terms = text.split(/\W/)
|
18
|
+
matches = []
|
19
|
+
@library.tracks.each do |track|
|
20
|
+
if terms.all? { |term| track.search_string.include? term }
|
21
|
+
puts track
|
22
|
+
matches << track.search_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if matches.size < 50
|
27
|
+
IO.popen("pbcopy", "w") { |clipboard| clipboard.print matches.join " " }
|
28
|
+
puts "Found #{matches.size} matches (ids have been placed on clipboard)"
|
29
|
+
else
|
30
|
+
puts "Found #{matches.size} matches"
|
31
|
+
end
|
19
32
|
end
|
20
33
|
end
|
21
|
-
puts "Found #{matches.size} matches (ids have been placed on clipboard)"
|
22
|
-
IO.popen('pbcopy','w') { |clipboard| clipboard.print matches.join ' ' }
|
23
34
|
end
|
24
|
-
end
|
35
|
+
end
|
data/lib/hearken/console.rb
CHANGED
@@ -1,38 +1,21 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
require 'yaml'
|
3
|
+
require "hearken/command/enqueue"
|
4
|
+
require "hearken/command/reload"
|
5
|
+
require "hearken/command/search"
|
6
|
+
require "hearken/library"
|
7
|
+
require "shell_shock/context"
|
9
8
|
|
10
9
|
module Hearken
|
11
10
|
class Console
|
12
11
|
include ShellShock::Context
|
13
12
|
|
14
|
-
def with name, *aliases
|
15
|
-
aliases << name.to_s if aliases.empty?
|
16
|
-
add_command Command.load(name, @player), *aliases
|
17
|
-
end
|
18
|
-
|
19
|
-
def with_all *names
|
20
|
-
names.each {|name| with name}
|
21
|
-
end
|
22
|
-
|
23
13
|
def initialize
|
24
|
-
preferences = Preferences.new
|
25
|
-
@player = Player.new preferences
|
26
|
-
at_exit { @player.stop }
|
27
14
|
@prompt = "hearken > "
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
with :remove, 'rm', '-'
|
33
|
-
with :start, 'play', 'go'
|
34
|
-
with :search, 'find'
|
35
|
-
with_all *%w{reload stop scrobbling shuffle setup_scrobbling recent love profile}
|
15
|
+
library = Hearken::Library.new
|
16
|
+
add_command(Hearken::Command::Enqueue.new(library), "enqueue")
|
17
|
+
add_command(Hearken::Command::Reload.new(library), "reload")
|
18
|
+
add_command(Hearken::Command::Search.new(library), "search")
|
36
19
|
end
|
37
20
|
end
|
38
|
-
end
|
21
|
+
end
|
data/lib/hearken/debug.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hearken
|
2
4
|
module Debug
|
3
|
-
def debug
|
4
|
-
if ENV[
|
5
|
-
puts message
|
6
|
-
end
|
5
|
+
def debug(message)
|
6
|
+
puts message if ENV["DEBUG"]
|
7
7
|
end
|
8
8
|
|
9
9
|
def pause
|
10
|
-
if ENV[
|
10
|
+
if ENV["DEBUG"]
|
11
11
|
puts "Hit enter to continue"
|
12
12
|
gets
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -1,31 +1,39 @@
|
|
1
|
-
|
2
|
-
require 'hearken/indexing/persistant_traverser'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
require "hearken/paths"
|
4
|
+
require "hearken/indexing/persistant_traverser"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
module Hearken
|
7
|
+
module Indexing
|
8
|
+
class Indexer
|
9
|
+
include Hearken::Paths
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def initialize(path)
|
12
|
+
create_paths
|
13
|
+
@path = path
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def execute
|
17
|
+
start = Time.now
|
18
|
+
count = 0
|
19
|
+
traverser = Hearken::Indexing::PersistantTraverser.new @path, index_path
|
21
20
|
|
22
|
-
|
21
|
+
traverser.each do |_audio_file|
|
22
|
+
count += 1
|
23
|
+
show_progress start, count if (count % 1000).zero?
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
show_progress start, count
|
27
|
+
|
28
|
+
system "afplay #{File.dirname(__FILE__)}/../../../media/applause.mp3"
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def show_progress(start, count)
|
34
|
+
elapsed = Time.now - start
|
35
|
+
warn "Processed #{count} audio files in #{elapsed} seconds (#{elapsed / count} per file)"
|
36
|
+
end
|
37
|
+
end
|
30
38
|
end
|
31
|
-
end
|
39
|
+
end
|