mp3filename 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/mp3filename.rb +12 -9
  3. metadata +12 -16
  4. data/README +0 -56
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2e6491e2f904fbe1e64ace837e6ea0c86697e319
4
+ data.tar.gz: d81b60bfc7943b8d28ac5e1e890d84818a9019bd
5
+ SHA512:
6
+ metadata.gz: 6cdade8f284b9d8c48a481e9e13281eee908e22c8277df659774590a2cedfc92ee89d7ae893d821d00c251c1220af43cf7d38022dcae15392f19ba04dbdee142
7
+ data.tar.gz: 4d8cfd0bd0dc38f9bce95c41ec4b32fed559245c26223dcc0adf7385363cf3855dbb5583f5bbe82a21dac63eacb76f477b6b555b345255080d7e29e41075bd11
data/lib/mp3filename.rb CHANGED
@@ -3,25 +3,28 @@ require 'mp3info'
3
3
  class Mp3Error < StandardError; end;
4
4
 
5
5
  class Mp3FileName
6
- VERSION = "1.0.0"
6
+ VERSION = "1.0.3"
7
7
 
8
8
  def initialize(path)
9
9
  @path = path
10
10
  end
11
11
 
12
12
  def change
13
- Dir["#{@path}/*.mp3"].each do |file|
14
- Mp3Info.open(file) do |mp3|
15
- title = mp3.tag.title
16
- title ||= ""
17
- file_name = title.empty? ? file.gsub(/^\d*_*/,'') : "#{title}.mp3"
13
+ Dir["#{@path}/*.mp3"].each do |old_file_name|
14
+ Mp3Info.open(old_file_name) do |mp3|
15
+ new_file_name = convert_file_name(mp3, old_file_name)
18
16
  begin
19
- FileUtils.mv("#{file}", file_name)
20
- puts "File Name changed to : #{file_name}"
21
- rescue
17
+ FileUtils.mv("#{old_file_name}", "#{@path}/#{new_file_name}.mp3")
18
+ puts "'#{old_file_name.split('/')[-1]}' changed to '#{new_file_name}.mp3'"
19
+ rescue
22
20
  next
23
21
  end
24
22
  end
25
23
  end
26
24
  end
25
+
26
+ def convert_file_name(mp3, file)
27
+ file_name = mp3.tag.title ? "#{mp3.tag.title}" : file.split('.mp3')[0]
28
+ file_name.gsub(/[\d_\-\[\]]/,'').gsub(/(\w+\.)+\w+/,'').strip
29
+ end
27
30
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mp3filename
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Manoj Mishra
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ruby-mp3info
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Mp3 File Name is a utility to rename mp3 files to their title
@@ -34,31 +31,30 @@ executables:
34
31
  extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
- - README
38
- - lib/mp3filename.rb
39
34
  - bin/mp3filename
35
+ - lib/mp3filename.rb
40
36
  homepage: https://github.com/railsfreak/mp3filename
41
- licenses: []
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
42
40
  post_install_message:
43
41
  rdoc_options: []
44
42
  require_paths:
45
43
  - lib
46
44
  required_ruby_version: !ruby/object:Gem::Requirement
47
- none: false
48
45
  requirements:
49
- - - ! '>='
46
+ - - ">="
50
47
  - !ruby/object:Gem::Version
51
48
  version: '0'
52
49
  required_rubygems_version: !ruby/object:Gem::Requirement
53
- none: false
54
50
  requirements:
55
- - - ! '>='
51
+ - - ">="
56
52
  - !ruby/object:Gem::Version
57
53
  version: '0'
58
54
  requirements: []
59
55
  rubyforge_project:
60
- rubygems_version: 1.8.24
56
+ rubygems_version: 2.2.2
61
57
  signing_key:
62
- specification_version: 3
58
+ specification_version: 4
63
59
  summary: Mp3 File Name is a utility to rename mp3 files to their title
64
60
  test_files: []
data/README DELETED
@@ -1,56 +0,0 @@
1
- = mp3filename
2
-
3
- http://www.github.com/railsfreak/mp3filename
4
-
5
- == DESCRIPTION:
6
-
7
- Mp3FileName is a utility to rename all mp3 files in a directory to their title.
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- % mp3filename <directory_path>
12
-
13
- == SYNOPSIS:
14
-
15
-
16
- == REQUIREMENTS:
17
-
18
- ruby-mp3info
19
-
20
- == INSTALL:
21
-
22
- sudo gem install mp3filename
23
-
24
- == DEVELOPERS:
25
-
26
- After checking out the source, run:
27
-
28
- $ rake newb
29
-
30
- This task will install any missing dependencies, run the tests/specs,
31
- and generate the RDoc.
32
-
33
- == LICENSE:
34
-
35
- (The MIT License)
36
-
37
- Copyright (c) 2013 FIX
38
-
39
- Permission is hereby granted, free of charge, to any person obtaining
40
- a copy of this software and associated documentation files (the
41
- 'Software'), to deal in the Software without restriction, including
42
- without limitation the rights to use, copy, modify, merge, publish,
43
- distribute, sublicense, and/or sell copies of the Software, and to
44
- permit persons to whom the Software is furnished to do so, subject to
45
- the following conditions:
46
-
47
- The above copyright notice and this permission notice shall be
48
- included in all copies or substantial portions of the Software.
49
-
50
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.