-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget.xbooru.sh
61 lines (51 loc) · 1.49 KB
/
get.xbooru.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Юзергаент
uag="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0"
# Проверка параметров
if [ ! "$2" = "" ]
then
tags=$1
savedir=$2
else
if [ ! "$1" = "" ]
then
tags=$1
savedir=$1
else
echo Использование:
echo `basename $0` теги \[каталог\]
exit 1
fi
fi
# Каталог для закачки
if [ ! -d $savedir ]
then
echo Creating $savedir...
mkdir "$savedir"
fi
echo Entering $savedir
cd "$savedir"
# Количество постов
postcount=`curl --compressed -# "https://xbooru.com/index.php?page=dapi&s=post&q=index&tags=$tags&limit=1" -A "$uag"|pcregrep -o 'count=\"[^"]+'|sed -e 's/count=//' -e 's/\"//'`
# Проверка количества
if [ $postcount -eq 0 ]
then
echo По сочетанию "$tags" ничего не найдено.
exit 3
else
echo По сочетанию "$tags" найдено постов: $postcount
fi
# Удаление файла-списка
if [ -s get2.xbooru.txt ]
then
rm -f get2.xbooru.txt
fi
pcount=`expr $postcount / 1000`
for ((i=0; i<=$pcount; i++))
do
echo Page $i
curl --compressed -# "https://xbooru.com/index.php?page=dapi&s=post&q=index&tags=$tags&limit=1000&pid=$i" -A "$uag"|pcregrep --buffer-size=16M -o -e 'file_url=\"[^"]+'|sed -e 's#file_url=##g' -e 's/\"//' >>get2.xbooru.txt
done;
wget -nc -i get2.xbooru.txt --referer="https://xbooru.com/" --no-check-certificate
echo Finished!
echo $tags \=\> $savedir