gramola 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/afplay_itunes_vox_activity_monitor.png +0 -0
- data/bin/gramola +6 -0
- data/gramola.gemspec +25 -0
- data/lib/gramola.rb +84 -0
- data/lib/gramola/version.rb +3 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac8775ad930733ce76fb21705346e6ec95855f6d
|
4
|
+
data.tar.gz: 88e15460e79d0abd31f228773b7ff6c623de4867
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d453280f776656eaa5badd1ee9712848903a3260da61ae974c729f8acbc4ec135e2e39005065d589a60ba01447f605cf323655125fae9f4709c2a77265f2b5d
|
7
|
+
data.tar.gz: f52efbaf46c8c85ad05feeca188c6864ab89b840b623fa0a843f84b3d385821326888557b8791f1a730ea0be4cf3b77365d69ef8cc1c407d5b587eeccbdbf039
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Lucas Andión
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Gramola
|
2
|
+
|
3
|
+
Gramola is a command-line script to call afplay on your Music collection
|
4
|
+
under ~/Music from your mac's Terminal.
|
5
|
+
|
6
|
+
I love my ipod shuffle. No screen, no hassle, just play some music.
|
7
|
+
|
8
|
+
Gramola is just like that. Just run gramola and all your mp3's under your
|
9
|
+
~/Music folder will be played in shuffle mode. You can also add search keywords
|
10
|
+
or play them on list mode.
|
11
|
+
|
12
|
+
Simple and battery friendly.
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
|
16
|
+
OSX 10.5+
|
17
|
+
|
18
|
+
# Run:'ruby gramola.rb' or do once 'chmod +x gramola.rb' and then exec with './gramola.rb'
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
$ gem install gramola
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
$ gramola -h
|
28
|
+
Usage: gramola.rb [-l] [keyword ...]. Shuffles all *.mp3 under ~/Music by default.
|
29
|
+
-l, --list Play the files in order
|
30
|
+
-h, --help Show this message
|
31
|
+
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
Binary file
|
data/bin/gramola
ADDED
data/gramola.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gramola/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gramola"
|
8
|
+
spec.version = Gramola::VERSION
|
9
|
+
spec.authors = ["Lucas Andión"]
|
10
|
+
spec.email = ["andion@gmail.com"]
|
11
|
+
spec.description = %q{Hassle-free, battery friendly mp3 player for your mac}
|
12
|
+
spec.summary = %q{Gramola is a command-line script to call afplay on your Music collection
|
13
|
+
under ~/Music from your mac's Terminal}
|
14
|
+
spec.homepage = "https://github.com/andion/gramola"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
spec.executables = ['gramola']
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
data/lib/gramola.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#
|
2
|
+
# GRAMOLA: shuffle play all the mp3 files under your '/Music'
|
3
|
+
# folder using afplay (OSX 10.5+ only)
|
4
|
+
#
|
5
|
+
# Many features xD:
|
6
|
+
# "Background mode": './gramola.rb &'
|
7
|
+
# Pause: Ctrl-Z or 'fg' + Crl-Z if background
|
8
|
+
# Resume: 'fg'
|
9
|
+
# Play specific groups/keywords: './gramola.rb 'Group name' Keyword 'Other group'
|
10
|
+
# Non-shuffle option: -l
|
11
|
+
#
|
12
|
+
#
|
13
|
+
require "gramola/version"
|
14
|
+
|
15
|
+
module Gramola
|
16
|
+
require 'optparse'
|
17
|
+
require 'shellwords'
|
18
|
+
|
19
|
+
MUSIC_FOLDER='Music'
|
20
|
+
MUSIC_EXTENSIONS='*{.mp3}'
|
21
|
+
|
22
|
+
class Player
|
23
|
+
|
24
|
+
def initialize(argv)
|
25
|
+
@shuffle = true #default
|
26
|
+
parse_options(argv)
|
27
|
+
@files = Dir[File.join(Dir.home,MUSIC_FOLDER,'**',MUSIC_EXTENSIONS)]
|
28
|
+
@songs = filter_by_groups(@files,@groups)
|
29
|
+
@length = get_total_length(@songs)
|
30
|
+
end
|
31
|
+
|
32
|
+
def info
|
33
|
+
"Playing #{@songs.size} songs for about #{print_length(@length)} in #{shuffle_info}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def play
|
37
|
+
(@shuffle ? @songs.shuffle : @songs).each{|s| `afplay "#{s}"`} #Main script function
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def parse_options(argv)
|
43
|
+
parser = OptionParser.new do |opts|
|
44
|
+
opts.banner = "Usage: gramola.rb [-l] [file ...]. Shuffles all *.mp3 under ~/Music by default."
|
45
|
+
opts.on('-l', '--list', "Play the files in order") {@shuffle = false}
|
46
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
47
|
+
puts opts
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
@groups = opts.parse!
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def shuffle_info
|
55
|
+
@shuffle ? "shuffle mode" : "list mode"
|
56
|
+
end
|
57
|
+
|
58
|
+
def filter_by_groups(files,groups)
|
59
|
+
if groups.any?
|
60
|
+
groups = groups.map &:downcase
|
61
|
+
files.select{|f| f.downcase =~ Regexp.new("#{groups * '|' }") }
|
62
|
+
else
|
63
|
+
files
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns total lenght of the +files+ in seconds.
|
68
|
+
def get_total_length(filenames)
|
69
|
+
shell_formatted_filenames = Shellwords.join filenames
|
70
|
+
res = `afinfo -b #{shell_formatted_filenames}` # total info
|
71
|
+
length = 0
|
72
|
+
res.lines{|l| length = length + l.split.first.to_f if l.split.first.to_f}
|
73
|
+
length
|
74
|
+
end
|
75
|
+
|
76
|
+
def print_length(seconds)
|
77
|
+
m, s = seconds.divmod(60)
|
78
|
+
h, m = m.divmod(60)
|
79
|
+
d, h = h.divmod(24)
|
80
|
+
[d > 0 ? ("%d day" % d) : nil, h > 0 ? ("%d hours" % h) : nil,
|
81
|
+
m ? ("%d minutes" % m) : ("%d seconds... Orly?")].compact * ' '
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gramola
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lucas Andión
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Hassle-free, battery friendly mp3 player for your mac
|
42
|
+
email:
|
43
|
+
- andion@gmail.com
|
44
|
+
executables:
|
45
|
+
- gramola
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .DS_Store
|
50
|
+
- .gitignore
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- afplay_itunes_vox_activity_monitor.png
|
56
|
+
- bin/gramola
|
57
|
+
- gramola.gemspec
|
58
|
+
- lib/gramola.rb
|
59
|
+
- lib/gramola/version.rb
|
60
|
+
homepage: https://github.com/andion/gramola
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.3
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Gramola is a command-line script to call afplay on your Music collection
|
84
|
+
under ~/Music from your mac's Terminal
|
85
|
+
test_files: []
|