track_list 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/tracklist +33 -0
- data/lib/track_list.rb +29 -0
- data/lib/track_list/directory_parser.rb +31 -0
- data/lib/track_list/time_converter.rb +22 -0
- data/lib/track_list/track_parser.rb +28 -0
- data/lib/track_list/version.rb +3 -0
- data/track_list.gemspec +34 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 19ccf4d5c9f27359f814c7f0eedc6e7da542776f76ed93ba750a8ed8c9a6ae60
|
4
|
+
data.tar.gz: ca406f21d8aa70b501ca11cbfb02c1dc56cc45a4524f229dfa52d55a4cd0a33b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dc08e75b5820ac67bbdb6e35ea3eca637288cef65894d0af55d0e5e761a0dcedcdc6f203b4fc37c9607284631bc64e6154df4643ae46142978b6d7bd956c3e4
|
7
|
+
data.tar.gz: a285701de7d1442e70d64a3e7e784112c893d27c94c40d8ff6524e02cad2c81c208184482841aa35b3e84305d6220e3210c86d7b83d58115766ef0b180ea336d
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.1.0] - 2019-08-08
|
8
|
+
### Added
|
9
|
+
- Separation of concerns compared to old codebase. Current codebase is cleaner.
|
10
|
+
-- TrackParser class that parses a single track.
|
11
|
+
-- DirectoryParser class that parses a directory, using TrackParser.
|
12
|
+
-- TimeConverter class that puts seconds into hour:minute:seconds for easy readability on track lengths.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
track_list (0.1.0)
|
5
|
+
taglib-ruby (~> 0.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (10.5.0)
|
11
|
+
taglib-ruby (0.7.1)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 2.0)
|
18
|
+
rake (~> 10.0)
|
19
|
+
taglib-ruby
|
20
|
+
track_list!
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Domenic Fiore
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# TrackList
|
2
|
+
|
3
|
+
This program aims to provide an easy way to get a tracklist for an album in your terminal, or you could use it in your own program if you wish. At the moment, there is a pre-defined format that should work for importing tracklists into MusicBrainz easily. Customizable output is a future goal of this project.
|
4
|
+
|
5
|
+
## Sample Output
|
6
|
+
```
|
7
|
+
1. Tellin' Lies (0:03:59)
|
8
|
+
2. Thick as Thieves (0:03:15)
|
9
|
+
3. Lookers (0:03:37)
|
10
|
+
4. Midwestern States (0:03:27)
|
11
|
+
5. Charlie's Army (0:02:31)
|
12
|
+
6. House on Fire (0:03:37)
|
13
|
+
7. Black Mass (0:02:52)
|
14
|
+
8. Boy Blue (0:03:20)
|
15
|
+
9. Bad Catholics (0:02:52)
|
16
|
+
10. Your Wild Years (0:03:54)
|
17
|
+
11. The Bars (0:04:11)
|
18
|
+
12. After the Party (0:03:50)
|
19
|
+
13. Livin' Ain't Easy (0:03:26)
|
20
|
+
```
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
First, install [TagLib](https://taglib.org/).
|
25
|
+
|
26
|
+
Homebrew: `brew install taglib`
|
27
|
+
|
28
|
+
Ubuntu/Debian: `sudo apt install libtag1-dev`
|
29
|
+
|
30
|
+
Arch: `sudo pacman -S taglib`
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem 'track_list'
|
36
|
+
```
|
37
|
+
|
38
|
+
And then execute:
|
39
|
+
|
40
|
+
$ bundle
|
41
|
+
|
42
|
+
Or install it yourself as:
|
43
|
+
|
44
|
+
$ gem install ruby-tracklist
|
45
|
+
|
46
|
+
|
47
|
+
## Usage
|
48
|
+
|
49
|
+
`tracklist <album directory>`
|
50
|
+
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/DomenicF/track_list/issues.
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "track_list"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/tracklist
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "track_list"
|
4
|
+
require 'getoptlong'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
opts = GetoptLong.new(
|
13
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
|
14
|
+
)
|
15
|
+
|
16
|
+
|
17
|
+
opts.each do |opt, arg|
|
18
|
+
case opt
|
19
|
+
when '--help'
|
20
|
+
puts <<-EOF
|
21
|
+
Usage: tracklist <album-directory>
|
22
|
+
e.g. tracklist "Music/The Menzingers/After the Party"
|
23
|
+
|
24
|
+
-h, --help:
|
25
|
+
show help
|
26
|
+
EOF
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if ARGV.length != 1
|
31
|
+
puts "Missing album directory (try --help)"
|
32
|
+
exit 0
|
33
|
+
end
|
data/lib/track_list.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "track_list/version"
|
2
|
+
require 'track_list/track_parser'
|
3
|
+
require 'track_list/directory_parser'
|
4
|
+
require 'track_list/time_converter'
|
5
|
+
|
6
|
+
module TrackList
|
7
|
+
class Error < StandardError; end
|
8
|
+
# Your code goes here...
|
9
|
+
end
|
10
|
+
|
11
|
+
dir = TrackList::DirectoryParser.new(ARGV[0])
|
12
|
+
|
13
|
+
dir.parse.each do |track|
|
14
|
+
puts track.parse if track.parse.is_a? String
|
15
|
+
end
|
16
|
+
|
17
|
+
# dir_file_list = dir.list
|
18
|
+
|
19
|
+
# tracks = []
|
20
|
+
|
21
|
+
# dir_file_list.each do |n|
|
22
|
+
# tracks.push(TrackList::TrackParser.new(n))
|
23
|
+
# end
|
24
|
+
|
25
|
+
# tracks.each do |track|
|
26
|
+
# #p track.parse
|
27
|
+
# end
|
28
|
+
|
29
|
+
# dir.parse
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'track_list/track_parser'
|
2
|
+
|
3
|
+
module TrackList
|
4
|
+
class DirectoryParser
|
5
|
+
def initialize(dir)
|
6
|
+
@dir = dir
|
7
|
+
end
|
8
|
+
|
9
|
+
def list
|
10
|
+
files = []
|
11
|
+
Dir.foreach(@dir) do |file|
|
12
|
+
files.push(@dir + '/' + file)
|
13
|
+
end
|
14
|
+
return files
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse
|
18
|
+
files = self.list.sort
|
19
|
+
parsed_tracks = []
|
20
|
+
files.each do |filename, index|
|
21
|
+
track = TrackList::TrackParser.new(filename)
|
22
|
+
if track != nil || track != ''
|
23
|
+
parsed_tracks.push(track)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return parsed_tracks
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module TrackList
|
2
|
+
class TimeConverter
|
3
|
+
def initialize(time)
|
4
|
+
@time = time
|
5
|
+
end
|
6
|
+
|
7
|
+
# https://www.codethought.com/2010/01/seconds-minutes-hours-converting-time-units-in-ruby/
|
8
|
+
def format_time
|
9
|
+
#find the seconds
|
10
|
+
seconds = @time % 60
|
11
|
+
|
12
|
+
#find the minutes
|
13
|
+
minutes = (@time / 60) % 60
|
14
|
+
|
15
|
+
#find the hours
|
16
|
+
hours = (@time / 3600)
|
17
|
+
|
18
|
+
#format the time
|
19
|
+
return hours.to_s + ":" + format("%02d", minutes.to_s) + ":" + format("%02d", seconds.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'taglib'
|
2
|
+
require 'track_list/time_converter'
|
3
|
+
|
4
|
+
module TrackList
|
5
|
+
class TrackParser
|
6
|
+
|
7
|
+
def initialize(track)
|
8
|
+
@track = track
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse
|
12
|
+
TagLib::FileRef.open(@track) do |fileref|
|
13
|
+
unless fileref.null?
|
14
|
+
tag = fileref.tag
|
15
|
+
properties = fileref.audio_properties
|
16
|
+
time_conversion = TrackList::TimeConverter.new(properties.length)
|
17
|
+
length = time_conversion.format_time
|
18
|
+
|
19
|
+
#@tracks[tag.track] = "#{tag.track}. #{tag.title} (#{length})"
|
20
|
+
|
21
|
+
parsed_string = "#{tag.track}. #{tag.title} (#{length})"
|
22
|
+
return parsed_string
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/track_list.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "track_list/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "track_list"
|
7
|
+
spec.version = TrackList::VERSION
|
8
|
+
spec.authors = ["Domenic Fiore"]
|
9
|
+
spec.email = ["domenicfiore@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Get the tracklist of a directory.}
|
12
|
+
spec.description = %q{Output the tracklist of an album from a directory.}
|
13
|
+
spec.homepage = "https://gitlab.com/DomenicF/track_list"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://gitlab.com/DomenicF/track_list"
|
20
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "bin"
|
28
|
+
spec.executables = ["tracklist"]
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_dependency "taglib-ruby", "~> 0.7"
|
32
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: track_list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Domenic Fiore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: taglib-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Output the tracklist of an album from a directory.
|
56
|
+
email:
|
57
|
+
- domenicfiore@gmail.com
|
58
|
+
executables:
|
59
|
+
- tracklist
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- CHANGELOG.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- bin/tracklist
|
73
|
+
- lib/track_list.rb
|
74
|
+
- lib/track_list/directory_parser.rb
|
75
|
+
- lib/track_list/time_converter.rb
|
76
|
+
- lib/track_list/track_parser.rb
|
77
|
+
- lib/track_list/version.rb
|
78
|
+
- track_list.gemspec
|
79
|
+
homepage: https://gitlab.com/DomenicF/track_list
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata:
|
83
|
+
allowed_push_host: https://rubygems.org
|
84
|
+
homepage_uri: https://gitlab.com/DomenicF/track_list
|
85
|
+
source_code_uri: https://gitlab.com/DomenicF/track_list
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubygems_version: 3.0.4
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Get the tracklist of a directory.
|
105
|
+
test_files: []
|