-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcut
executable file
·58 lines (46 loc) · 1.21 KB
/
mcut
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /bin/sh
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "help" ] || [ -z "$1" ]; then
cat << EOF
$ mcut FILE START [END]
mp3cut wrapper
Parameters:
\$1: input file
\$2: start time
[\$3]: end time, default: end of the song
Time Format:
00:00+000, min:sec+mili
Flags:
-r, replace the old with the new cut version
Example:
$ mcut "Beastie Boys - The Sounds of Science.mp3" 01:39
$ mcut "Beastie Boys - The Sounds of Science.mp3" 01:39 -r
EOF
exit
fi
command -v mp3cut >/dev/null || { echo "mp3cut is not installed"; exit 127; }
command -v copy_id3.py >/dev/null || { echo "copy_id3.py script is not installed"; exit 127; }
IN="$1"
OUT="$IN.new"
if [ -z "$2" ]; then
mpv --profile=music "$IN"
exit 0
fi
START="$2"
END="$3"
[ -z "$3" ] && END="00:00"
REPLACE=0
if [ "$3" = "-r" ]; then
REPLACE=1
END="00:00"
fi
[ "$4" = "-r" ] && REPLACE=1
if [ "$REPLACE" -gt 0 ]; then
mp3cut -o "$OUT" -t "00:$START+000-00:$END+000" "$IN"
echo "=== Replacing original with cut version ==="
~/scripts/music/copy_id3.py "$IN" "$OUT"
mv "$OUT" "$IN"
chmod -x "$IN"
else
mp3cut -o - -t "00:$START+000-00:$END+000" "$IN" | mpv --profile=music -
# mp3cut -o "$IN.new" -t "00:$START+000-00:$END+000" "$IN"
fi