Name the output folder as argument
This commit is contained in:
parent
1cc991b47a
commit
8aa7a529dc
5
rdit.sh
5
rdit.sh
|
@ -1,13 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#cfg
|
#cfg
|
||||||
output="down"
|
|
||||||
useragent="Love by u/gadelat"
|
useragent="Love by u/gadelat"
|
||||||
|
|
||||||
subreddit=$1
|
subreddit=$1
|
||||||
url="https://www.reddit.com/r/$subreddit/.json?raw_json=1"
|
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 $output
|
mkdir -p $subreddit
|
||||||
while : ; do
|
while : ; do
|
||||||
urls=$(echo -e "$content"|grep -Po '"source": {"url":.*?[^\\]",'|cut -f 6 -d '"')
|
urls=$(echo -e "$content"|grep -Po '"source": {"url":.*?[^\\]",'|cut -f 6 -d '"')
|
||||||
names=$(echo -e "$content"|grep -Po '"title":.*?[^\\]",'|cut -f 4 -d '"')
|
names=$(echo -e "$content"|grep -Po '"title":.*?[^\\]",'|cut -f 4 -d '"')
|
||||||
|
@ -19,7 +18,7 @@ while : ; do
|
||||||
id=`echo -e "$ids"|sed -n "$a"p`
|
id=`echo -e "$ids"|sed -n "$a"p`
|
||||||
echo $name
|
echo $name
|
||||||
newname="$name"_"$subreddit"_$id.${url##*.}
|
newname="$name"_"$subreddit"_$id.${url##*.}
|
||||||
wget -U "$useragent" --no-check-certificate -nv -nc -P down -O "$output/$newname" $url
|
wget -U "$useragent" --no-check-certificate -nv -nc -P down -O "$subreddit/$newname" $url
|
||||||
fi
|
fi
|
||||||
a=$(($a+1))
|
a=$(($a+1))
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue