Simpler code, README update (objective,usage,envvars) and better usage().
parent
69e4cac809
commit
3f892dc644
45
README.md
45
README.md
|
@ -1,41 +1,56 @@
|
||||||
|
# Get Tracks
|
||||||
|
|
||||||
|
`get-tracks.sh` allows you to easily extract music tracks from a file with multiple songs, like a CD-in-a-file.
|
||||||
|
|
||||||
# Required applications
|
# Required applications
|
||||||
|
|
||||||
|
`get-tracks.sh` is a simple shell script based around `ffmpeg`, using `xxd` and `awk`.
|
||||||
|
|
||||||
* ffmpeg
|
* ffmpeg
|
||||||
* xxd (with '-r' and '-p' options)
|
* xxd (with '-r' and '-p' options)
|
||||||
* awk
|
* awk
|
||||||
|
|
||||||
|
It was tested on both OpenBSD and Linux.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
|
Download a CD and the starting time of each track in a file, and you're good to go.
|
||||||
|
|
||||||
```Bash
|
```Bash
|
||||||
get-tracks.sh rip <audio-file> <time-file>
|
get-tracks.sh <audio-file> <time-file>
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
get-track.sh rip doom-eternal.opus doom-eternal.txt
|
get-track.sh doom-eternal.opus doom-eternal.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
`audio-file` can be in any format understood by `ffmpeg`.
|
*audio-file* can be in any format understood by `ffmpeg`.
|
||||||
|
|
||||||
The `time-file` must have this format:
|
The *time-file* must have this format:
|
||||||
|
|
||||||
```
|
```
|
||||||
0:00 First song
|
0:00 intro
|
||||||
2:20 Second song
|
2:20 First song
|
||||||
3:18 Awesome song
|
3:18 Awesome song
|
||||||
```
|
```
|
||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
|
|
||||||
* **SIMULATION**: if non empty do not invoke ffmpeg
|
* **SIMULATION** [empty or not]\
|
||||||
* **FORMAT** [mp3,ogg,opus,…]: for the song file format
|
do not invoke ffmpeg
|
||||||
* **NONUMBER**: if equals to 1, do not write song number
|
* **NONUMBER** [empty or 1]\
|
||||||
* **SEPARATOR**: (default: ' - '), write song number, with this separator
|
do not write song numbers
|
||||||
example with SEPARATOR='_': song names will be 01_song.opus 02_song.opus…
|
* **FORMAT** [mp3,ogg,opus,…]\
|
||||||
* **HEADERS**: if equals to 1, print environment parameters (verbosity, simulation, etc.)
|
see the ffmpeg documentation for the output formats available
|
||||||
|
* **SEPARATOR** [separator] (default: ' - ')\
|
||||||
|
separator between number and name\
|
||||||
|
example with SEPARATOR='_': 01_intro.opus 02_blah.opus…
|
||||||
|
* **HEADERS** [empty or 1]\
|
||||||
|
print environment parameters (verbosity, simulation, etc.)
|
||||||
* **VERBOSITY** [0-3] (default: 1)\
|
* **VERBOSITY** [0-3] (default: 1)\
|
||||||
verbosity 0: no output except errors from ffmpeg\
|
0: no output except errors from ffmpeg\
|
||||||
verbosity 1: simple indications on the current track being extracted\
|
1: simple indications on the current track being extracted\
|
||||||
verbosity 2: print actual ffmpeg commands the script currently runs
|
2: print actual ffmpeg commands the script currently runs
|
||||||
|
|
||||||
# More
|
# More
|
||||||
|
|
||||||
|
|
|
@ -161,23 +161,35 @@ rip(){
|
||||||
}
|
}
|
||||||
|
|
||||||
usage(){
|
usage(){
|
||||||
echo "usage: $0 command"
|
cat <<END
|
||||||
echo "command: show <song-list>"
|
Get tracks:
|
||||||
echo "command: rip <single-file-playlist> <song-list>"
|
usage: $0 <single-file-playlist> <song-list>
|
||||||
echo
|
|
||||||
echo "song-list line format example: 1:30 My second track of the playlist"
|
Debug mode (displays starting and ending times for each song):
|
||||||
echo "show output format: start end title"
|
usage: $0 <song-list>
|
||||||
echo
|
|
||||||
echo "envvar: SIMULATION, if non empty, do not invoke ffmpeg"
|
|
||||||
echo "envvar: NONUMBER, if equals to 1, do not write song number"
|
Format for <song-list>:
|
||||||
echo "envvar: FORMAT [mp3,ogg,opus,…], see the ffmpeg documentation"
|
0:00 First track
|
||||||
echo "envvar: SEPARATOR [separator] (default: ' - '), write song number, with this separator"
|
1:30 Second track
|
||||||
echo " example with SEPARATOR='_': song names will be 01_song.opus 02_song.opus…"
|
|
||||||
echo "envvar: HEADERS, if equals to 1, print environment parameters (verbosity, simulation, etc.)"
|
Environment variables:
|
||||||
echo "envvar: VERBOSITY [0-3] (default: 1)"
|
- SIMULATION [empty or not]
|
||||||
echo " verbosity 0: no output except errors from ffmpeg"
|
do not invoke ffmpeg
|
||||||
echo " verbosity 1: simple indications on the current track being extracted"
|
- NONUMBER [empty or 1]
|
||||||
echo " verbosity 2: print actual ffmpeg commands the script currently runs"
|
do not write song numbers
|
||||||
|
- FORMAT [mp3,ogg,opus,…]
|
||||||
|
see the ffmpeg documentation
|
||||||
|
- SEPARATOR [separator] (default: ' - ')
|
||||||
|
separator between number and name
|
||||||
|
example with SEPARATOR='_': 01_intro.opus 02_blah.opus…
|
||||||
|
- HEADERS [empty or 1]
|
||||||
|
print environment parameters (verbosity, simulation, etc.)
|
||||||
|
- VERBOSITY [0-3] (default: 1)
|
||||||
|
0: no output except errors from ffmpeg
|
||||||
|
1: simple indications on the current track being extracted
|
||||||
|
2: print actual ffmpeg commands the script currently runs
|
||||||
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
|
@ -185,9 +197,6 @@ if [ $# -lt 1 ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
command=$1
|
|
||||||
shift
|
|
||||||
|
|
||||||
header(){
|
header(){
|
||||||
if [ "$HEADERS" = "1" ]; then
|
if [ "$HEADERS" = "1" ]; then
|
||||||
echo $*
|
echo $*
|
||||||
|
@ -240,30 +249,8 @@ if [ $? -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "x-${command}" in
|
case $# in
|
||||||
x-show)
|
1) process_time_file < "$1" ;;
|
||||||
|
2) rip "$1" "$2" ;;
|
||||||
# Takes the audio file in first parameter
|
*) usage 1>&2 ; exit 1 ;;
|
||||||
if [ $# -ne 1 ]; then
|
|
||||||
echo "Usage: $0 show time-stamps-file" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
process_time_file < "$1"
|
|
||||||
;;
|
|
||||||
|
|
||||||
x-rip)
|
|
||||||
|
|
||||||
# Takes the audio file in first parameter
|
|
||||||
if [ $# -ne 2 ]; then
|
|
||||||
echo "Usage: $0 show music-file time-stamps-file" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
rip "$1" "$2"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
usage 1>&2
|
|
||||||
exit 1
|
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue