r2mp3 0.2.2 → 0.3.1.1718288953
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/.DS_Store +0 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +19 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README +27 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/inspector/mp3inspector.rb +90 -0
- data/lib/r2mp3/base.rb +2 -2
- data/lib/r2mp3/converter.rb +10 -121
- data/lib/r2mp3/inspector.rb +10 -31
- data/lib/r2mp3/tool.rb +3 -0
- data/lib/r2mp3/version.rb +5 -5
- data/lib/r2mp3.rb +9 -20
- data/r2mp3/.DS_Store +0 -0
- data/r2mp3/boot.rb +3 -0
- data/r2mp3/dependencies.rb +7 -0
- data/r2mp3/lib/.DS_Store +0 -0
- data/r2mp3/lib/adapter.rb +8 -0
- data/r2mp3/lib/base-utils.rb +2 -0
- data/r2mp3/lib/converter-utils.rb +238 -0
- data/r2mp3/lib/mplayer_adapter.rb +23 -0
- data/r2mp3/lib/tools/lame.rb +0 -0
- data/r2mp3/lib/tools/mplayer.rb +0 -0
- data/r2mp3/r2mp3.rb +1 -0
- data/sig/r2mp3.rbs +4 -0
- metadata +84 -58
- data/README.txt +0 -50
- data/lib/r2mp3/error.rb +0 -21
- data/lib/r2mp3/support.rb +0 -16
- data/lib/r2mp3/test_blah.rb +0 -13
- data/lib/r2mp3/tools/lame.rb +0 -12
- data/lib/r2mp3/tools/loader.rb +0 -25
- data/lib/r2mp3/tools/mplayer.rb +0 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 535285bfd7c3095d9d544aa7cfea11490db976b9d3c35c9b9f44fa21cda0e442
|
4
|
+
data.tar.gz: a40cace2f6148ba2170e95f3a6fd88f768ec483476962c41ad39790b991880d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9eb0f49ccb1c984544c6d8a6973a7c34053ea4def2c424e8ac75cd4504dcb008ef6bcab06b4ee3ccfa790f9e87756120b3ea4873e8d9eeaa0d20050788b03ea
|
7
|
+
data.tar.gz: d3417d00fd1e2c8aa2eae93b4f806f5a43dc279a73ce4961bbd115891d9be086b0b038faf25a4f8a64b30ebc7a6462b634c5129289abf7caa6c05b180d5fa0ef
|
data/.DS_Store
ADDED
Binary file
|
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
## [0.1.0] - 2007-10-15
|
2
|
+
|
3
|
+
- Initial release, pre-Alpha
|
4
|
+
- Should support simple convert to mp3
|
5
|
+
|
6
|
+
|
7
|
+
## [0.1.1] - 2007-10-29
|
8
|
+
- Add bitrate setting
|
9
|
+
- Add mode setting
|
10
|
+
- Remove bitrate setting bug
|
11
|
+
- Change example
|
12
|
+
- Support MP3 to MP3
|
13
|
+
- MP3 inspector added based-on mp3-info
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [0.3.1] - 2024-06-30
|
18
|
+
- ** Breaking changes **
|
19
|
+
- Update to depend on ffmpeg
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 zdk
|
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
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
R2mp3 library:
|
2
|
+
- Convert wma to mp3
|
3
|
+
- Convert aac to mp3
|
4
|
+
- Convert ra to mp3
|
5
|
+
|
6
|
+
Requirement:
|
7
|
+
lame_adapter (sudo gem install lame_adapter)
|
8
|
+
mplayer+lame (sudo apt-get install mplayer lame)
|
9
|
+
|
10
|
+
|
11
|
+
Change log:
|
12
|
+
15/10/2007 Pre-Alpha
|
13
|
+
- Should support simple convert to mp3
|
14
|
+
|
15
|
+
29/10/2007 Version 0.1.1
|
16
|
+
- Add bitrate setting
|
17
|
+
- Add mode setting
|
18
|
+
- Remove bitrate setting bug
|
19
|
+
- Change example
|
20
|
+
- Support MP3 to MP3
|
21
|
+
- MP3 inspector added based-on mp3-info
|
22
|
+
|
23
|
+
#todo - refactor
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# R2mp3
|
2
|
+
|
3
|
+
Simple audio files to mp3 library using ffmpeg and getting mp3 information.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add r2mp3
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install r2mp3
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```
|
18
|
+
require "r2mp3"
|
19
|
+
|
20
|
+
converter = R2mp3::Converter.new(input_file: "./in.wav", output_file: "./out.mp3", bitrate: 320)
|
21
|
+
converter.run!
|
22
|
+
|
23
|
+
mp3 = R2mp3::Inspector.new(file: "out.mp3")
|
24
|
+
puts mp3.info
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zdk/r2mp3. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/r2mp3/blob/main/CODE_OF_CONDUCT.md).
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
35
|
+
|
36
|
+
## Code of Conduct
|
37
|
+
|
38
|
+
Everyone interacting in the R2mp3 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zdk/r2mp3/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#This script used for inspect the mp3 file
|
3
|
+
require 'rubygems'
|
4
|
+
require "base64"
|
5
|
+
require 'mp3info'
|
6
|
+
TEMP_FILE = File.join(File.dirname($0),"file.mp3")
|
7
|
+
|
8
|
+
class Mp3Tool
|
9
|
+
def self.setup
|
10
|
+
@valid_mp3 = Base64.decode64 <<EOF
|
11
|
+
//uQZAAAAAAAaQYAAAAAAA0gwAAAAAABpBwAAAAAADSDgAAATEFNRTMuOTNV
|
12
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
13
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
14
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
15
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
16
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
17
|
+
VVVVVVVVVVVVVVVVVVVVVVVVTEFNRTMuOTNVVVVVVVVVVVVVVVVVVVVVVVVV
|
18
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
19
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
20
|
+
VVVVVVVVVVVVVVVV//uSZL6P8AAAaQAAAAAAAA0gAAAAAAABpAAAAAAAADSA
|
21
|
+
AAAAVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
22
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
23
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
24
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
25
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
26
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUxBTUUzLjkzVVVVVVVV
|
27
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
28
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
29
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7kmT/j/AAAGkAAAAAAAANIAAA
|
30
|
+
AAAAAaQAAAAAAAA0gAAAAFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
31
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
32
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
33
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
34
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
35
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVM
|
36
|
+
QU1FMy45M1VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
37
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
38
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+5Jk/4/w
|
39
|
+
AABpAAAAAAAADSAAAAAAAAGkAAAAAAAANIAAAABVVVVVVVVVVVVVVVVVVVVV
|
40
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
41
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
42
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
43
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
44
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
45
|
+
VVVVVVVVVVVVVVVVTEFNRTMuOTNVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
46
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
47
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
48
|
+
VVVVVVVV//uSZP+P8AAAaQAAAAAAAA0gAAAAAAABpAAAAAAAADSAAAAAVVVV
|
49
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
50
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
51
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
52
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
53
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
54
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
55
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
56
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
57
|
+
VVVVVVVVVVVVVVVVVVVVVVVVVQ==
|
58
|
+
EOF
|
59
|
+
@tag = {
|
60
|
+
"title" => "title",
|
61
|
+
"artist" => "artist",
|
62
|
+
"album" => "album",
|
63
|
+
"year" => 1921,
|
64
|
+
"comments" => "comments",
|
65
|
+
"genre" => 0,
|
66
|
+
"genre_s" => "Blues",
|
67
|
+
"tracknum" => 36
|
68
|
+
}
|
69
|
+
File.open(TEMP_FILE, "w") { |f| f.write(@valid_mp3) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.inspect
|
73
|
+
Mp3Info.open(TEMP_FILE) do |info|
|
74
|
+
puts "Inspecting...#{TEMP_FILE}"
|
75
|
+
puts "======Summary============"
|
76
|
+
puts "MPEG #{info.mpeg_version}"
|
77
|
+
puts "Layer #{info.layer}"
|
78
|
+
puts "VBR? #{info.vbr}"
|
79
|
+
puts "Bitrate #{info.bitrate} kbps"
|
80
|
+
puts "Mode: #{info.channel_mode}"
|
81
|
+
puts "Sample rate #{info.samplerate} Hz"
|
82
|
+
puts "Error protection? #{info.error_protection}"
|
83
|
+
puts "Length #{info.length}"
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Mp3Tool.setup
|
90
|
+
Mp3Tool.inspect
|
data/lib/r2mp3/base.rb
CHANGED
data/lib/r2mp3/converter.rb
CHANGED
@@ -1,125 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@input_file = options[:in]
|
7
|
-
@output_file = options[:out]
|
8
|
-
@wav_output = options[:wav].nil? ? "audiodump.wav" : options[:wav]
|
9
|
-
@mode = options[:mode]
|
10
|
-
@bitrate = options[:bitrate]
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_mp3
|
14
|
-
return false unless convert_from_to(:file => @input_file, :from => audio_info.type, :to => :wav)
|
15
|
-
convert_from_to(:file => @input_file, :from => :wav, :to => :mp3)
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_mp3!
|
19
|
-
raise ConverterError::DumpToWaveError unless convert_from_to(:file => @input_file, :from => audio_info.type, :to => :wav)
|
20
|
-
raise ConverterError::CovertToMp3Error unless convert_from_to(:file => @input_file, :from => :wav, :to => :mp3)
|
21
|
-
return true
|
22
|
-
end
|
23
|
-
|
24
|
-
def is_wav?
|
25
|
-
@wav
|
26
|
-
end
|
27
|
-
|
28
|
-
def is_mp3?
|
29
|
-
@mp3
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
#To Do: auto load tool for particular media type
|
35
|
-
def run_tool_with(options = {})
|
36
|
-
# p Module.nesting
|
37
|
-
recipe = options[:recipe]
|
38
|
-
message = options[:message]
|
39
|
-
unless recipe.nil? && message.nil?
|
40
|
-
tool = R2mp3::Tools::Loader.load(recipe)
|
41
|
-
tool.execute(message)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def audio_info
|
46
|
-
Inspector.new(:file => @input_file)
|
47
|
-
end
|
1
|
+
require "r2mp3/tool"
|
2
|
+
module R2mp3
|
3
|
+
class Converter < Data.define(:input_file, :output_file, :bitrate)
|
4
|
+
def run!
|
5
|
+
command = "#{R2mp3::FFMPEG} -i #{input_file} -acodec libmp3lame -ab #{bitrate}k #{output_file}"
|
48
6
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
return true if run_tool_with(:recipe => dump_to_wav, :message => message)
|
55
|
-
when :mp3
|
56
|
-
# @default_recipe = YAML::load_file(File.dirname(__FILE__) + "/../../recipes/to_mp3.yaml")[:default]
|
57
|
-
return true if run_tool_with(:recipe => wav_to_mp3, :message => message)
|
58
|
-
end
|
59
|
-
return false
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
def dump_to_wav
|
64
|
-
puts "dumping to wav...."
|
65
|
-
raise ConverterError::InputFileRequired unless File.exists?(@input_file)
|
66
|
-
%{#{R2mp3::Tools::MPLAYER} #{wav_options} #{@input_file}}
|
67
|
-
end
|
68
|
-
|
69
|
-
#TODO: More DRY
|
70
|
-
def wav_options
|
71
|
-
# todo:
|
72
|
-
opts = {
|
73
|
-
:quiet => "",
|
74
|
-
:vo => "null",
|
75
|
-
:vc => "dummy",
|
76
|
-
:af => "volume=0,resample=44100:0:1",
|
77
|
-
:ao => "pcm:waveheader:file=#{@wav_output}"
|
78
|
-
}
|
79
|
-
options = " "
|
80
|
-
opts.each do |k,v|
|
81
|
-
options << "-#{k.to_s} #{v.to_s} "
|
82
|
-
end
|
83
|
-
options
|
84
|
-
end
|
85
|
-
|
86
|
-
def wav_to_mp3
|
87
|
-
puts "wav to mp3 conversion...."
|
88
|
-
raise ConverterError::DumpToWaveError unless File.exists?(@wav_output)
|
89
|
-
input = @wav_output
|
90
|
-
options = mp3_options
|
91
|
-
@output_path = @output_file
|
92
|
-
%{#{R2mp3::Tools::LAME} #{input} #{@output_file} #{options}}
|
93
|
-
end
|
94
|
-
|
95
|
-
#it just works, and shouldn't be here exactly.
|
96
|
-
#To do: MORE DRY
|
97
|
-
def mp3_options
|
98
|
-
# (j)oint, (s)imple, (f)orce, (d)dual-mono, (m)ono
|
99
|
-
mode = {
|
100
|
-
:stereo => "j",
|
101
|
-
:mono => "m",
|
102
|
-
:dual_mono => "d"
|
103
|
-
}
|
104
|
-
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
|
105
|
-
opts = {
|
106
|
-
:V2 => "",
|
107
|
-
:_vbr_new => "",
|
108
|
-
:q0 => "",
|
109
|
-
:_lowpass => "19.7",
|
110
|
-
:m => "j"
|
111
|
-
}
|
112
|
-
opts[:m] = mode[@mode.to_sym] unless @mode.nil?
|
113
|
-
unless @bitrate.nil?
|
114
|
-
raise ConverterError::Mp3UnsupportBitrate unless bitrates.include?(@bitrate.to_i)
|
115
|
-
opts[:b] = @bitrate
|
116
|
-
end
|
117
|
-
options = " "
|
118
|
-
opts.each do |k,v|
|
119
|
-
options << "-#{k.to_s.gsub("_","-")} #{v.to_s} "
|
120
|
-
end
|
121
|
-
options
|
7
|
+
result, err, s = Open3.capture3(command)
|
8
|
+
return if s.success?
|
9
|
+
|
10
|
+
print err
|
11
|
+
nil
|
122
12
|
end
|
123
|
-
|
124
13
|
end
|
125
14
|
end
|
data/lib/r2mp3/inspector.rb
CHANGED
@@ -1,36 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "wahwah"
|
2
2
|
module R2mp3
|
3
|
-
class Inspector
|
4
|
-
attr_reader :type, :header, :channel_mode, :length, :tag1, :tag, :vbr, :layer, :samplerate, :mpeg_version, :tag1_parsed, :filename, :bitrate
|
5
|
-
|
6
|
-
def initialize(options={})
|
7
|
-
@file = options[:file]
|
8
|
-
raise InspectorError::InputFileRequired if @file.nil?
|
9
|
-
@type = file_extension
|
10
|
-
info
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
# Naive
|
15
|
-
def file_extension
|
16
|
-
File.extname(@file).gsub(".","").to_sym
|
17
|
-
end
|
18
|
-
|
3
|
+
class Inspector < Data.define(:file)
|
19
4
|
def info
|
20
|
-
|
21
|
-
|
22
|
-
|
5
|
+
nil unless File.extname(file).eql?(".mp3")
|
6
|
+
tag = nil
|
7
|
+
File.open file do |f|
|
8
|
+
tag = WahWah::Mp3Tag.new(f)
|
9
|
+
end
|
10
|
+
tag.instance_variables.each_with_object({}) do |var, hash|
|
11
|
+
hash[var.to_s.delete("@")] = tag.instance_variable_get(var)
|
23
12
|
end
|
24
|
-
self
|
25
|
-
end
|
26
|
-
|
27
|
-
def mp3_data
|
28
|
-
[
|
29
|
-
:header, :channel_mode, :length, :tag1,
|
30
|
-
:tag, :vbr, :layer, :samplerate, :mpeg_version,
|
31
|
-
:filename, :bitrate
|
32
|
-
]
|
33
13
|
end
|
34
|
-
|
35
14
|
end
|
36
|
-
end
|
15
|
+
end
|
data/lib/r2mp3/tool.rb
ADDED
data/lib/r2mp3/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module R2mp3
|
2
2
|
module Version
|
3
|
-
MAJOR
|
4
|
-
MINOR
|
5
|
-
TINY
|
6
|
-
BUILD
|
3
|
+
MAJOR = '0'
|
4
|
+
MINOR = '3'
|
5
|
+
TINY = '1'
|
6
|
+
BUILD = Time.now.to_i.to_s
|
7
7
|
end
|
8
8
|
VERSION = [Version::MAJOR, Version::MINOR, Version::TINY, Version::BUILD].compact * '.'
|
9
|
-
end
|
9
|
+
end
|
data/lib/r2mp3.rb
CHANGED
@@ -1,22 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'base64'
|
3
|
-
require 'digest/sha1'
|
4
|
-
require 'time'
|
5
|
-
require 'date'
|
6
|
-
require 'yaml'
|
7
|
-
require 'active_support'
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
3
|
+
require "rubygems"
|
4
|
+
require "base64"
|
5
|
+
require "open3"
|
6
|
+
require "wahwah"
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
libs = [ :error, :version, :converter, :inspector ]
|
15
|
-
#
|
16
|
-
libs.each { |l| require File.dirname(__FILE__) + "/#{R2mp3::Base::R2MP3}/#{l.to_s}" }
|
17
|
-
|
18
|
-
|
19
|
-
require 'r2mp3/tools/loader'
|
20
|
-
require 'r2mp3/tools/lame'
|
21
|
-
require 'r2mp3/tools/mplayer'
|
22
|
-
|
8
|
+
require_relative "r2mp3/base"
|
9
|
+
require_relative "r2mp3/version"
|
10
|
+
require_relative "r2mp3/converter"
|
11
|
+
require_relative "r2mp3/inspector"
|
data/r2mp3/.DS_Store
ADDED
Binary file
|
data/r2mp3/boot.rb
ADDED
data/r2mp3/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,238 @@
|
|
1
|
+
class Converter
|
2
|
+
def initialize(opts={},&block)
|
3
|
+
$opts = opts
|
4
|
+
yield(opts) if block_given?
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Convert
|
9
|
+
|
10
|
+
def self.mp3_to_wav(input, output=nil, opts={})
|
11
|
+
puts "mp3 to wav"
|
12
|
+
conversion(:mp3, :wav, input, output, opts) do | input, output, opts |
|
13
|
+
Mplayer.dump_to_wav(input, output, opts)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.mp3_to_mp3(input, output=nil, opts={})
|
18
|
+
puts "mp3 to mp3"
|
19
|
+
output ||= input.gsub(/\.rm$/,".mp3")
|
20
|
+
mp3_to_wav(input, 'temp.wav', opts) and wav_to_mp3('temp.wav', output, opts.merge({:delete_input=>true}))
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.ra_to_wav(input, output=nil, opts={})
|
24
|
+
conversion(:rm, :wav, input, output, opts) do | input, output, opts |
|
25
|
+
Mplayer.dump_to_wav(input, output, opts)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.ra_to_mp3(input, output=nil, opts={})
|
30
|
+
output ||= input.gsub(/\.rm$/,".mp3")
|
31
|
+
ra_to_wav(input, 'temp.wav', opts) and wav_to_mp3('temp.wav', output, opts.merge({:delete_input=>true}))
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.aac_to_wav(input, output=nil, opts={})
|
35
|
+
conversion(:m4a, :wav, input, output, opts) do | input, output, opts |
|
36
|
+
Mplayer.dump_to_wav(input, output, opts)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.aac_to_mp3(input, output=nil, opts={})
|
41
|
+
output ||= input.gsub(/\.m4a$/,".mp3")
|
42
|
+
aac_to_wav(input, 'temp.wav', opts) and wav_to_mp3('temp.wav', output, opts.merge({:delete_input=>true}))
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.wma_to_mp3(input, output=nil, opts = {})
|
46
|
+
p opts
|
47
|
+
output ||= input.gsub(/\.wma$/,".mp3")
|
48
|
+
wma_to_wav(input, 'temp.wav', opts) and wav_to_mp3('temp.wav', output, opts.merge({:delete_input=>true}))
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.wma_to_wav(input, output=nil, opts={})
|
52
|
+
conversion(:wma, :wav, input, output, opts) do | input, output, opts |
|
53
|
+
Mplayer.dump_to_wav(input, output, opts)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.wav_to_mp3(input, output=nil, opts={})
|
58
|
+
puts "wav to mp3"
|
59
|
+
conversion(:wav, :mp3, input, output, opts) do | input, output, opts |
|
60
|
+
opts[:mode] ||= :stereo
|
61
|
+
opts[:bitrate] ||= 64
|
62
|
+
puts "bitrate = #{opts[:bitrate]}"
|
63
|
+
lame = LameAdapter.new
|
64
|
+
lame.input_file input
|
65
|
+
lame.output_file output
|
66
|
+
lame.mode opts[:mode]
|
67
|
+
lame.bitrate opts[:bitrate]
|
68
|
+
lame.convert!
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.conversion(input_format, output_format, input_file, output_file, opts={}, &block)
|
73
|
+
puts "...conversion"
|
74
|
+
input_format = input_format.to_s
|
75
|
+
output_format = output_format.to_s
|
76
|
+
input_regexp = /\.#{input_format}$/
|
77
|
+
return false unless File.exists? input_file and File.extname(input_file) =~ input_regexp
|
78
|
+
output_file ||= input_file.gsub(input_regexp,".#{output_format}")
|
79
|
+
success = yield(input_file, output_file, opts)
|
80
|
+
FileUtils.rm input_file if opts[:delete_input]
|
81
|
+
success and File.exists? output_file
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.wma_dir_to_mp3(dirname, opts = {})
|
85
|
+
Dir["#{dirname}/*.wma"].each do |name|
|
86
|
+
if !name[/[\s]+/].nil? then
|
87
|
+
new_name = name.gsub(" ","_").downcase
|
88
|
+
FileUtils.mv "#{name}", "#{new_name}", :force => true # no error
|
89
|
+
name = new_name
|
90
|
+
end
|
91
|
+
wma_to_mp3(name, nil, opts)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.wma_file_to_mp3(filename, opts = {})
|
96
|
+
wma_to_mp3(filename, nil, opts)
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.aac_dir_to_mp3(dirname, opts = {})
|
100
|
+
Dir["#{dirname}/*.m4a"].each do |name|
|
101
|
+
if !name[/[\s]+/].nil? then
|
102
|
+
new_name = name.gsub(" ","_").downcase
|
103
|
+
FileUtils.mv "#{name}", "#{new_name}", :force => true # no error
|
104
|
+
name = new_name
|
105
|
+
end
|
106
|
+
aac_to_mp3(name, nil, opts)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.aac_file_to_mp3(filename, opts = {})
|
111
|
+
aac_to_mp3(filename, nil, opts)
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.ra_dir_to_mp3(dirname, opts = {})
|
115
|
+
Dir["#{dirname}/*.rm"].each do |name|
|
116
|
+
if !name[/[\s]+/].nil? then
|
117
|
+
new_name = name.gsub(" ","_").downcase
|
118
|
+
FileUtils.mv "#{name}", "#{new_name}", :force => true # no error
|
119
|
+
name = new_name
|
120
|
+
end
|
121
|
+
ra_to_mp3(name, nil, opts)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def self.ra_file_to_mp3(filename, opts = {})
|
126
|
+
ra_to_mp3(filename, nil, opts)
|
127
|
+
end
|
128
|
+
|
129
|
+
def self.mp3_dir_to_mp3(dirname, opts = {})
|
130
|
+
Dir["#{dirname}/*.mp3"].each do |name|
|
131
|
+
if !name[/[\s]+/].nil? then
|
132
|
+
new_name = name.gsub(" ","_").downcase
|
133
|
+
FileUtils.mv "#{name}", "#{new_name}", :force => true # no error
|
134
|
+
name = new_name
|
135
|
+
end
|
136
|
+
mp3_to_mp3(name, nil, opts)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.mp3_file_to_mp3(filename, opts = {})
|
141
|
+
mp3_to_mp3(filename, nil, opts)
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
class Hash
|
148
|
+
|
149
|
+
def to_mp3
|
150
|
+
case $opts[:convert]
|
151
|
+
when :wma
|
152
|
+
unless $opts[:dir].nil? then
|
153
|
+
puts "convert all wma files in #{self[:dir]}"
|
154
|
+
Convert.wma_dir_to_mp3(self[:dir], self)
|
155
|
+
else
|
156
|
+
puts "(wma) convert #{self[:file]} to mp3"
|
157
|
+
Convert.wma_file_to_mp3(self[:file], self)
|
158
|
+
end
|
159
|
+
when :aac
|
160
|
+
unless $opts[:dir].nil? then
|
161
|
+
puts "convert all aac files in #{self[:dir]}"
|
162
|
+
Convert.aac_dir_to_mp3(self[:dir], self)
|
163
|
+
else
|
164
|
+
puts "(aac) convert #{self[:file]} to mp3"
|
165
|
+
Convert.aac_file_to_mp3(self[:file], self)
|
166
|
+
end
|
167
|
+
when :ra
|
168
|
+
unless $opts[:dir].nil? then
|
169
|
+
puts "convert all ra files in #{self[:dir]}"
|
170
|
+
Convert.ra_dir_to_mp3(self[:dir], self)
|
171
|
+
else
|
172
|
+
puts "(ra) convert #{self[:file]} to mp3"
|
173
|
+
Convert.ra_file_to_mp3(self[:file], self)
|
174
|
+
end
|
175
|
+
when :mp3
|
176
|
+
unless $opts[:dir].nil? then
|
177
|
+
puts "convert all mp3 files in #{self[:dir]}"
|
178
|
+
Convert.mp3_dir_to_mp3(self[:dir], self)
|
179
|
+
else
|
180
|
+
puts "(mp3) convert #{self[:file]} to mp3"
|
181
|
+
Convert.mp3_file_to_mp3(self[:file], self)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def bitrate kbps
|
187
|
+
self[:bitrate] = kbps
|
188
|
+
end
|
189
|
+
|
190
|
+
def mode m
|
191
|
+
self[:mode] = m
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
# class Options < Hash
|
200
|
+
# def initialize(arg)
|
201
|
+
# begin
|
202
|
+
# optstruct = OpenStruct.new
|
203
|
+
# options = OptionParser.new do |opts|
|
204
|
+
# opts.banner = "usage: #{__FILE__} [options]"
|
205
|
+
# opts.on('-w','--wma-to-mp3','convert .wma to mp3 ')do
|
206
|
+
# self[:wma] = true
|
207
|
+
# end
|
208
|
+
# opts.on('-a','--aac-to-mp3','convert .m4a to mp3')do
|
209
|
+
# self[:aac] = true
|
210
|
+
# end
|
211
|
+
# opts.on('-r','--ra-to-mp3','convert .rm to mp3')do
|
212
|
+
# self[:ra] = true
|
213
|
+
# end
|
214
|
+
# opts.on('-m','--mp3-to-mp3','convert mp3 to mp3')do
|
215
|
+
# self[:mp3] = true
|
216
|
+
# end
|
217
|
+
# opts.on('-f','--file [filename]','file') do |f|
|
218
|
+
# self[:file] = f
|
219
|
+
# end
|
220
|
+
# opts.on('-d','--dir [directoryname]','directory') do |d|
|
221
|
+
# self[:dir] = d
|
222
|
+
# end
|
223
|
+
# opts.on('-b','--bitrate [kbps]','bitrate') do |b|
|
224
|
+
# self[:bitrate] = b.to_i
|
225
|
+
# end
|
226
|
+
# opts.on_tail('-h','--help','help') do
|
227
|
+
# puts opts
|
228
|
+
# exit
|
229
|
+
# end
|
230
|
+
# raise "print help" if ARGV.size < 1
|
231
|
+
# raise "choose wma or aac " if self[:wma] and self[:aac]
|
232
|
+
# end.parse!(arg)
|
233
|
+
# rescue OptionParser::InvalidOption, RuntimeError => e
|
234
|
+
# puts e
|
235
|
+
# puts "#{$0} -h or --help , for help"
|
236
|
+
# end
|
237
|
+
# end
|
238
|
+
# end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Mplayer
|
2
|
+
# Can be used to dump any audio file to wav
|
3
|
+
def self.dump_to_wav(input, output, opts={})
|
4
|
+
puts "dump to wav"
|
5
|
+
begin
|
6
|
+
platform = `uname -a`
|
7
|
+
binary = "#{%r{Linux} =~ platform}".empty?? "/Applications/mplayer":"mplayer"
|
8
|
+
FileUtils.rm("audiodump.wav") if File.exists? "audiodump.wav"
|
9
|
+
opts[:resample] ||= '44100'
|
10
|
+
args = ""
|
11
|
+
force_opt = {:vo => "null", :vc => "dummy", :af => "resample=#{opts[:resample]}", :ao => "pcm:waveheader"}
|
12
|
+
force_opt.each{|k,v| args << "-#{k.to_s} #{v} "}
|
13
|
+
cmd = "#{binary} #{args} #{input}"
|
14
|
+
success = system(cmd)
|
15
|
+
puts "Success? #{success}"
|
16
|
+
FileUtils.mv("audiodump.wav", output) if File.exists? "audiodump.wav"
|
17
|
+
success
|
18
|
+
rescue Errno::ENOENT => err
|
19
|
+
puts "No audiodump :" + err
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
File without changes
|
File without changes
|
data/r2mp3/r2mp3.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'boot'
|
data/sig/r2mp3.rbs
ADDED
metadata
CHANGED
@@ -1,75 +1,101 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: r2mp3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1.1718288953
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
6
|
+
authors:
|
7
|
+
- zdk
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
17
20
|
type: :runtime
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: wahwah
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Some audio files format to mp3
|
42
|
+
email:
|
43
|
+
- di.warachet@gmail.com
|
27
44
|
executables: []
|
28
|
-
|
29
45
|
extensions: []
|
30
|
-
|
31
46
|
extra_rdoc_files: []
|
32
|
-
|
33
|
-
|
34
|
-
-
|
47
|
+
files:
|
48
|
+
- ".DS_Store"
|
49
|
+
- ".standard.yml"
|
50
|
+
- CHANGELOG.md
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- LICENSE.txt
|
53
|
+
- README
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- inspector/mp3inspector.rb
|
57
|
+
- lib/r2mp3.rb
|
35
58
|
- lib/r2mp3/base.rb
|
36
59
|
- lib/r2mp3/converter.rb
|
37
|
-
- lib/r2mp3/error.rb
|
38
60
|
- lib/r2mp3/inspector.rb
|
39
|
-
- lib/r2mp3/
|
40
|
-
- lib/r2mp3/test_blah.rb
|
41
|
-
- lib/r2mp3/tools
|
42
|
-
- lib/r2mp3/tools/lame.rb
|
43
|
-
- lib/r2mp3/tools/loader.rb
|
44
|
-
- lib/r2mp3/tools/mplayer.rb
|
61
|
+
- lib/r2mp3/tool.rb
|
45
62
|
- lib/r2mp3/version.rb
|
46
|
-
-
|
47
|
-
-
|
48
|
-
|
49
|
-
|
50
|
-
|
63
|
+
- r2mp3/.DS_Store
|
64
|
+
- r2mp3/boot.rb
|
65
|
+
- r2mp3/dependencies.rb
|
66
|
+
- r2mp3/lib/.DS_Store
|
67
|
+
- r2mp3/lib/adapter.rb
|
68
|
+
- r2mp3/lib/base-utils.rb
|
69
|
+
- r2mp3/lib/converter-utils.rb
|
70
|
+
- r2mp3/lib/mplayer_adapter.rb
|
71
|
+
- r2mp3/lib/tools/lame.rb
|
72
|
+
- r2mp3/lib/tools/mplayer.rb
|
73
|
+
- r2mp3/r2mp3.rb
|
74
|
+
- sig/r2mp3.rbs
|
75
|
+
homepage: https://github.com/zdk/r2mp3
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata:
|
79
|
+
homepage_uri: https://github.com/zdk/r2mp3
|
80
|
+
source_code_uri: https://github.com/zdk/r2mp3
|
81
|
+
changelog_uri: https://github.com/zdk/r2mp3/changelog.txt
|
82
|
+
post_install_message:
|
51
83
|
rdoc_options: []
|
52
|
-
|
53
|
-
require_paths:
|
84
|
+
require_paths:
|
54
85
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
57
88
|
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
|
61
|
-
|
62
|
-
requirements:
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.0.0
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
63
93
|
- - ">="
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version:
|
66
|
-
version:
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
67
96
|
requirements: []
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
specification_version: 2
|
73
|
-
summary: A library for converting any audio files to mp3
|
97
|
+
rubygems_version: 3.5.11
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Audio files converter
|
74
101
|
test_files: []
|
75
|
-
|
data/README.txt
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
R2mp3 is a ruby library that makes audio converting to mp3 fairly easy.
|
2
|
-
|
3
|
-
Currently, support formats are following:
|
4
|
-
- wma
|
5
|
-
- aac
|
6
|
-
- aif
|
7
|
-
- au
|
8
|
-
- flac
|
9
|
-
- ogg
|
10
|
-
- ra
|
11
|
-
|
12
|
-
|
13
|
-
INSTALLATION
|
14
|
-
#Software requirement
|
15
|
-
|
16
|
-
1. install lame and mplayer in the box.
|
17
|
-
(OSX)
|
18
|
-
sudo port intall lame
|
19
|
-
sudo port install mplayer
|
20
|
-
|
21
|
-
(Debian, Ubuntu, etc.)
|
22
|
-
sudo apt-get install lame
|
23
|
-
sudo apt-get install mplayer
|
24
|
-
|
25
|
-
|
26
|
-
2. install gem
|
27
|
-
sudo gem install r2mp3
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
HOW TO USE
|
32
|
-
|
33
|
-
|
34
|
-
#Converter
|
35
|
-
|
36
|
-
#handle all objects which is convertable to mp3
|
37
|
-
converter = R2mp3::Converter.new(:in => "/path/to/file", :out => "/path/to/file")
|
38
|
-
|
39
|
-
#options :mode => "stereo", :bitrate => ""
|
40
|
-
converter.to_mp3 # true or false
|
41
|
-
converter.to_mp3! # true if sucess, otherwise raise Exception
|
42
|
-
|
43
|
-
|
44
|
-
#Inspector
|
45
|
-
file = R2mp3::Inspector.new(:file => "/path/to/mp3_file")
|
46
|
-
file.type
|
47
|
-
file.bitrate
|
48
|
-
file.samplerate
|
49
|
-
|
50
|
-
#for more detail, see in spec/
|
data/lib/r2mp3/error.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class ConverterError < RuntimeError
|
2
|
-
class InputFileRequired < ConverterError
|
3
|
-
end
|
4
|
-
class UnknownError < ConverterError
|
5
|
-
end
|
6
|
-
class DumpToWaveError < ConverterError
|
7
|
-
end
|
8
|
-
class Mp3UnsupportBitrate < ConverterError
|
9
|
-
end
|
10
|
-
class CovertToMp3Error < ConverterError
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class InspectorError < RuntimeError
|
15
|
-
class InputFileRequired < InspectorError
|
16
|
-
end
|
17
|
-
class InvalidInput < InspectorError
|
18
|
-
end
|
19
|
-
class UnknownError < InspectorError
|
20
|
-
end
|
21
|
-
end
|
data/lib/r2mp3/support.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
|
3
|
-
def constant(opts = {})
|
4
|
-
opts.each_pair do |k, v|
|
5
|
-
k = k.to_s.upcase
|
6
|
-
const_set(k, v) unless const_defined?(k)
|
7
|
-
end
|
8
|
-
|
9
|
-
# module_eval(<<-EVAL, __FILE__, __LINE__)
|
10
|
-
# def self.#{name.to_s.downcase}
|
11
|
-
# #{name.to_s}
|
12
|
-
# end
|
13
|
-
# EVAL
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/lib/r2mp3/test_blah.rb
DELETED
data/lib/r2mp3/tools/lame.rb
DELETED
data/lib/r2mp3/tools/loader.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module R2mp3
|
2
|
-
module Tools
|
3
|
-
class Loader
|
4
|
-
|
5
|
-
def self.load(recipe)
|
6
|
-
name = recipe.split.first
|
7
|
-
tool = "R2mp3::Tools::#{name.classify}".constantize.send(:new, recipe)
|
8
|
-
end
|
9
|
-
|
10
|
-
module InstanceMethods
|
11
|
-
def initialize(recipe)
|
12
|
-
@recipe = recipe
|
13
|
-
end
|
14
|
-
|
15
|
-
def execute(message=nil)
|
16
|
-
run_command = "#{@recipe} 2>&1"
|
17
|
-
# puts "run command: #{run_command}"
|
18
|
-
# puts message unless message.nil?
|
19
|
-
@result = `#{run_command}`
|
20
|
-
return parse(@result)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/r2mp3/tools/mplayer.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module R2mp3
|
2
|
-
module Tools
|
3
|
-
constant :mplayer => 'mplayer'
|
4
|
-
class Mplayer
|
5
|
-
include Loader::InstanceMethods
|
6
|
-
|
7
|
-
def parse(result)
|
8
|
-
return true unless result[/Audio stream found/].nil?
|
9
|
-
return true unless result[/file format detected/].nil?
|
10
|
-
false
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|