Revision: 1693
          http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1693&view=rev
Author:   jcsjcs
Date:     2007-09-15 06:19:23 -0700 (Sat, 15 Sep 2007)

Log Message:
-----------
        * scripts/ removed previous
          convert-{flac|ogg|mp3|m4a|wav}2{mp3|m4a} scripts and
          replaced with convert-2{mp3|m4a} drafted by Peter van der
          Does. These scripts share gtkpod-convert-common.sh.

          scripts/Makefile.am: added/removed the files mentioned above.

        * src/prefs.c: automatically replace prefs settings to use the
          new generic conversion scripts.

Modified Paths:
--------------
    gtkpod/trunk/ChangeLog_detailed
    gtkpod/trunk/scripts/Makefile.am
    gtkpod/trunk/src/file_convert.c
    gtkpod/trunk/src/misc.c
    gtkpod/trunk/src/prefs.c

Added Paths:
-----------
    gtkpod/trunk/scripts/convert-2m4a.sh
    gtkpod/trunk/scripts/convert-2mp3.sh
    gtkpod/trunk/scripts/gtkpod-convert-common.sh

Removed Paths:
-------------
    gtkpod/trunk/scripts/convert-flac2m4a.sh
    gtkpod/trunk/scripts/convert-flac2mp3.sh
    gtkpod/trunk/scripts/convert-m4a2mp3.sh
    gtkpod/trunk/scripts/convert-mp32m4a.sh
    gtkpod/trunk/scripts/convert-ogg2m4a.sh
    gtkpod/trunk/scripts/convert-ogg2mp3.sh
    gtkpod/trunk/scripts/convert-wav2m4a.sh
    gtkpod/trunk/scripts/convert-wav2mp3.sh

Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed     2007-09-15 06:37:22 UTC (rev 1692)
+++ gtkpod/trunk/ChangeLog_detailed     2007-09-15 13:19:23 UTC (rev 1693)
@@ -6,6 +6,16 @@
          loading the iTunesDB, libgpod will not read the ArtworkDB,
          thereby losing all artwork.
 
+       * scripts/ removed previous
+         convert-{flac|ogg|mp3|m4a|wav}2{mp3|m4a} scripts and
+         replaced with convert-2{mp3|m4a} drafted by Peter van der
+         Does. These scripts share gtkpod-convert-common.sh.
+
+         scripts/Makefile.am: added/removed the files mentioned above.
+
+       * src/prefs.c: automatically replace prefs settings to use the
+          new generic conversion scripts.
+
 2007-09-02  Todd Zullinger  <tmzullinger at users.sourceforge.net>
 
        * scripts/convert-m4a2mp3.sh: fixed a typo, spotted by Peter

Modified: gtkpod/trunk/scripts/Makefile.am
===================================================================
--- gtkpod/trunk/scripts/Makefile.am    2007-09-15 06:37:22 UTC (rev 1692)
+++ gtkpod/trunk/scripts/Makefile.am    2007-09-15 13:19:23 UTC (rev 1693)
@@ -20,16 +20,9 @@
        sync-webcalendar.sh \
        ldif2vcf.sh \
        mab2vcard \
-       convert-ogg2mp3.sh \
-       convert-ogg2m4a.sh \
-       convert-flac2mp3.sh \
-        convert-flac2m4a.sh \
-        convert-m4a2mp3.sh \
-        convert-mp32m4a.sh \
-        convert-ogg2mp3.sh \
-        convert-ogg2m4a.sh \
-        convert-wav2mp3.sh \
-        convert-wav2m4a.sh
+       convert-2mp3.sh \
+       convert-2mp4.sh \
+       gtkpod-convert-common.sh 
 
 # these scripts will of course also go in the distribution tarball.
 EXTRA_DIST=$(script_SCRIPTS)

Added: gtkpod/trunk/scripts/convert-2m4a.sh
===================================================================
--- gtkpod/trunk/scripts/convert-2m4a.sh                                (rev 0)
+++ gtkpod/trunk/scripts/convert-2m4a.sh        2007-09-15 13:19:23 UTC (rev 
1693)
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Script that converts a file into an mp3 file
+#
+# USAGE:
+#
+# convert-2mp3.sh [options] inputfile
+#
+# For a list of allowed options please consult gtkpod-convert-common.sh
+#
+# STDOUT's last line is the converted filename.
+# Return Codes:
+#   0 ok
+#   1 input file not found
+#   2 output file cannot be created
+#   3 cannot get info
+#   4 cannot exec decoding
+#   5 cannot exec encoding
+#   6 conversion failed
+#   7 unknown option
+#
+
+# Constants
+extension="m4a"
+ENCODER_OPTS="-q 150 -c 22000"
+ENCODER="faac"
+
+. ${0%/*}/gtkpod-convert-common.sh
+
+if [ $filetype = "wav" ]; then
+    "$encoder" -o "$outfile" $ENCODER_OPTS -w --artist "$artist" --title 
"$title" --year "$year" --album "$album" --track "$track" --genre "$genre" 
--comment "$comment" "$infile"
+else
+    "$decoder" $options "$infile" | "$encoder" -o "$outfile" $ENCODER_OPTS -w 
--artist "$artist" --title "$title" --year "$year" --album "$album" --track 
"$track" --genre "$genre" --comment "$comment" -
+fi
+# Check result
+if [ "x$?" != "x0" ]; then
+    exit 6
+fi
+
+# Seems to be ok: display filename for gtkpod
+echo $outfile
+exit 0


Property changes on: gtkpod/trunk/scripts/convert-2m4a.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: gtkpod/trunk/scripts/convert-2mp3.sh
===================================================================
--- gtkpod/trunk/scripts/convert-2mp3.sh                                (rev 0)
+++ gtkpod/trunk/scripts/convert-2mp3.sh        2007-09-15 13:19:23 UTC (rev 
1693)
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Script that converts a file into an mp3 file
+#
+# USAGE:
+#
+# convert-2mp3.sh [options] inputfile
+#
+# For a list of allowed options please consult gtkpod-convert-common.sh
+#
+# STDOUT's last line is the converted filename.
+# Return Codes:
+#   0 ok
+#   1 input file not found
+#   2 output file cannot be created
+#   3 cannot get info
+#   4 cannot exec decoding
+#   5 cannot exec encoding
+#   6 conversion failed
+#   7 unknown option
+#
+
+# Constants
+extension="mp3"
+ENCODER_OPTS="--preset standard"
+ENCODER="lame"
+
+. ${0%/*}/gtkpod-convert-common.sh
+
+# Check if the genre is one which lame supports
+if [ -n "$genre" ] && `"$encoder" --genre-list | grep -qi "\b$genre\b"`; then
+    genreopt="--tg \"$genre\""
+else
+    # check for id3v2
+    id3v2=`which id3v2`
+    if [ -n "$id3v2" ]; then
+        useid3v2=1
+    fi
+fi
+
+if [ $filetype = "wav" ]; then
+    "$encoder" $ENCODER_OPTS --add-id3v2 --tt "$title" --ta "$artist" --tl 
"$album" --ty "$year" --tc "$comment" --tn "$track" "$genreopt" "$infile" 
"$outfile"
+else
+    "$decoder" $options "$infile" | "$encoder" $ENCODER_OPTS --add-id3v2 --tt 
"$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn 
"$track" "$genreopt" - "$outfile"
+fi
+# Check result
+if [ "x$?" != "x0" ]; then
+    exit 6
+fi
+
+# Try to set the genre with id3v2 if needed.  This may fail as older versions 
of
+# id3v2 did not support genre strings in place of numeric genre id's
+if [ -n "$useid3v2" ]; then
+    $id3v2 -g "$genre" "$mp3file" || :
+fi
+
+# Seems to be ok: display filename for gtkpod
+echo $outfile
+exit 0


Property changes on: gtkpod/trunk/scripts/convert-2mp3.sh
___________________________________________________________________
Name: svn:executable
   + *

Deleted: gtkpod/trunk/scripts/convert-flac2m4a.sh
===================================================================
--- gtkpod/trunk/scripts/convert-flac2m4a.sh    2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-flac2m4a.sh    2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,98 +0,0 @@
-#!/bin/sh
-# Simple script that converts a flac file into an m4a file
-#
-# USAGE:
-#
-# convert-flac2m4a.sh [options] flacfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="m4a"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with faac"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of flac
-flac=`which flac`
-if [ -z "$flac" ]; then
-    exit 4
-fi
-
-# Check for the existence of faac
-faac=`which faac`
-if [ -z "$faac" ]; then
-    exit 5
-fi
-
-# Launch command
-exec "$flac" -d -c -- "$infile" | "$faac" -o "$outfile" -q 150 -c 22000 -w 
--artist "$artist" --title "$title" --year "$year" --album "$album" --track 
"$track" --genre "$genre" --comment "$comment" -
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-flac2mp3.sh
===================================================================
--- gtkpod/trunk/scripts/convert-flac2mp3.sh    2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-flac2mp3.sh    2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,115 +0,0 @@
-#!/bin/sh
-# Simple script that converts a flac file into an mp3 file
-#
-# USAGE:
-#
-# convert-flac2mp3.sh [options] flacfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="mp3"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with lame"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of flac
-flac=`which flac`
-if [ -z "$flac" ]; then
-    exit 4
-fi
-
-# Check for the existence of lame
-lame=`which lame`
-if [ -z "$lame" ]; then
-    exit 5
-fi
-
-# Check if the genre is one which lame supports
-if [ -n "$genre" ] && `$lame --genre-list | grep -qi "\b$genre\b"`; then
-    genreopt="--tg \"$genre\""
-else
-    # check for id3v2
-    id3v2=`which id3v2`
-    if [ -n "$id3v2" ]; then
-        useid3v2=1
-    fi
-fi
-
-# Launch command
-exec "$flac" -d -c -- "$infile" | "$lame" --preset standard --add-id3v2 --tt 
"$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn 
"$track" "$genreopt" - "$outfile"
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-
-# Try to set the genre with id3v2 if needed.  This may fail as older versions 
of
-# id3v2 did not support genre strings in place of numeric genre id's
-if [ -n "$useid3v2" ]; then
-    $id3v2 -g "$genre" "$mp3file" || :
-fi
-
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-m4a2mp3.sh
===================================================================
--- gtkpod/trunk/scripts/convert-m4a2mp3.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-m4a2mp3.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,97 +0,0 @@
-#!/bin/sh
-# Simple script that converts an m4a file into an mp3 file
-#
-# USAGE:
-#
-# convert-m4a2mp3.sh [options] m4afile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="mp3"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with lame"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of faad
-faad=`which faad`
-if [ -z "$faad" ]; then
-    exit 4
-fi
-
-# Check for the existence of lame
-lame=`which lame`
-if [ -z "$lame" ]; then
-    exit 5
-fi
-
-# Launch command
-exec "$faad" -o - "$infile" | "$lame" --preset standard --add-id3v2 --tt 
"$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn 
"$track" --tg "$genre" - "$outfile"
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-mp32m4a.sh
===================================================================
--- gtkpod/trunk/scripts/convert-mp32m4a.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-mp32m4a.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,97 +0,0 @@
-#!/bin/sh
-# Simple script that converts an mp3 file into an m4a file
-#
-# USAGE:
-#
-# convert-mp32m4a.sh [options] mp3file
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="m4a"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with faac"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of lame
-lame=`which lame`
-if [ -z "$lame" ]; then
-    exit 4
-fi
-
-# Check for the existence of faac
-faac=`which faac`
-if [ -z "$faac" ]; then
-    exit 5
-fi
-
-# Launch command
-exec "$lame" --decode "$infile" - | "$faac" -o "$outfile" -q 150 -c 22000 -w 
--artist "$artist" --title "$title" --year "$year" --album "$album" --track 
"$track" --genre "$genre" --comment "$comment" -
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-ogg2m4a.sh
===================================================================
--- gtkpod/trunk/scripts/convert-ogg2m4a.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-ogg2m4a.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,97 +0,0 @@
-#!/bin/sh
-# Simple script that converts a ogg file into an m4a file
-#
-# USAGE:
-#
-# convert-ogg2m4a.sh [options] oggfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="m4a"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with faac"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of oggdec
-oggdec=`which oggdec`
-if [ -z "$oggdec" ]; then
-    exit 4
-fi
-
-# Check for the existence of faac
-faac=`which faac`
-if [ -z "$faac" ]; then
-    exit 5
-fi
-
-# Launch command
-exec "$oggdec" --output - -- "$infile" | "$faac" -o "$outfile" -q 150 -c 22000 
-w --artist "$artist" --title "$title" --year "$year" --album "$album" --track 
"$track" --genre "$genre" --comment "$comment" -
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-ogg2mp3.sh
===================================================================
--- gtkpod/trunk/scripts/convert-ogg2mp3.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-ogg2mp3.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,115 +0,0 @@
-#!/bin/sh
-# Simple script that converts a ogg file into an mp3 file
-#
-# USAGE:
-#
-# convert-ogg2mp3.sh [options] oggfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="mp3"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with lame"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of oggdec
-oggdec=`which oggdec`
-if [ -z "$oggdec" ]; then
-    exit 4
-fi
-
-# Check for the existence of lame
-lame=`which lame`
-if [ -z "$lame" ]; then
-    exit 5
-fi
-
-# Check if the genre is one which lame supports
-if [ -n "$genre" ] && `$lame --genre-list | grep -qi "\b$genre\b"`; then
-    genreopt="--tg \"$genre\""
-else
-    # check for id3v2
-    id3v2=`which id3v2`
-    if [ -n "$id3v2" ]; then
-        useid3v2=1
-    fi
-fi
-
-# Launch command
-exec "$oggdec" --output - -- "$infile" | "$lame" --preset standard --add-id3v2 
--tt "$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn 
"$track" "$genreopt" - "$outfile"
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-
-# Try to set the genre with id3v2 if needed.  This may fail as older versions 
of
-# id3v2 did not support genre strings in place of numeric genre id's
-if [ -n "$useid3v2" ]; then
-    $id3v2 -g "$genre" "$outfile" || :
-fi
-
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-wav2m4a.sh
===================================================================
--- gtkpod/trunk/scripts/convert-wav2m4a.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-wav2m4a.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,91 +0,0 @@
-#!/bin/sh
-# Simple script that converts a wav file into an m4a file
-#
-# USAGE:
-#
-# convert-wav2m4a.sh [options] wavfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="m4a"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with faac"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of faac
-faac=`which faac`
-if [ -z "$faac" ]; then
-    exit 5
-fi
-
-# Launch command
-"$faac" -o "$outfile" -q 150 -c 22000 -w --artist "$artist" --title "$title" 
--year "$year" --album "$album" --track "$track" --genre "$genre" --comment 
"$comment" "$infile"
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Deleted: gtkpod/trunk/scripts/convert-wav2mp3.sh
===================================================================
--- gtkpod/trunk/scripts/convert-wav2mp3.sh     2007-09-15 06:37:22 UTC (rev 
1692)
+++ gtkpod/trunk/scripts/convert-wav2mp3.sh     2007-09-15 13:19:23 UTC (rev 
1693)
@@ -1,109 +0,0 @@
-#!/bin/sh
-# Simple script that converts a wav file into an mp3 file
-#
-# USAGE:
-#
-# convert-wav2mp3.sh [options] wavfile
-#
-#       -x      Print converted filename extension and exit
-#       -f      Set converted filename
-#      -a      Artist tag
-#      -A      Album tag
-#      -T      Track tag
-#      -t      Title tag
-#      -g      Genre tag
-#      -y      Year tag
-#      -c      Comment tag
-#
-# STDOUT's last line is the converted filename.
-# Return Codes:
-#   0 ok
-#   1 input file not found
-#   2 output file cannot be created
-#   3 cannot get info
-#   4 cannot exec decoding
-#   5 cannot exec encoding
-#   6 conversion failed
-#   7 unknown option
-
-# Constants
-extension="mp3"
-
-# Get parameters
-while getopts a:A:T:t:g:c:y:f:x opt ; do
-       case "$opt" in
-               x)      echo "$extension"; exit 0 ;;
-               f)      outfile="$OPTARG" ;;
-               a)      artist="$OPTARG" ;;
-               A)      album="$OPTARG" ;;
-               T)      track="$OPTARG" ;;
-               t)      title="$OPTARG" ;;
-               g)      genre="$OPTARG" ;;
-               y)      year="$OPTARG" ;;
-               c)      comment="$OPTARG" ;;
-               ?)      exit 7 ;;
-       esac
-done
-shift $(($OPTIND - 1))
-infile="$1"
-
-if [ "$outfile" = "" ]; then
-    # Build output file
-    outfile=`basename "$infile"`
-    outfile=${outfile%%.flac}
-    outfile="/tmp/$outfile.$extension"
-fi
-
-# Default values
-[ -z "$comment" ] && comment="Encoded for gtkpod with lame"
-
-#echo "Converting \"$infile\" into \"$outfile\""
-
-# Checking input file
-if [ "$infile" = "" ]; then
-    exit 1
-fi
-if [ ! -f "$infile" ]; then
-    exit 1
-fi
-
-# Checking output file
-touch "$outfile"
-if [ "x$?" != "x0" ]; then
-    exit 2
-fi
-
-# Check for the existence of lame
-lame=`which lame`
-if [ -z "$lame" ]; then
-    exit 5
-fi
-
-# Check if the genre is one which lame supports
-if [ -n "$genre" ] && `$lame --genre-list | grep -qi "\b$genre\b"`; then
-    genreopt="--tg \"$genre\""
-else
-    # check for id3v2
-    id3v2=`which id3v2`
-    if [ -n "$id3v2" ]; then
-        useid3v2=1
-    fi
-fi
-
-# Launch command
-"$lame" --preset standard --add-id3v2 --tt "$title" --ta "$artist" --tl 
"$album" --ty "$year" --tc "$comment" --tn "$track" "$genreopt" "$infile" 
"$outfile"
-
-# Check result
-if [ "x$?" != "x0" ]; then
-    exit 6
-fi
-
-# Try to set the genre with id3v2 if needed.  This may fail as older versions 
of
-# id3v2 did not support genre strings in place of numeric genre id's
-if [ -n "$useid3v2" ]; then
-    $id3v2 -g "$genre" "$outfile" || :
-fi
-
-# Seems to be ok: display filename for gtkpod
-echo $outfile
-exit 0

Added: gtkpod/trunk/scripts/gtkpod-convert-common.sh
===================================================================
--- gtkpod/trunk/scripts/gtkpod-convert-common.sh                               
(rev 0)
+++ gtkpod/trunk/scripts/gtkpod-convert-common.sh       2007-09-15 13:19:23 UTC 
(rev 1693)
@@ -0,0 +1,106 @@
+#!/bin/sh
+# Script that converts a file into an mp3 file
+#
+# USAGE:
+#
+# Called by convert-2mp3.sh and convert-2m4a.sh.
+#
+# The following command line arguments are being used
+#
+#       -x      Print converted filename extension and exit
+#       -f      Set converted filename
+#      -a      Artist tag
+#      -A      Album tag
+#      -T      Track tag
+#      -t      Title tag
+#      -g      Genre tag
+#      -y      Year tag
+#      -c      Comment tag
+#      -q      Quality (overwrites standard encoder options)
+#               For mp3 files this could be "--vbr-new -V<number>".
+#
+# Return Codes:
+#   0 ok
+#   1 input file not found
+#   2 output file cannot be created
+#   3 cannot get info
+#   4 cannot exec decoding
+#   5 cannot exec encoding
+#   6 conversion failed
+#   7 unknown option
+
+# Get parameters
+while getopts q:a:A:T:t:g:c:y:f:x opt ; do
+       case "$opt" in
+               x)      echo "$extension"; exit 0 ;;
+               f)      outfile="$OPTARG" ;;
+               a)      artist="$OPTARG" ;;
+               A)      album="$OPTARG" ;;
+               T)      track="$OPTARG" ;;
+               t)      title="$OPTARG" ;;
+               g)      genre="$OPTARG" ;;
+               y)      year="$OPTARG" ;;
+               c)      comment="$OPTARG" ;;
+               q)      ENCODER_OPTS="$OPTARG" ;;
+               ?)      exit 7 ;;
+       esac
+done
+shift $(($OPTIND - 1))
+
+infile="$1"
+infile_extension=${infile##*.}
+
+# Convert the source parameters to lowercase.
+filetype=`echo ${infile_extension}| tr [:upper:] [:lower:]`
+if [ $filetype != flac ] && [ $filetype != ogg ] && [ $filetype != wav ] && [ 
$filetype != m4a ]; then
+    exit 4
+fi
+
+if [ "$outfile" = "" ]; then
+    # Build output file
+    outfile=`basename "$infile"`
+    outfile=${outfile%.$infile_extension}
+    tmp=${TMPDIR-/tmp}
+    outfile="$tmp/$outfile.$extension"
+fi
+
+# Default values
+[ -z "$comment" ] && comment="Encoded for gtkpod with $ENCODER"
+
+# echo "Converting \"$infile\" into \"$outfile\""
+
+# Checking input file
+if [ "$infile" = "" ]; then
+    exit 1
+fi
+if [ ! -f "$infile" ]; then
+    exit 1
+fi
+
+# Checking output file
+touch "$outfile"
+if [ "x$?" != "x0" ]; then
+    exit 2
+fi
+
+# Check for the existence of encoder
+encoder=`which $ENCODER`
+if [ -z "$encoder" ]; then
+    exit 5
+fi
+
+# Determine decoder
+case $filetype in
+       flac)   decoder="flac" ; options="-d -c --"  ;;
+       ogg)    decoder="oggdec" ; options="--output - --" ;;
+       m4a)    decoder="faad" ; options="-o -" ;;
+       wav)    decoder="" ;;
+esac
+
+# Check for the existence of decoder
+if [ $decoder ]; then
+    decoder=`which "$decoder"`
+    if [ -z "$decoder" ]; then
+        exit 4
+    fi
+fi


Property changes on: gtkpod/trunk/scripts/gtkpod-convert-common.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: gtkpod/trunk/src/file_convert.c
===================================================================
--- gtkpod/trunk/src/file_convert.c     2007-09-15 06:37:22 UTC (rev 1692)
+++ gtkpod/trunk/src/file_convert.c     2007-09-15 13:19:23 UTC (rev 1693)
@@ -2086,7 +2086,7 @@
        {
            gchar *buf = conversion_get_track_info (NULL, ctr);
            ctr->errormessage =
-               g_strdup_printf (_("Conversion of '%s' failed: '%s %s' did not 
return filename extension as expected.\n\n"),
+               g_strdup_printf (_("Conversion of '%s' failed: '\"%s\" %s' did 
not return filename extension as expected.\n\n"),
                                 buf,
                                 argv[0], argv[1]);
            g_free (buf);

Modified: gtkpod/trunk/src/misc.c
===================================================================
--- gtkpod/trunk/src/misc.c     2007-09-15 06:37:22 UTC (rev 1692)
+++ gtkpod/trunk/src/misc.c     2007-09-15 13:19:23 UTC (rev 1693)
@@ -427,6 +427,11 @@
 
 /* Create a NULL-terminated array of strings given in the command
    line. The last argument must be NULL.
+
+   As a special feature, the first argument is split up into
+   individual strings to allow the use of "convert-2mp3 -q <special
+   settings>". Set the first argument to NULL if you don't want this.
+
    You must free the returned array with g_strfreev() after use. */
 gchar **build_argv_from_strings (const gchar *first_arg, ...)
 {
@@ -435,19 +440,31 @@
     const gchar *str;
     GPtrArray *ptra = g_ptr_array_sized_new (20);
 
-    g_ptr_array_add (ptra, g_strdup (first_arg));
-    /* add the rest of the strings */
     if (first_arg)
     {
-       va_start (args, first_arg);
-       do
+       gchar **strings = g_strsplit (first_arg, " ", 0);
+       gchar **strp = strings;
+       while (*strp)
        {
-           str = va_arg (args, const gchar *);
-           g_ptr_array_add (ptra, g_strdup (str));
+           if (**strp)
+           {   /* ignore empty strings */
+               g_ptr_array_add (ptra, g_strdup(*strp));
+           }
+           ++strp;
        }
-       while (str);
-       va_end (args);
+       g_strfreev (strings);
     }
+
+    va_start (args, first_arg);
+    do
+    {
+       str = va_arg (args, const gchar *);
+       g_ptr_array_add (ptra, g_strdup (str));
+    }
+    while (str);
+
+    va_end (args);
+
     argv = (gchar **)g_ptr_array_free (ptra, FALSE);
 
     return argv;

Modified: gtkpod/trunk/src/prefs.c
===================================================================
--- gtkpod/trunk/src/prefs.c    2007-09-15 06:37:22 UTC (rev 1692)
+++ gtkpod/trunk/src/prefs.c    2007-09-15 13:19:23 UTC (rev 1693)
@@ -1192,7 +1192,49 @@
     /* For versions < 0.91, remove all itdb keys */
     if (version < 0.91)
        prefs_flush_subkey("itdb_");
-   
+
+    /* rename convert scripts */
+    if (version <= 0.99001)
+    {
+
+       const gchar **keyp;
+       const gchar *keys[] =
+           {"path_conv_m4a", "path_conv_wav", "path_conv_mp3",
+            "path_conv_ogg", "path_conv_flac", NULL};
+
+       for (keyp=keys; *keyp; ++keyp)
+       {
+           buf = prefs_get_string (*keyp);
+           if (buf)
+           {
+               const gchar *needles[] =
+                   { "convert-flac2mp3.sh", "convert-m4a2mp3.sh",
+                     "convert-ogg2mp3.sh", "convert-wav2mp3.sh",
+                     "convert-flac2m4a.sh", "convert-m4a2m4a.sh",
+                     "convert-ogg2m4a.sh", "convert-wav2m4a.sh", NULL };
+               const gchar *replacements[] =
+                   { "convert-2mp3.sh    ", "convert-2mp3.sh   ",
+                     "convert-2mp3.sh   ", "convert-2mp3.sh   " ,
+                     "convert-2m4a.sh    ", "convert-2m4a.sh   ",
+                     "convert-2m4a.sh   ", "convert-2m4a.sh   " };
+               const gchar **needlep;
+               const gchar **replp;
+               replp = replacements;
+               for (needlep=needles; *needlep; ++needlep, ++replp)
+               {
+                   gchar *bufp = strstr (buf, *needlep);
+                   if (bufp)
+                   {
+                       g_memmove (bufp, *replp, strlen (*replp));
+                       prefs_set_string (*keyp, buf);
+                       break;
+                   }
+               }
+               g_free (buf);
+           }
+       }
+    }
+
     prefs_set_string ("version", VERSION);
 }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to