marcato 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +23 -0
- data/README.md +58 -0
- data/marcato +16 -0
- data/marcato.rb +38 -0
- data/marcato_test.rb +16 -0
- metadata +74 -0
data/LICENSE.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) Hugh Bien
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
Redistributions of source code must retain the above copyright notice, this list
|
8
|
+
of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
Redistributions in binary form must reproduce the above copyright notice, this
|
11
|
+
list of conditions and the following disclaimer in the documentation and/or
|
12
|
+
other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
15
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
16
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
18
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
19
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
20
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
21
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
22
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
Marcato is a playlist manager for use with `mplayer`.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
============
|
8
|
+
|
9
|
+
% gem install marcato
|
10
|
+
|
11
|
+
Usage
|
12
|
+
=====
|
13
|
+
|
14
|
+
First, set any options in your `.bashrc` or `.zshrc`:
|
15
|
+
|
16
|
+
export MARCATO_MUSIC="/path/to/music"
|
17
|
+
export MARCATO_FILE="/path/to/.marcato" # defaults to ~/.marcato
|
18
|
+
export MARCATO_OPTS="--random" # optional
|
19
|
+
|
20
|
+
Playlists can be made on the fly via searching:
|
21
|
+
|
22
|
+
% marcato muse
|
23
|
+
muse_super-massive-black-hole.mp3
|
24
|
+
muse_starlight.mp3
|
25
|
+
% mplayer -playlist <(marcato muse)
|
26
|
+
|
27
|
+
Playlists are just yaml, each line is a search term:
|
28
|
+
|
29
|
+
% marcato --edit
|
30
|
+
top-songs:
|
31
|
+
- muse
|
32
|
+
- beatles
|
33
|
+
|
34
|
+
jazz:
|
35
|
+
- coltrane
|
36
|
+
- jazz-mafia
|
37
|
+
|
38
|
+
Access your playlist just like searching for a song. Marcato accepts multiple
|
39
|
+
terms/playlists:
|
40
|
+
|
41
|
+
% marcao jazz beatles
|
42
|
+
|
43
|
+
By default, the order of songs is alphabetical. Use the `--random` flag to
|
44
|
+
shuffle:
|
45
|
+
|
46
|
+
% marcato --random jazz
|
47
|
+
|
48
|
+
List out playlists with `--list`:
|
49
|
+
|
50
|
+
% marcato --list
|
51
|
+
jazz
|
52
|
+
top-songs
|
53
|
+
|
54
|
+
License
|
55
|
+
=======
|
56
|
+
|
57
|
+
Copyright (c) Hugh Bien - http://hughbien.com.
|
58
|
+
Released under BSD License, see LICENSE.md for more info.
|
data/marcato
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require File.expand_path('marcato', File.dirname(__FILE__))
|
4
|
+
|
5
|
+
OptionParser.new do |o|
|
6
|
+
@m = Marcato.new
|
7
|
+
o.set_summary_indent(' ')
|
8
|
+
o.banner = "Usage: #{File.basename($0)} [option] <song or playlist>"
|
9
|
+
o.define_head 'Playlist manager for mplayer'
|
10
|
+
o.on('-e', '--edit', 'edit playlists') { @m.edit; exit }
|
11
|
+
o.on('-l', '--list', 'list playlists') { @m.list; exit }
|
12
|
+
o.on('-r', '--random', 'play in random order') { @m.randomize! }
|
13
|
+
o.on('-h', '--help', 'show this help message') { puts o; exit }
|
14
|
+
o.parse!(ARGV + (ENV['MARCATO_OPTS'] ? ENV['MARCATO_OPTS'].split(/\s+/) : []))
|
15
|
+
@m.play(ARGV.join(' '))
|
16
|
+
end
|
data/marcato.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
class Marcato
|
5
|
+
VERSION = '0.0.2'
|
6
|
+
MARCATO_FILE = ENV['MARCATO_FILE'] || "#{ENV['HOME']}/.marcato"
|
7
|
+
MARCATO_MUSIC = File.expand_path(ENV['MARCATO_MUSIC'] || '.')
|
8
|
+
EDITOR = ENV['EDITOR'] || 'vi'
|
9
|
+
|
10
|
+
def randomize!
|
11
|
+
@random = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit
|
15
|
+
`#{EDITOR} #{MARCATO_FILE} < \`tty\` > \`tty\``
|
16
|
+
end
|
17
|
+
|
18
|
+
def list
|
19
|
+
puts playlists.keys.sort.join("\n") if !playlists.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
def play(query = '')
|
23
|
+
searches = query.split(/\s+/)
|
24
|
+
playlists.select { |k,v| searches.include?(k) }.each do |name, terms|
|
25
|
+
searches += terms
|
26
|
+
end
|
27
|
+
files = searches.map do |search|
|
28
|
+
Dir.glob(File.join(MARCATO_MUSIC, "*#{search}*"))
|
29
|
+
end.flatten.uniq
|
30
|
+
files = @random ? files.sort_by { rand } : files.sort
|
31
|
+
puts files.join("\n") if !files.empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def playlists
|
36
|
+
YAML.load(File.read(MARCATO_FILE))
|
37
|
+
end
|
38
|
+
end
|
data/marcato_test.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "#{File.dirname(__FILE__)}/marcato"
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
class MarcatoTest < MiniTest::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@m = Marcato.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_randomize
|
12
|
+
refute(@m.instance_variable_get(:@random))
|
13
|
+
@m.randomize!
|
14
|
+
assert(@m.instance_variable_get(:@random))
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: marcato
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Hugh Bien
|
9
|
+
autorequire:
|
10
|
+
bindir: .
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: &81719930 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *81719930
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mocha
|
27
|
+
requirement: &81719450 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *81719450
|
36
|
+
description: Provides a command line tool for creating playlists that work with mplayer.
|
37
|
+
email:
|
38
|
+
- hugh@hughbien.com
|
39
|
+
executables:
|
40
|
+
- marcato
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- marcato.rb
|
45
|
+
- marcato_test.rb
|
46
|
+
- README.md
|
47
|
+
- LICENSE.md
|
48
|
+
- marcato
|
49
|
+
- ./marcato
|
50
|
+
homepage: https://github.com/hughbien/marcato
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.3.6
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.15
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Playlist manager for mplayer
|
74
|
+
test_files: []
|