extract_discord_research/extract.sh
2020-10-31 21:45:11 +01:00

67 lines
1.5 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#***************************#
# extract.sh #
# #
# author : rick@gnous.eu #
# licence: GPL3 or later #
# #
#***************************#
################################################################################
# Télécharge le fichier .b se trouvant à lurl en paramètre et le dézip dans
# /tmp/file-tmp.
# Globals:
# [TODO:var-name]
# Arguments:
# $1: le curl (sans de --output) à faire pour récupérer le fichier
################################################################################
function recupDezip {
command="$@ --output /tmp/file-tmp.b"
eval $command
if [ -f "/tmp/file-tmp" ]
then
rm /tmp/file-tmp
fi
brotli -d -S .b /tmp/file-tmp.b
}
read -p "Entrez commande curl sans --compressed : " commandCurl
recupDezip $commandCurl
# on récupère le nombre de résultat pour avoir le nombre de page
nbResult=$(python3 help.py -g)
nbPage=$((nbResult / 25))
url=$(echo $commandCurl | cut -d\ -f2)
args=$(echo $commandCurl | cut -d\ -f3-)
url="${url::-1}&offset=${url: -1}"
if [ $((nbResult % 25)) -gt 0 ]
then
nbPage=$((nbPage + 1))
fi
read -p "Attention ! $nbPage pages seront traités !"
if [ -f result.json ]
then
rm result.json
fi
cp /tmp/file-tmp result.json
j=25
for i in $(seq 1 $nbPage)
do
newUrl="${url::-1}$j${url: -1}"
newCommand="curl $newUrl $args"
recupDezip $newCommand
python3 help.py -u
j=$((j + 25))
done
echo $nbPage