Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ksh
- #
- # Re-encode mp3 files shipped by EVE Online's Windows client for use with wine
- # Run in ~/.wine/drive_c/Program\ Files/CCP/EVE/res/audio/Jukebox
- #
- # Copyright 2011 Waveclaw.net
- # License: GPL
- # Warranty: not suitable for any purpose, use at your own risk!
- #
- # Version History
- #
- # 2005-08-11 JDP mangle-sound.sh based on _Linux_Server_Hacks_
- # 2003 Rob Flickenger, O'Reilly
- # 2009-03-24 JDP Convert id3v2 to getMplayerID Perl script for tags
- # 2011-02-10 JDP Specialize mangle-sound.sh for remasting Eve files
- # 2011-02-11 JDP Posted Stripped Version to pastebin
- # 2011-02-12 JDP Replace getMplayerID perl script with mplayer
- # 2011-02-13 JDP Cleanup, restore comments and repost to pastebin
- # 2011-02-15 JDP Fix backwards variable substitution in get_all_tags
- #
- PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:~/bin
- EXT=mp3
- DATE=`date +%Y%m%d`
- BACKUP_LOCATION=backup.$DATE
- if [ 0 -eq $UID ];
- then
- echo "Please do not run `basename $0` as root!"
- exit;
- fi
- is_installed() {
- PROGRAM=$1
- PATHNAME=$( type $PROGRAM 2> /dev/null )
- if [ -z "$PATHNAME" ]; then
- echo "cannot locate $PROGRAM in path"
- exit 1
- fi
- }
- get_tag() {
- TAG=$1
- FILE=$2
- $MPLAYER -vo null -ao null -frames 0 -identify $FILE 2>/dev/null \
- | grep "${TAG}:" | sed -e "s/${TAG}: //g"
- }
- get_all_tags() {
- FILE=$1
- TITLE=`get_tag Title "$FILE"`; TITLE=${TITLE:-"$FILE"}
- COMMENT=`get_tag Comment "$FILE"`; COMMENT=${COMMENT:-'Unknown'}
- ALBUM=`get_tag Album "$FILE"` ; ALBUM=${ALBUM:-'EVE Online'}
- ARTIST=`get_tag Artist "$FILE"` ; ARTIST=${ARTIST:-'Jon Hailur'}
- #No Year, Genre or Track on Eve files
- # YEAR=`get_tag Year "$NAME"`
- # GENRE=`get_tag Genre "$FILE"`'
- # TRACK=`get_tag Track "$NAME"`
- YEAR=`date +%Y`
- GENRE=soundtrack
- TRACK="${FILE#Ambient}"
- TRACK="${TRACK%%.$EXT}"
- }
- decode_file() {
- FILE=$1
- $MPLAYER -vc null -vo null -ao pcm:fast $FILE 2>&1 >/dev/null
- mv audiodump.wav "${FILE%%.$EXT}.wav"
- }
- encode_file() {
- FILE="${1%%.$EXT}"
- $LAME "$FILE.wav" --tt "$TITLE" --tl "$ALBUM" --ta "$ARTIST" \
- --tg "$GENRE" --ty "$YEAR" --tn "$TRACK"
- mv "$FILE.wav.$EXT" "$FILE.$EXT"
- }
- is_installed mplayer
- MPLAYER=`which mplayer`
- is_installed lame
- LAME=`which lame`
- mkdir -p $BACKUP_LOCATION
- echo "Remastering all MP3 files in current directory!"
- echo "Originals backuped up to $BACKUP_LOCATION"
- for NAME in *.${EXT};
- do
- echo "Processing $NAME"
- echo "--------------------------------------------------------------"
- # tags
- get_all_tags $NAME
- echo "Title: $TITLE"
- echo "Genre: $GENRE"
- echo "Comment: $COMMENT"
- echo "Album: $ALBUM"
- echo "Artist: $ARTIST"
- echo "Year: $YEAR"
- echo "Track: $TRACK"
- # convert
- decode_file "$NAME"
- # backup
- if [ -d "$BACKUP_LOCATION" ]
- then
- mv "$NAME" "$BACKUP_LOCATION"
- else
- echo "Could not backup $NAME"
- exit 1
- fi
- # replace
- encode_file "$NAME"
- # cleanup
- rm "$FILE.wav"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement