rupeepeethree 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +36 -0
- data/History.txt +6 -0
- data/Manifest.txt +13 -0
- data/README.md +62 -0
- data/Rakefile +16 -0
- data/bin/rp3 +5 -0
- data/lib/rupeepeethree.rb +41 -0
- data/lib/rupeepeethree/tagger.rb +65 -0
- data/lib/rupeepeethree/version.rb +3 -0
- data/rupeepeethree.gemspec +42 -0
- data/spec/fixtures/cover_art.jpg +0 -0
- data/spec/fixtures/test.mp3 +0 -0
- data/spec/rupeepeethree/tagger_spec.rb +34 -0
- data/spec/rupeepeethree_spec.rb +39 -0
- metadata +105 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.12)
|
5
|
+
i18n (~> 0.6)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
climate_control (0.0.3)
|
8
|
+
activesupport (>= 3.0)
|
9
|
+
cocaine (0.5.1)
|
10
|
+
climate_control (>= 0.0.3, < 1.0)
|
11
|
+
diff-lcs (1.2.1)
|
12
|
+
i18n (0.6.4)
|
13
|
+
mime-types (1.21)
|
14
|
+
multi_json (1.6.1)
|
15
|
+
rake (10.0.3)
|
16
|
+
rspec (2.13.0)
|
17
|
+
rspec-core (~> 2.13.0)
|
18
|
+
rspec-expectations (~> 2.13.0)
|
19
|
+
rspec-mocks (~> 2.13.0)
|
20
|
+
rspec-core (2.13.0)
|
21
|
+
rspec-expectations (2.13.0)
|
22
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
23
|
+
rspec-mocks (2.13.0)
|
24
|
+
taglib-ruby (0.5.2)
|
25
|
+
trollop (1.16.2)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
cocaine
|
32
|
+
mime-types
|
33
|
+
rake
|
34
|
+
rspec
|
35
|
+
taglib-ruby
|
36
|
+
trollop
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gemfile
|
2
|
+
Gemfile.lock
|
3
|
+
History.txt
|
4
|
+
Manifest.txt
|
5
|
+
README.md
|
6
|
+
Rakefile
|
7
|
+
bin/rupeepeethree
|
8
|
+
lib/rupeepeethree.rb
|
9
|
+
lib/rupeepeethree/version.rb
|
10
|
+
lib/rupeepeethree/tagger.rb
|
11
|
+
spec/rupeepeethree_spec.rb
|
12
|
+
spec/fixtures/cover_art.jpg
|
13
|
+
spec/fixtures/test.mp3
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# rupeepeethree
|
2
|
+
|
3
|
+
http://github.com/datafruits/rupeepeethree
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
[![Build Status](https://secure.travis-ci.org/datafruits/rupeepeethree.png?branch=master)](http://travis-ci.org/datafruits/rupeepeethree)
|
8
|
+
|
9
|
+
tag your mp3 files. a command line wrapper around taglib-ruby.
|
10
|
+
|
11
|
+
## FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
* a dumb name
|
14
|
+
* probably works
|
15
|
+
* has tests
|
16
|
+
* easier to change the album art than eyeD3
|
17
|
+
|
18
|
+
## SYNOPSIS:
|
19
|
+
|
20
|
+
`rp3 -t "a cool song about pineapples" -p ~/pics/pineapple_tshirt.png pineapple_fortress.mp3`
|
21
|
+
|
22
|
+
## REQUIREMENTS:
|
23
|
+
|
24
|
+
* taglib
|
25
|
+
|
26
|
+
## INSTALL:
|
27
|
+
|
28
|
+
* gem install rupeepeethree
|
29
|
+
|
30
|
+
## DEVELOPERS:
|
31
|
+
|
32
|
+
After checking out the source, run:
|
33
|
+
|
34
|
+
$ rake newb
|
35
|
+
|
36
|
+
This task will install any missing dependencies, run the tests/specs,
|
37
|
+
and generate the RDoc.
|
38
|
+
|
39
|
+
## LICENSE:
|
40
|
+
|
41
|
+
(The MIT License)
|
42
|
+
|
43
|
+
Copyright (c) 2013
|
44
|
+
|
45
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
46
|
+
a copy of this software and associated documentation files (the
|
47
|
+
'Software'), to deal in the Software without restriction, including
|
48
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
49
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
50
|
+
permit persons to whom the Software is furnished to do so, subject to
|
51
|
+
the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be
|
54
|
+
included in all copies or substantial portions of the Software.
|
55
|
+
|
56
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
57
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
58
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
59
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
60
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
61
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
62
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "hoe"
|
5
|
+
|
6
|
+
Hoe.plugin :gemspec
|
7
|
+
|
8
|
+
Hoe.spec "rupeepeethree" do
|
9
|
+
developer("Tony Miller", "mcfiredrill@gmail.com")
|
10
|
+
|
11
|
+
# self.rubyforge_name = "rupeepeethreex" # if different than "rupeepeethree"
|
12
|
+
|
13
|
+
license "MIT" # this should match the license in the README
|
14
|
+
end
|
15
|
+
|
16
|
+
# vim: syntax=ruby
|
data/bin/rp3
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rupeepeethree/tagger'
|
3
|
+
require 'rupeepeethree/version'
|
4
|
+
require 'trollop'
|
5
|
+
|
6
|
+
class Rupeepeethree
|
7
|
+
def self.run(args)
|
8
|
+
p = Trollop::Parser.new do
|
9
|
+
version "RP3 version #{VERSION} by Tony Miller"
|
10
|
+
banner <<-EOS
|
11
|
+
░█▀▄░█▀█░▀▀█
|
12
|
+
░█▀▄░█▀▀░░▀▄
|
13
|
+
░▀░▀░▀░░░▀▀░
|
14
|
+
┣¨キ┣¨キ
|
15
|
+
You thought your mp3s were cool. Turns out you were wrong. Your mp3s have no tags. You must tag them!
|
16
|
+
EOS
|
17
|
+
opt :title, "title", type: String, short: 't'
|
18
|
+
opt :artist, "artist", type: String, short: 'a'
|
19
|
+
opt :year, "track year", type: String, short: 'Y'
|
20
|
+
opt :album, "album title", type: String, short: 'A'
|
21
|
+
opt :picture, "artwork", type: String, short: 'p'
|
22
|
+
opt :clear, "clear all tags!"
|
23
|
+
end
|
24
|
+
|
25
|
+
opts = Trollop::with_standard_exception_handling p do
|
26
|
+
raise Trollop::HelpNeeded if ARGV.empty? # show help screen
|
27
|
+
p.parse ARGV
|
28
|
+
end
|
29
|
+
|
30
|
+
mp3 = ARGV[0]
|
31
|
+
if mp3.nil?
|
32
|
+
abort("no mp3 specified...")
|
33
|
+
end
|
34
|
+
if opts[:clear]
|
35
|
+
Tagger.clear(mp3)
|
36
|
+
else
|
37
|
+
Tagger.tag(mp3,opts)
|
38
|
+
puts Tagger.print_tags(mp3)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'taglib'
|
2
|
+
require 'mime/types'
|
3
|
+
|
4
|
+
class Tagger
|
5
|
+
def self.tag(mp3,tags)
|
6
|
+
TagLib::MPEG::File.open(mp3) do |f|
|
7
|
+
t = f.id3v2_tag || TagLib::ID3v2::Tag.new
|
8
|
+
if tags[:title]
|
9
|
+
t.title = tags[:title]
|
10
|
+
end
|
11
|
+
if tags[:artist]
|
12
|
+
t.artist = tags[:artist]
|
13
|
+
end
|
14
|
+
if tags[:album]
|
15
|
+
t.album = tags[:album]
|
16
|
+
end
|
17
|
+
if tags[:year]
|
18
|
+
t.year = tags[:year].to_i
|
19
|
+
end
|
20
|
+
if tags[:picture]
|
21
|
+
image_file = File.expand_path(tags[:picture])
|
22
|
+
# delete old frame if it exists
|
23
|
+
cover = t.frame_list('APIC').first
|
24
|
+
if cover
|
25
|
+
t.remove_frame(cover)
|
26
|
+
end
|
27
|
+
cover = TagLib::ID3v2::AttachedPictureFrame.new
|
28
|
+
cover.mime_type = mime_type(image_file)
|
29
|
+
cover.type = TagLib::ID3v2::AttachedPictureFrame::FrontCover
|
30
|
+
cover.picture = File.open(image_file,"rb"){|f|f.read}
|
31
|
+
t.add_frame(cover)
|
32
|
+
end
|
33
|
+
f.save
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# clear all tags
|
38
|
+
def self.clear(mp3)
|
39
|
+
TagLib::MPEG::File.open(mp3) do |f|
|
40
|
+
f.strip
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.print_tags(mp3)
|
45
|
+
result = ""
|
46
|
+
TagLib::MPEG::File.open(mp3) do |f|
|
47
|
+
t = f.id3v2_tag
|
48
|
+
|
49
|
+
result << "title: #{t.title}\n"
|
50
|
+
result << "artist: #{t.artist}\n"
|
51
|
+
result << "album: #{t.album}\n"
|
52
|
+
result << "year: #{t.year}\n"
|
53
|
+
|
54
|
+
t.frame_list('APIC').each do |cover|
|
55
|
+
result << "image: [#{cover.mime_type}] [#{cover.picture.length} bytes]\n"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
return result
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def self.mime_type(file)
|
63
|
+
MIME::Types.type_for(file).to_s
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'rupeepeethree/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "rupeepeethree"
|
9
|
+
s.version = Rupeepeethree::VERSION
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Tony Miller"]
|
13
|
+
s.date = "2013-03-14"
|
14
|
+
s.description = "tag your mp3 files. a command line wrapper around taglib-ruby."
|
15
|
+
s.email = ["mcfiredrill@gmail.com"]
|
16
|
+
s.executables = ["rp3"]
|
17
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.homepage = "http://github.com/datafruits/rupeepeethree"
|
21
|
+
s.licenses = ["MIT"]
|
22
|
+
s.rdoc_options = ["--main", "README.md"]
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
s.rubyforge_project = "rupeepeethree"
|
25
|
+
s.rubygems_version = "1.8.25"
|
26
|
+
s.summary = "tag your mp3 files"
|
27
|
+
|
28
|
+
if s.respond_to? :specification_version then
|
29
|
+
s.specification_version = 3
|
30
|
+
|
31
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
32
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.10"])
|
33
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.5"])
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
36
|
+
s.add_dependency(%q<hoe>, ["~> 3.5"])
|
37
|
+
end
|
38
|
+
else
|
39
|
+
s.add_dependency(%q<rdoc>, ["~> 3.10"])
|
40
|
+
s.add_dependency(%q<hoe>, ["~> 3.5"])
|
41
|
+
end
|
42
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require './lib/rupeepeethree/tagger'
|
2
|
+
|
3
|
+
describe Tagger do
|
4
|
+
let(:mp3) { 'spec/fixtures/test.mp3' }
|
5
|
+
before :each do
|
6
|
+
Tagger.clear(mp3)
|
7
|
+
end
|
8
|
+
it "edits the existing cover art frame instead of creating a new one" do
|
9
|
+
tags = {picture: "spec/fixtures/cover_art.jpg"}
|
10
|
+
image_string = /image: \[\[image\/jpeg\]\] \[59562 bytes\]\n/
|
11
|
+
Tagger.tag(mp3, tags)
|
12
|
+
result = Tagger.print_tags(mp3)
|
13
|
+
result.should match(image_string)
|
14
|
+
|
15
|
+
Tagger.tag(mp3, tags)
|
16
|
+
result = Tagger.print_tags(mp3)
|
17
|
+
result.should_not match(/#{image_string}{2}/)
|
18
|
+
end
|
19
|
+
it "clears the tags" do
|
20
|
+
tags = {title: "foodfight",
|
21
|
+
artist: "ninjaturtle",
|
22
|
+
album: "purplerain",
|
23
|
+
year: "1987",
|
24
|
+
picture: "spec/fixtures/cover_art.jpg"}
|
25
|
+
Tagger.tag(mp3, tags)
|
26
|
+
Tagger.clear(mp3)
|
27
|
+
result = Tagger.print_tags(mp3)
|
28
|
+
result.should match(/title: \n/)
|
29
|
+
result.should match(/artist: \n/)
|
30
|
+
result.should match(/album: \n/)
|
31
|
+
result.should match(/year: 0\n/)
|
32
|
+
result.should_not match(/image:/)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "rupeepeethree"
|
2
|
+
require "cocaine"
|
3
|
+
|
4
|
+
describe Rupeepeethree do
|
5
|
+
before :all do
|
6
|
+
@rp3 = "ruby -Ilib bin/rp3"
|
7
|
+
end
|
8
|
+
before :each do
|
9
|
+
# clear tags
|
10
|
+
line = Cocaine::CommandLine.new(@rp3, "-c :mp3")
|
11
|
+
line.run(mp3: "spec/fixtures/test.mp3")
|
12
|
+
end
|
13
|
+
it "sets a title tag" do
|
14
|
+
line = Cocaine::CommandLine.new(@rp3, "-t :title :mp3")
|
15
|
+
result = line.run(title: "foodfight", mp3: "spec/fixtures/test.mp3")
|
16
|
+
result.should match(/foodfight/)
|
17
|
+
end
|
18
|
+
it "sets an artist tag" do
|
19
|
+
line = Cocaine::CommandLine.new(@rp3, "-a :artist :mp3")
|
20
|
+
result = line.run(artist: "ninjaturtle", mp3: "spec/fixtures/test.mp3")
|
21
|
+
result.should match(/ninjaturtle/)
|
22
|
+
end
|
23
|
+
it "sets an album tag" do
|
24
|
+
line = Cocaine::CommandLine.new(@rp3, "-A :album :mp3")
|
25
|
+
result = line.run(album: "purplerain", mp3: "spec/fixtures/test.mp3")
|
26
|
+
result.should match(/purplerain/)
|
27
|
+
end
|
28
|
+
it "sets a year tag" do
|
29
|
+
line = Cocaine::CommandLine.new(@rp3, "-Y :year :mp3")
|
30
|
+
result = line.run(year: "1987", mp3: "spec/fixtures/test.mp3")
|
31
|
+
result.should match(/1987/)
|
32
|
+
end
|
33
|
+
it "sets album art tag" do
|
34
|
+
line = Cocaine::CommandLine.new(@rp3, "-p :pic :mp3")
|
35
|
+
result = line.run(pic: "spec/fixtures/cover_art.jpg", mp3: "spec/fixtures/test.mp3")
|
36
|
+
result.should match(/image\/jpeg/)
|
37
|
+
result.should match(/59562 bytes/)
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rupeepeethree
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tony Miller
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.10'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hoe
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.5'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.5'
|
46
|
+
description: tag your mp3 files. a command line wrapper around taglib-ruby.
|
47
|
+
email:
|
48
|
+
- mcfiredrill@gmail.com
|
49
|
+
executables:
|
50
|
+
- rp3
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- History.txt
|
54
|
+
- Manifest.txt
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- .travis.yml
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
60
|
+
- History.txt
|
61
|
+
- Manifest.txt
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- bin/rp3
|
65
|
+
- lib/rupeepeethree.rb
|
66
|
+
- lib/rupeepeethree/tagger.rb
|
67
|
+
- lib/rupeepeethree/version.rb
|
68
|
+
- rupeepeethree.gemspec
|
69
|
+
- spec/fixtures/cover_art.jpg
|
70
|
+
- spec/fixtures/test.mp3
|
71
|
+
- spec/rupeepeethree/tagger_spec.rb
|
72
|
+
- spec/rupeepeethree_spec.rb
|
73
|
+
homepage: http://github.com/datafruits/rupeepeethree
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --main
|
79
|
+
- README.md
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project: rupeepeethree
|
96
|
+
rubygems_version: 1.8.25
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: tag your mp3 files
|
100
|
+
test_files:
|
101
|
+
- spec/fixtures/cover_art.jpg
|
102
|
+
- spec/fixtures/test.mp3
|
103
|
+
- spec/rupeepeethree/tagger_spec.rb
|
104
|
+
- spec/rupeepeethree_spec.rb
|
105
|
+
has_rdoc:
|