This repository has been archived by the owner on Aug 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmp3_gain_89_hard
executable file
·118 lines (103 loc) · 3.4 KB
/
mp3_gain_89_hard
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
## Dieses Skript ueberprueft das mp3-gain-tag in mp3-Dateien.
## Wenn es nicht vorhanden ist, wird die Lautheit der Datei
## analysiert und die Audio-Daten auf die Lautheit angepasst.
# Auch Player, die kein APE ReplayGain-Tag beruecksichtigen
# spielen die Datei entsprechend ab.
# Nachteil ist, dass die Audio-Daten verändert werden.
## http://wiki.ubuntuusers.de/MP3Gain
#
# This script examines the mp3-gain-tag in mp3-files.
# Is it not available, the audio data would be edited.
#
# You need to be running Nautilus 1.0.3+ to use scripts.
# To install as Nautilus script consider copying to filename with spaces.
# This is for better reading the Nautilus content menu
# For all users, type for example:
# sudo cp my_script "/usr/share/nautilus-scripts/my script"
# sudo chmod +x "/usr/share/nautilus-scripts/my script"
# sudo ln -s "/usr/share/nautilus-scripts/my_script" "~/.local/share/nautilus/scripts/my script"
#
# For local user, type for example:
# cp my_script ".local/share/nautilus/scripts/my script"
# chmod u+x ".local/share/nautilus/scripts/my script"
#
# dependent on: mp3gain
# if not alraedy on your system, type:
# sudo apt-get install mp3gain
# if mp3gain is not in your repository
# one can use this report
# sudo add-apt-repository ppa:flexiondotorg/audio
# sudo apt-get update
#
# Author: Joerg Sorge
# Distributed under the terms of GNU GPL version 2 or later
# Copyright (C) Joerg Sorge joergsorge at gmail com
# 2011-09-01
function f_choose_msg_lang () {
local_locale=$(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1)
if [ $local_locale == "de" ]; then
msg[1]="installiert"
msg[2]="replayGain anpassen auf 89 dB SPL..."
msg[3]="replayGain berechnen..."
msg[4]="replayGain: Bearbeite Dateien..."
msg[5]="Abgebrochen..."
err[1]=" ist nicht installiert, Bearbeitung nicht moeglich."
err[2]="Das ist keine wav Datei:"
err[3]="Fehler beim enkodieren"
err[4]="Fehler bei mp3gain"
else
msg[1]="installed"
msg[2]="Calculate replayGain..."
msg[3]="Calculate replayGain..."
msg[4]="replayGain: work on files..."
msg[5]="Canceled..."
err[1]=" not installed, work not possible."
err[2]="It's not a wav file:"
err[3]="Error by replayGain to mp3 "
err[4]="Error by mp3gain"
fi
}
function f_check_package () {
package_install=$1
if dpkg-query -s $1 2>/dev/null|grep -q installed; then
echo "$package_install ${msg[1]}"
else
zenity --error --text="$package_install ${err[1]}"
exit
fi
}
# switch lang
f_choose_msg_lang
# check for packages
f_check_package "mp3gain"
echo -n "${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}" | while read file ; do
report "mp3gain"
(
# echo and progress will pulsate
echo "10"
filename=$(basename "$file")
extension="${filename##*.}"
echo "# ${msg[2]}\n$filename"
if [ "$extension" != "mp3" ] && [ "$extension" != "MP3" ]; then
zenity --error --text="${err[2]}\n$filename"
exit
fi
# run mp3gain
# write result with $(commands) in message
# use option -r to "hardcode" repalygain
message=$(mp3gain -r "$file" 2>&1 && echo "Success")
#message=$(mp3gain "$file" 2>&1 && echo "Success")
# remove all characters right from 'S'
error=${message##*S}
if [ "$error" != "uccess" ]
then
echo "$message" | zenity --title="${err[4]}" --text-info --width=500 --height=200
fi
) | zenity --progress \
--title="${msg[4]}" --text="..." --width=500 --pulsate --auto-close
if [ "$?" = -1 ] ; then
zenity --error --text="${msg[5]}"
fi
done
exit