Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
default extension implemented as an argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dagon666 committed Oct 25, 2013
1 parent 58563d2 commit 843dc6b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions napi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ g_FpsTool=""
g_Fps=0
g_LogFile="none"

# default extension
g_DefaultExt="txt"

# statistical data
g_Skipped=0
g_Downloaded=0
Expand All @@ -78,6 +81,7 @@ function display_help
echo "napi.sh version $g_Revison (identifies as $g_Version)"
echo "napi.sh [OPCJE] <plik|katalog|*>"
echo " -c | --cover - pobierz okladke"
echo " -e | --ext - rozszerzenie dla pobranych napisow (domyslnie *.txt)"
echo " -s | --skip - nie sciagaj, jezeli napisy juz sciagniete"
echo " -u | --user <login> - uwierzytelnianie jako uzytkownik"
echo " -p | --pass <passwd> - haslo dla uzytkownika <login>"
Expand Down Expand Up @@ -301,17 +305,17 @@ function download_subs
# input/output filename manipulation
base=$(basename "$file")
output_path=$(dirname "$file")
output="$output_path/${base%.*}.txt"
output_img="$output_path/${base%.*}.jpg"
conv_output="$output_path/ORIG_${base%.*}.txt"
output="$output_path/${base%.*}.$g_DefaultExt"
output_img="$output_path/${base%.*}.jpg"
conv_output="$output_path/ORIG_${base%.*}.$g_DefaultExt"
fExists=0

if [[ -e "$output" ]] || [[ -e "$conv_output" ]]; then
fExists=1
fi

if [[ $fExists -eq 1 ]] && [[ $g_Skip -eq 1 ]]; then
echo -e "[SKIP]\t[${base%.*}.txt]:\tPlik z napisami juz istnieje !!!"
echo -e "[SKIP]\t[${base%.*}.$g_DefaultExt]:\tPlik z napisami juz istnieje !!!"
g_Skipped=$(( $g_Skipped + 1 ))
continue
else
Expand All @@ -329,7 +333,7 @@ function download_subs
echo " -- Konwertuje napisy do formatu: [$g_Format]"

# determine the output extention and the output filename
# if ext == txt then copy the original with a ORIG_ prefix
# if ext == $g_DefaultExt then copy the original with a ORIG_ prefix
case "$g_Format" in
"subrip")
outputSubs="$output_path/${base%.*}.srt"
Expand Down Expand Up @@ -498,6 +502,17 @@ while [ $# -gt 0 ]; do
g_Pass="$1"
;;

# extension
"-e" | "--ext")
shift
if [[ -z "$1" ]]; then
f_printf_error "Nie okreslono domyslnego rozszerzenia dla pobranych plikow"
exit
fi
g_DefaultExt="$1"
;;


# logfile
"-l" | "--log")
shift
Expand Down

0 comments on commit 843dc6b

Please # to comment.