Stop echo to interpert control characters. Fixes #4

This commit is contained in:
Gabriel Ostrolucký 2019-03-28 10:01:45 +01:00
parent 9fa024d97d
commit c462b0c15b
No known key found for this signature in database
GPG Key ID: 0B618B95BA22CEEF
1 changed files with 7 additions and 7 deletions

View File

@ -8,21 +8,21 @@ url="https://www.reddit.com/r/$subreddit/.json?raw_json=1"
content=`wget -U "$useragent" -q -O - $url` content=`wget -U "$useragent" -q -O - $url`
mkdir -p $subreddit mkdir -p $subreddit
while : ; do while : ; do
urls=$(echo -e "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.preview.images[0].source.url') urls=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.preview.images[0].source.url')
names=$(echo -e "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.title') names=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.title')
ids=$(echo -e "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.id') ids=$(echo -n "$content"| jq -r '.data.children[]|select(.data.post_hint|test("image")) | .data.id')
a=1 a=1
wait # prevent spawning too many processes wait # prevent spawning too many processes
for url in $urls; do for url in $urls; do
name=`echo -e "$names"|sed -n "$a"p` name=`echo -n "$names"|sed -n "$a"p`
id=`echo -e "$ids"|sed -n "$a"p` id=`echo -n "$ids"|sed -n "$a"p`
ext=`echo -e "${url##*.}"|cut -d '?' -f 1` ext=`echo -n "${url##*.}"|cut -d '?' -f 1`
newname="$name"_"$subreddit"_$id.$ext newname="$name"_"$subreddit"_$id.$ext
echo $name echo $name
wget -U "$useragent" --no-check-certificate -nv -nc -P down -O "$subreddit/$newname" $url &>/dev/null & wget -U "$useragent" --no-check-certificate -nv -nc -P down -O "$subreddit/$newname" $url &>/dev/null &
a=$(($a+1)) a=$(($a+1))
done done
after=$(echo -e "$content"| jq -r '.data.after') after=$(echo -n "$content"| jq -r '.data.after')
if [ -z $after ]; then if [ -z $after ]; then
break break
fi fi