Guest User

Untitled

a guest
Mar 19th, 2010
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #cueape 0.1
  4. #This script is intended to convert ape or flac + cue files to
  5. #ogg vorbis or mp3 files, setting the tags to the correct value,
  6. #obtained from the cue file.
  7. #REQUIREMENTS:
  8. #   -Oggenc installed (it comes with vorbis-tools) if you want to encode into Ogg Vorbis.
  9. #   -lame installed if you want to encode into mp3
  10. #   -mac to decode ape files (Monkey's Audio)
  11. #   -flac to decode flac files.
  12.  
  13. #IF YOU FIND A BUG OR HAVE A SUGGESTION COMMENTO OR SIMPLY WANT TO CONTACT ME PLEASE MAIL ME TO
  14. #rafadev_*@gmail.com  REMOVING THE "_*"
  15. #This is done to prevent spamming
  16.  
  17. #Copyright (C) 2006  Rafael Ponieman - Buenos Aires, Argentina
  18.  
  19. #This program is free software; you can redistribute it and/or
  20. #modify it under the terms of the GNU General Public License
  21. #as published by the Free Software Foundation; either version 2
  22. #of the License, or (at your option) any later version.
  23.  
  24. #This program is distributed in the hope that it will be useful,
  25. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. #GNU General Public License for more details.
  28.  
  29. #You should have received a copy of the GNU General Public License
  30. #along with this program; if not, write to the Free Software
  31. #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  32.  
  33.  
  34. #scripted by deX
  35.  
  36.  
  37. case "$1" in
  38. *.[aA][pP][eE] | *[fF][lL][aA][cC]  )
  39.     if [ ! -f "$1" ] ; then
  40.         echo "Input file $1 doesn't exist"
  41.         exit 1
  42.     fi
  43.     if [ ! -f "$2" ]; then
  44.         echo "Cue input file $2 doesn't exist"
  45.         exit 1
  46.     fi ;;
  47. *   )
  48.     echo "Error: invalid input parameters"
  49.     exit ;;
  50. esac
  51.  
  52. #Testing parameters
  53. if [ "$3" != "-m" ] && [ "$3" != "-o" ] ; then
  54.     echo -en "Invalid parameters\n"
  55.     echo -en ""
  56.     echo -en "Usage: cueape [input ape file] [input cue file] [parameters]\nParameters can be: -m for mp3 encoding or -o for ogg encoding.\n"
  57.     exit 1
  58. fi
  59.  
  60. #Need help with this one, coudn't solve it. I need to know how to check if a
  61. #program actually exists and is accesible
  62. #Checking for mac
  63. #[ -f $(which 'maca' >> /dev/null) ] ||  {
  64. #   echo -en "You must have mac in your PATH.\nPlease install Monkey's Audio Codec\nYou can get it from http://sourceforge.net/projects/mac-port/\n"
  65. #}
  66.  
  67.  
  68. #Saving the position so as to return afterwards
  69. olddir="$(pwd)"
  70.  
  71. #Going to target directory
  72. cd "$(dirname "$1")"
  73.  
  74. #Checking for the output folder. If it's not there I create it
  75. [ ! -d "Output" ] && mkdir -p "Output"
  76. cp "$2" "Output/"
  77.  
  78. #Decompress
  79. echo -en "\nCueape 0.1\n\n"
  80. echo -en "Starting conversion\n"
  81.  
  82. #Checking filetype by extension and decompressing
  83. tmp="$(basename "$1")"
  84. tmp="${tmp##*.}"
  85.  
  86. case "$tmp" in
  87. [fF][lL][aA][cC]    )  
  88.     echo -en "Decompressing FLAC file\n\n"
  89.     echo -en ""
  90.     tm="$(basename "$1")"
  91.     tm="${tm%.[fF][lL][aA][cC]}"
  92.     out="$(flac "-d" "$1" -o "Output/${tm}.wav" )"
  93.     ;;
  94. [aA][pP][eE]        )
  95.     echo -en "Decompressing APE file\n\n"
  96.     echo -en ""
  97.     tm="$(basename "$1")"
  98.     tm="${tm%.[aA][pP][eE]}"
  99.     out="$(mac "$1" "Output/${tm}.wav" "-d")"
  100.     ;;
  101. *           )
  102.     echo "Error: line 99"
  103. esac
  104.  
  105. cd "Output"
  106. echo -en "\nDecompression finished\n"
  107. echo -en "Starting reencoding\n\n"
  108. echo -en ""
  109. if [ "$3" = "-o" ] ; then
  110.     #Calling oggenc. Saving output for future checking
  111.     out="$(oggenc -q 6 -o "$tm.ogg" "$tm.wav")"
  112.     echo -en "\nReencoding finished\n"
  113.     echo -en "Splitting\n\n"
  114.     echo -en ""
  115.     out="$(mp3splt -c "$(basename "$2")" -o "@n+-+@t" "$tm.ogg")"
  116. else
  117.     #Calling lame. Saving output for future checking
  118.     out="$(lame --preset extreme "$tm.wav" "$tm.mp3")"
  119.     echo -en "\nReencoding finished\n"
  120.     echo -en "Splitting\n\n"
  121.     echo -en ""
  122.     #Using framemode becaus this settings are for VBR
  123.     out="$(mp3splt -f -c "$(basename "$2")" -o "@n+-+@t" "$tm.mp3")"
  124. fi
  125. cd "$oldir"
  126. echo -en "\nProcessing finished successfully\n"
  127. echo -en ""
  128. exit 0
Advertisement
Add Comment
Please, Sign In to add comment