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

Commit

Permalink
--bigger-than flag added to try to download subtitles only for files …
Browse files Browse the repository at this point in the history
…bigger than the given size (in MB) - that way samples can be sift out
  • Loading branch information
Tomasz Wisniewski committed Feb 3, 2014
2 parents bebf872 + 6263f78 commit 7fe748d
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions napi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ g_MandatoryTools=( $g_Md5 'tr' 'printf'

# if pynapi is not acceptable then use "other" - in this case p7zip is
# required to finish processing
g_Revison="v1.1.9"
g_Revison="v1.1.10"
g_Version="pynapi"
#g_Version="other"

Expand All @@ -78,6 +78,9 @@ g_LogFile="none"
# default extension
g_DefaultExt="txt"

# minimum size
g_MinimumSize=0;

# statistical data
g_Skipped=0
g_Downloaded=0
Expand All @@ -93,6 +96,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 " -b | --bigger-than <size MB> - szukaj napisow tylko dla plikow wiekszych niz <size>"
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"
Expand Down Expand Up @@ -155,7 +159,7 @@ function check_extention
{
is_video=0
filename=$(basename "$1")
extention=$(echo "${filename##*.}" | tr [A-Z] [a-z])
extention=$(echo "${filename##*.}" | tr '[A-Z]' '[a-z]')

for ext in "${g_VideoUris[@]}"; do
if [[ "$ext" = "$extention" ]]; then
Expand Down Expand Up @@ -253,51 +257,29 @@ function get_cover
#
function prepare_file_list
{
list_creation_info=0

if [[ $# -gt 1 ]] && [[ ! -d "$1" ]] ; then
list_creation_info=1
echo "=================="
echo "Tworzenie listy plikow..."
echo "=================="
echo
fi

for file in "$@"; do

# check if file exists, if not skip it
if [[ ! -s "$file" ]]; then
if [[ -e "$file" ]] && [[ ! -s "$file" ]]; then
echo -e "[EMPTY]\t[\"$file\"]:\tPodany plik nie istnieje lub jest pusty !!!"
continue

# check if is a directory
# if so, then recursively search the dir
elif [[ -d "$file" ]]; then
echo "Przeszukuje zawartosc katalogu: [\"$file\"]..."

unset templist i
while IFS= read -r file2; do
local tmp="$file"
prepare_file_list "$tmp"/*

# check if the respective file is a video file (by extention)
if [[ $(check_extention "$file2") == 1 ]]; then
templist[i++]="$file2"
fi

done < <(find "$file" -type f)

echo "Katalog zawiera ${#templist[*]} plikow"
g_FileList=( "${g_FileList[@]}" "${templist[@]}" )
else
# check if the respective file is a video file (by extention)
if [[ $(check_extention "$file") -eq 1 ]]; then
if [[ $(check_extention "$file") -eq 1 ]] &&
[[ $(stat $g_StatParams "$file") -ge $(( $g_MinimumSize*1024*1024 )) ]]; then
g_FileList=( "${g_FileList[@]}" "$file" )
fi
fi
done

if [[ $list_creation_info -eq 1 ]]; then
echo "Lista gotowa."
fi
}

#
Expand Down Expand Up @@ -525,6 +507,15 @@ while [ $# -gt 0 ]; do
g_DefaultExt="$1"
;;

"-b" | "--bigger-than")
shift
if [[ -z "$1" ]]; then
f_printf_error "Nie okreslono minimalnego rozmiaru"
exit
fi
g_MinimumSize="$1"
;;


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

0 comments on commit 7fe748d

Please # to comment.