krate 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ID3Tag.rb +11 -0
- data/lib/Krate.rb +35 -0
- metadata +47 -0
data/lib/ID3Tag.rb
ADDED
data/lib/Krate.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Krate
|
2
|
+
require_relative './ID3Tag.rb'
|
3
|
+
require "FileUtils"
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def self.run
|
8
|
+
success_count = 0
|
9
|
+
fail_count = 0
|
10
|
+
total_count = 0
|
11
|
+
Dir.glob('*.mp3') do |song|
|
12
|
+
file = File.new(song)
|
13
|
+
file.seek(-128, IO::SEEK_END)
|
14
|
+
tags = file.read
|
15
|
+
tag_array = tags.unpack ("A3A30A30A30A4A30C1")
|
16
|
+
tag = ID3Tag.new(tag_array[1], tag_array[2])
|
17
|
+
artist = tag.artist
|
18
|
+
title = tag.title
|
19
|
+
file.close
|
20
|
+
if !title.strip.empty? && !artist.strip.empty?
|
21
|
+
File.rename(song, "#{title} - #{artist}.mp3")
|
22
|
+
success_count = success_count + 1
|
23
|
+
else
|
24
|
+
FileUtils.mv(song, "Not_Renamed")
|
25
|
+
fail_count = fail_count + 1
|
26
|
+
end
|
27
|
+
total_count = (fail_count + success_count)
|
28
|
+
end
|
29
|
+
return total_count
|
30
|
+
print "There was a total of #{total_count} file(s) processed. Successfully renamed #{success_count} file(s) and moved #{fail_count} file(s) to be looked at."
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: krate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Emory Christenson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-03-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: DJ crate organizing tool
|
15
|
+
email: never1ess@hotmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/Krate.rb
|
21
|
+
- lib/ID3Tag.rb
|
22
|
+
homepage: http://rubygems.org/gems/krate
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.28
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Hola!
|
47
|
+
test_files: []
|