Bonjour à tous, et aux amoureux de mangas en particuliers 😉
Je vous propose un petit script bash (le code n'est surement pas nickel, j'apprends !) qui vous permet de télécharger les tomes de votre choix depuis le site
http://www.lecture-en-ligne.com afin de les lire quand vous le souhaitez avec le confort de comix par exemple.
[edit]
boomeranga! (0.9.8) permet aujourd'hui :
* récupération des chapitres désirés pour les mangas depuis lecture-en-ligne.com, mangafox.me et scan-manga.com
*
moteur de recherche multisites
* conversion automatique en .cbz
* possibilité de conversion en .pdf pour liseuses par exemple (grâce à Calibre)
* gestion de listes de suivis
* notification de disponibilité de màj pour le script
* annuaires lecture-en-ligne.com, mangafox.me et scan-manga.com
* avertissement dépendances nécessaires
#!/bin/bash
#weetabix' 2013
##################
# Boomeranga! #
##################
####description###########################################################################################
# boomeranga! a pour but d'améliorer le confort de lecture des planches de mangas disponibles sur le net #
# en les téléchargeant, puis en les compressant en .cbz (pour comix) et .pdf (si souhaité). #
# #
# Le script crée un dossier .boomeranga dans le home de l'utilisateur et y conserve 2 informations : #
# -le chemin vers le dossier de téléchargement #
# -le changelog #
# #
# N'hésitez pas à participer au projet en postant vos idées, remarques, bugs #
# #
# Info de versions : les versions <1 se concentrent sur le support de sites et les fonctionnalités. #
# la version 1.0 ne sortira que lorsque celles-ci seront jugées suffisantes. #
# L'interface graphique sera sa principale évolution. #
##########################################################################################################
####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################
v=0.9.8
#gestion dépendances
paquet=(bash calibre wget zip)
function télécharger {
#vérif si appel fonction depuis annuaire ou gb
if [[ ${an} != 1 ]]
then
if [[ ${gb} != 1 ]]
then
manga=`zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Nouveau manga - nom du manga ?"` || menu
fi
fi
mkdir $manga
cd $PWD/$manga/
#vérif page 404
if [[ -z $(grep ${manga} ../.404) ]]
then zenity --error --title "boomeranga" --text "manga non trouvé - abandon"
cd $ch
mv $PWD/$manga $HOME/.local/share/Trash/files & menu
fi
#connaitre chapitre max d'1 manga
wget http://www.lecture-en-ligne.com/$manga/1/0/0/1.html -O infochap
grep -A 1 'id="chap"' infochap > infochap2
head -2 infochap2 | tail -1 > infochap
cut -d ">" -f2 infochap | cut -d "<" -f1 > infochap2
chap_man=$(cat $PWD/infochap2)
chap=$(zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Commencer à quel chapitre ?") || exit
im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant
zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --question --text "$manga - Télécharger tous les chapitres disponibles ? [$chap_man paru(s) / $chapn nouveau(x)]"
if [ $? = 0 ]
then
chapmax=$chap_man
((chapmax++))
else
chapmax=$(zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --cancel-label "Quitter" --entry --text "Stopper à quel chapitre ? [vous êtes au n°$chap]") || exit
((chapmax++))
fi
while [ $chap != $chapmax ]
do
mkdir $chap
cd $PWD/$chap/
#rechercher le nb de pages du chapitre
wget http://www.lecture-en-ligne.com/$manga/$chap/0/0/1.html -O info
grep 'current_total_pages' info > info2
cut -d "'" -f2 info2 > info3
imax=`cat $PWD/info3`
#vérif page 404 - chapitre
if [[ -z $(grep -c 'ERREUR 404' info) ]]
then zenity --error --title "boomeranga!" --text "chapitre non trouvé - abandon"
cd $ch
mv $PWD/$manga $HOME/.local/share/Trash/files & menu
fi
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement du chapitre $chap"
#récupérer les images
for im in $(seq -w ${imax})
do
wget -T 15 http://www.lecture-en-ligne.com/images/mangas/$manga/$chap/$im.jpg
done
#création du .cbz
rm $PWD/info & rm $PWD/info2 & rm $PWD/info3
zip -r $chap.cbz .
mv $chap.cbz ..
cd ..
rm -r $PWD/$chap
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre
((chap++))
im=01
done
rm $PWD/infochap
echo $chapmax > $PWD/chaplast
#inscrire manga dans liste 'séries' sauf si déjà présent
cd ..
grep ${manga} séries
if [ $? != 0 ]
then
echo ${manga} >> séries
fi
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Vous trouverez les chapitres téléchargés dans le dossier <b>$ch</b> Bonne lecture! "
#on désactive variable annuaire
an=0 & gb=0
menu
}
function télécharger_poursuite {
cd $manga
wget http://www.lecture-en-ligne.com/$manga/1/0/0/1.html -O infochap
#vérification pour mangas sans n°1
grep "ERREUR 404" infochap
if [ $? = 1 ]
then
grep -A 1 'id="chap"' infochap > infochap2
head -2 infochap2 | tail -1 > infochap
cut -d ">" -f2 infochap | cut -d "<" -f1 > infochap2
chap_man=$(cat $PWD/infochap2)
chap=$(cat $PWD/chaplast)
im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant
chapmax=$chap_man
((chapmax++))
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement de la suite de $manga"
while [ $chap != $chapmax ]
do
mkdir $chap
cd $PWD/$chap/
#rechercher le nb de pages du chapitre
wget http://www.lecture-en-ligne.com/$manga/$chap/0/0/1.html -O info
grep 'current_total_pages' info > info2
cut -d "'" -f2 info2 > info3
imax=$(cat $PWD/info3)
#récupérer les images
for im in $(seq -w ${imax})
do
wget -T 15 http://www.lecture-en-ligne.com/images/mangas/$manga/$chap/$im.jpg
done
#création du .cbz
rm $PWD/info & rm $PWD/info2 & rm $PWD/info3
zip -r $chap.cbz .
mv $chap.cbz ..
cd ..
rm -r $PWD/$chap
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre
((chap++))
im=01
done
rm $PWD/infochap
echo $chapmax > $PWD/chaplast
fi
cd ..
}
function poursuite_series {
zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --question --text "Poursuivre les séries en cours :
<b>$(cat séries)</b> ?"
if [ $? = 0 ]
then
nb_ligm=$(wc -l séries | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries | tail -n 1)
télécharger_poursuite
((nb_lig++))
done
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Toutes les séries sont à jour"
menu
else
manga=`zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Nouveau manga - nom du manga ?"` || menu
#si manga vide
if [ -z $manga ]
then zenity --error --title "boomeranga!" --text "Erreur dans le nom - abandon" & exit
fi
télécharger
fi
}
function poursuite_series_mangafox {
zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --question --text "Poursuivre les séries en cours :
<b>$(cat séries.mfox)</b> ?"
if [ $? = 0 ]
then
nb_ligm=$(wc -l séries.mfox | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries.mfox | tail -n 1)
télécharger_poursuite_mfox
((nb_lig++))
done
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Toutes les séries sont à jour"
menu
else
manga=$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Nouveau manga - nom du manga ?") || menu
#si manga vide
if [ -z $manga ]
then zenity --error --title "boomeranga!" --text "Erreur dans le nom - abandon" & exit
fi
télécharger_mangafox
fi
}
function poursuite_series_scan-manga() {
zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --question --text "Poursuivre les séries en cours :
<b>$(cat séries.scan-manga)</b> ?"
if [ $? = 0 ]
then
nb_ligm=$(wc -l séries.scan-manga | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries.scan-manga | tail -n 1)
dir=$(echo ${manga} | cut -d "/" -f5 | cut -d "." -f1)
télécharger_poursuite_scan-manga
((nb_lig++))
done
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Toutes les séries sont à jour"
menu
fi
}
function poursuite_all() {
#poursuite lecture-en-ligne.com
zenity --progress --pulsate --timeout "1" --no-cancel --auto-close --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" \
--text "Mise à jour des séries :
<b>$(cat séries)</b>"
nb_ligm=$(wc -l séries | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries | tail -n 1)
télécharger_poursuite
((nb_lig++))
done
#poursuite mangafox.me
zenity --progress --pulsate --timeout "1" --no-cancel --auto-close --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" \
--text "Mise à jour des séries :
<b>$(cat séries.mfox)</b>"
nb_ligm=$(wc -l séries.mfox | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries.mfox | tail -n 1)
télécharger_poursuite_mfox
((nb_lig++))
done
#poursuite scan-manga.com
zenity --progress --pulsate --timeout "1" --no-cancel --auto-close --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" \
--text "Mise à jour des séries :
<b>$(cat séries.scan-manga)</b>"
nb_ligm=$(wc -l séries.scan-manga | cut -d " " -f1)
((nb_ligm++))
nb_lig=1
while [ $nb_lig != $nb_ligm ]
do
manga=$(head -n $nb_lig séries.scan-manga | tail -n 1)
dir=$(echo ${manga} | cut -d "/" -f5 | cut -d "." -f1)
télécharger_poursuite_scan-manga
((nb_lig++))
done
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Toutes les séries sont à jour"
menu
}
function télécharger_mangafox {
if [[ ${an} != 1 ]]
then
if [[ ${gb} != 1 ]]
then
manga=`zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Nouveau manga - nom du manga ?"` || menu
fi
fi
mkdir $manga
cd $PWD/$manga/
#dernier chapitre
chap_man=$(wget -U=firefox -qO - "http://mangafox.me/manga/${manga}/" | grep -A 1 "Chapters</h2><hr/>" | grep "Chapter " | sed "s@.*Chapter@@ ; s@.* - @@ ; s@</span></h3></div><ul class=\"chlist\" style=\"display:block\">@@")
info=$(zenity --forms --title "boomeranga" --text "Choix des chapitres" --cancel-label "Quitter" --add-entry "Chapitre début" --add-entry "Chapitre fin (dernier : ${chap_man})" --window-icon "/usr/share/pixmaps/boomeranga.svg")
#chap=${info%|*}
chap=$(echo $info | cut -d "|" -f 1)
((chap++))
#chapmax=c${info#*|}
chapmax=$(echo $info | cut -d "|" -f 2)
((chapmax++))
#formatage
if test ${#chap} = 1
then chap="c00"$(echo $info | cut -d "|" -f 1)
elif test ${#chap} = 2
then chap="c0"$(echo $info | cut -d "|" -f 1)
else
chap="c"$(echo $info | cut -d "|" -f 1)
fi
#formatage
if test ${#chapmax} = 1
then chapmax="c00"$(echo $info | cut -d "|" -f 2)
elif test ${#chapmax} = 2
then chapmax="c0"$(echo $info | cut -d "|" -f 2)
else
chapmax="c"$(echo $info | cut -d "|" -f 2)
fi
vol="v01"
im=1
while [ $chap != $chapmax ]
do
mkdir -p $vol$chap
cd $PWD/$vol$chap/
#rechercher le nb de pages du chapitre
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O info
grep 'var total_pages=' info > info2
cut -d "=" -f2 info2 | cut -d ";" -f1 > info3
imax=$(cat $PWD/info3)
let imaxi=imax+1
#404
if [[ -z $(cat $PWD/info) ]]
then
zenity --error --title "boomeranga!" --text "Manga/chapitre non trouvé - abandon"
cd $ch
mv $PWD/$manga $HOME/.local/share/Trash/files & exit
fi
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement du chapitre $chap"
#récupérer les images du chapitre
while [ $im != $imaxi ]
do
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infochap
grep -A 1 'onclick="return enlarge()"><img src=' infochap > infochap2
head -1 infochap2 > infochap
cut -d '"' -f6 infochap | cut -d '"' -f1 > infochap2
chi=$(< $PWD/infochap2)
wget -U=firefox $chi
((im++))
done
#création du .cbz
mv $PWD/info $HOME/.local/share/Trash/files ; mv $PWD/info2 $HOME/.local/share/Trash/files ; mv $PWD/info3 $HOME/.local/share/Trash/files
mv $PWD/infochap $HOME/.local/share/Trash/files ; mv $PWD/infochap2 $HOME/.local/share/Trash/files
zip -r $vol$chap.cbz .
mv $vol$chap.cbz ..
cd ..
rm -r $PWD/$vol$chap
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $vol$chap.cbz $vol$chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $vol$chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre / volume
chap=$(echo ${chap} | sed "s@.*c@@")
#incrément
((chap++))
#formatage
if test ${#chap} = 1
then chap="c00"${chap}
elif test ${#chap} = 2
then chap="c0"${chap}
else
chap="c"${chap}
fi
im=1
done
echo $chapmax > $PWD/chaplast
#inscrire manga dans liste 'séries' sauf si déjà présent
cd ..
grep ${manga} séries.mfox
if [ $? != 0 ]
then
echo ${manga} >> séries.mfox
fi
zenity --info --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Vous trouverez les chapitres téléchargés dans le dossier <b>$ch</b> Bonne lecture! "
cd $ch
an=0 & gb=0
menu
}
function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax=$(wget -U=firefox -qO - "http://mangafox.me/manga/${manga}/" | grep -A 1 "Chapters</h2><hr/>" | grep "Chapter " | sed "s@.*Chapter@@ ; s@.* - @@ ; s@</span></h3></div><ul class=\"chlist\" style=\"display:block\">@@")
((chapmax++))
#compter longueur variable et comparer avec commande test
if test ${#chapmax} = 1
then chapmax="c00"${chapmax}
elif test ${#chapmax} = 2
then chapmax="c0"${chapmax}
else
chapmax="c"${chapmax}
fi
im=1
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement de la suite de $manga"
while [ $chap != $chapmax ]
do
mkdir -p $vol$chap
cd $PWD/$vol$chap/
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O info
grep 'var total_pages=' info > info2
cut -d "=" -f2 info2 | cut -d ";" -f1 > info3
imax=$(cat $PWD/info3)
let imaxi=imax+1
#récupérer les images du chapitre
while [ $im != $imaxi ]
do
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infochap
grep -A 1 'onclick="return enlarge()"><img src=' infochap > infochap2
head -1 infochap2 > infochap
cut -d '"' -f6 infochap | cut -d '"' -f1 > infochap2
chi=$(cat $PWD/infochap2)
wget -U=firefox $chi
((im++))
done
#nettoyage
mv $PWD/info $HOME/.local/share/Trash/files ; mv $PWD/info2 $HOME/.local/share/Trash/files ; mv $PWD/info3 $HOME/.local/share/Trash/files
mv $PWD/infochap $HOME/.local/share/Trash/files ; mv $PWD/infochap2 $HOME/.local/share/Trash/files
#création du .cbz
zip -r $vol$chap.cbz .
mv $vol$chap.cbz ..
cd ..
rm -r $PWD/$vol$chap
#vérif opération précédente
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $vol$chap.cbz $vol$chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $vol$chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre / volume
chap=$(echo ${chap} | sed "s@.*c@@")
#incrément
((chap++))
#formatage
if test ${#chap} = 1
then chap="c00"${chap}
elif test ${#chap} = 2
then chap="c0"${chap}
else
chap="c"${chap}
fi
im=1
done
echo $chapmax > $PWD/chaplast
cd ..
}
function telecharger_scan-manga() {
mkdir $dir
cd $PWD/$dir/
#vérif page 404
chap=$(zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Commencer à quel chapitre ?") || exit
chapmax=$(zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --cancel-label "Quitter" --entry --text "Stopper à quel chapitre ? [vous êtes au n°$chap]") || exit
((chapmax++))
while [ $chap != $chapmax ]
do
mkdir $chap
cd $PWD/$chap/
wget "${manga}" -O titre
grep -A 3 "Chapitre ${chap} :" titre > titre1
grep "http://www.scan-manga.com/lecture-en-ligne" titre1 > titre
sed -i "s@.*http://www.scan-manga.com/lecture-en-ligne@http://www.scan-manga.com/lecture-en-ligne@" titre
sed -i "s@.html.*@.html@" titre
lienp=$(cat titre)
wget ${lienp} -O info
lien=$(grep "#image_lel').attr('src','http://leI" info | cut -d "'" -f6)
grep "var u = new Array;" info > totim
sed -i "s@\"@\n@g" totim
sed -i "/^var/d ; /;/d" totim
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement du chapitre $chap"
nb_imx=$(wc -l totim | cut -d " " -f1)
((nb_imx++))
nb_im=1
while [ $nb_im != $nb_imx ]
do
im=$(head -n ${nb_im} totim | tail -n 1)
wget ${lien}${im}
((nb_im++))
done
#création du .cbz
rm $PWD/info & rm $PWD/titre & rm $PWD/titre1 & rm $PWD/totim
zip -r $chap.cbz .
mv $chap.cbz ..
cd ..
rm -r $PWD/$chap
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre
((chap++))
done
#rm $PWD/infochap
echo $chapmax > $PWD/chaplast
#inscrire manga dans liste 'séries' sauf si déjà présent
cd ..
grep ${manga} séries.scan-manga
if [ $? != 0 ]
then
echo ${manga} >> séries.scan-manga
fi
menu
}
function télécharger_poursuite_scan-manga {
cd $dir
#connaitre chapitre max d'1 manga
#sed -n "/^Vol/p" supprime tout ce qui ne commence pas par "Vol"
chapmax=$(grep -A 5 "${manga}" ../.mangas_scan-manga | sed -n "/^Vol/p" | sed "s@.*Ch @@")
((chapmax++))
chap=$(cat $PWD/chaplast)
#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 1000 "Téléchargement de la suite de $dir"
while [ $chap != $chapmax ]
do
mkdir $chap
cd $PWD/$chap/
wget "${manga}" -O titre
grep -A 3 "Chapitre ${chap} :" titre > titre1
grep "http://www.scan-manga.com/lecture-en-ligne" titre1 > titre
sed -i "s@.*http://www.scan-manga.com/lecture-en-ligne@http://www.scan-manga.com/lecture-en-ligne@" titre
sed -i "s@.html.*@.html@" titre
lienp=$(cat titre)
wget ${lienp} -O info
lien=$(grep "#image_lel').attr('src','http://leI" info | cut -d "'" -f6)
grep "var u = new Array;" info > totim
sed -i "s@\"@\n@g" totim
sed -i "/^var/d ; /;/d" totim
nb_imx=$(wc -l totim | cut -d " " -f1)
((nb_imx++))
nb_im=1
while [ $nb_im != $nb_imx ]
do
im=$(head -n ${nb_im} totim | tail -n 1)
wget ${lien}${im}
((nb_im++))
done
#création du .cbz
rm $PWD/info & rm $PWD/titre & rm $PWD/titre1 & rm $PWD/totim
zip -r $chap.cbz .
mv $chap.cbz ..
cd ..
rm -r $PWD/$chap
#échec
#conversion pdf
[[ ${pdf} = "o" ]] && ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill
#échec
#changement de chapitre
((chap++))
done
#rm $PWD/infochap
echo $chapmax > $PWD/chaplast
cd ..
}
### annuaires ###
annuaire() {
test -f $PWD/.mangas2
if [ $? = 1 ]
then
zenity --question --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Lors du premier lancement cette option prend 2-3 minutes, l'exécuter ?" || menu
(nb_page=$(wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=1" | sed -n "/pagination/ s@.*>\([0-9]*\)</a> ).*@\1@p")
for i in $(seq ${nb_page})
do
wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=${i}" | grep -A 7 "tr onmouseover" | sed "s@^[[:space:]]*@@ ; s@</a>.*@@ ; s@<td class=\"td\">@@ ; s@</td>@@ ; /tr onmouseover\|<table class\|<td>\|--/d ; s@>@\n@ ; s@<a href=\"manga/@@ ; s@/\" class=\"infoImages\"@@"
done > .mangas
sed "s@<a href=@--@ ; /--/d ; /fois/d" .mangas > .mangas2
imax=$(wc -l .mangas2 | awk '{print $1}') ; let imax=imax/3 # détermine nb lignes
j=4
for (( i=1 ; i < $imax ; i=i+2 ))
do
# awk -v permet d'ajouter variable, print $NF = dernier mot
type=$(cat .mangas2 | grep "(" | awk -v i=$i 'NR == i {print;}' | awk '{print $NF}')
# insère le $type à la ligne j
sed -i "${j}i$type" .mangas2
let j=j+7
done
#supprime ( en début de ligne, ) en fin et (...
sed -i "s@^(@@ ; s@)\$@@ ; s@(.*@@" .mangas2
) | zenity --progress --pulsate --auto-close --no-cancel --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Récupération des données"
fi
manga=$(zenity --list --multiple --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Veuillez choisir une série" --width "1200" --height "400" --hide-column="1" --column="Référence" --column="Nom du manga" --column="Genre" --column="Type" --column="Note" --column="Nb chap." --column="Dernier paru" < $PWD/.mangas2) || menu
#initialisation variable annuaire
an=1
télécharger
}
annuaire_mfox() {
test -f $PWD/.mangas_mfox
if [ $? = 1 ]
then
zenity --question --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Lors du premier lancement cette option prend environ 5 minutes, l'exécuter ?" || menu
(
nb_page=300 #préciser nb pages par recherche sed
for i in $(seq ${nb_page})
do
wget -U=firefox -qO - "http://mangafox.me/directory/${i}.htm" | grep -A 4 "<div class=\"manga_text\">" | sed "s@^[[:space:]]*@@ ; /<div class=\"manga_text\">/d ; s@^<a class=\"title\" href=\"http://mangafox.me/manga/@@ ;
s@^<p class=\"info\" title=\"@@ ; s@/\" rel=\"[0-9]*\">@\n@ ; s@^.*\"rate\">@@ ; s@<p class=\"info\"><label>@@ ; s@.*</label> @@ ; s@\">.*@@ ; s@</a>@@ ; s@</span>@@ ; s@</p>@@ ; /--/d"
done > .mangas_mfox
#correction erreur sur 1 ligne
sed -i "s@ - ".*@@" .mangas_mfox
) | zenity --progress --pulsate --auto-close --no-cancel --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Récupération des données"
fi
manga=$(zenity --list --multiple --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Veuillez choisir une série" --width "1200" --height "400" --hide-column="1" --column="Référence" --column="Nom du manga" --column="Note" --column="Genre" --column="Visites" < $PWD/.mangas_mfox) || menu
#initialisation variable annuaire
an=1
télécharger_mangafox
}
annuaire_scan-manga() {
test -f $PWD/.mangas_scan-manga
if [ $? = 1 ]
then
(
wget -qO - http://www.scan-manga.com/scanlation/liste_des_mangas.html | grep "<div class=\"texte_lettre\">" -A 15 > .mangas_scan-manga
sed -i "/<div class=\"texte_lettre/d ; /<div class=\"texte_manga book_open\">/d ; s@<span class=\"hover_text_manga\"@\n@
s@<h3><a class=\"texte_manga\" href=\"@@ ; /<div class=\"texte_note\">/d ; s@<div class=\"texte_genre\"><span>@@ ; s@^>@@ ; s@</span></a></h3>@@ ;
/<div class='/d ; /^<span/d ; /^\"display/d ; s@.*average\"@@ ; s@^>@@ ; s@</span> <span style=@@ ; s@<div class=\"texte_statut\"><span>@@ ;
s@.*texte_der_chpt\">@@ ; s@</div>@--@" .mangas_scan-manga
sed -i "s@^ rel=\"[0-9]*\"@@ ; s@</a> le @\n@ ; /<div/d ; s@\">@@ ; s@^>@@ ; s@</span>--@@ ; /--/d" .mangas_scan-manga
#résolution accents
sed -i "s@à@à@ ; s@â@â@ ; s@é@é@ ; s@ê@ê@ ; s@è@è@ ; s@ô@ô@ ; s@ë@ë@ ; s@Ô@Ô@ ;
s@û@û@ ; s@’@'@ ; s@ï@ï@ ; s@amp;@@ ; s@ä@ä@ ; s@É@E@" .mangas_scan-manga
#màj
sed -i "s@<span class.*@@ ; s@</a> @\n@" .mangas_scan-manga
#correction temp
sed -i "s@Junketsu + Kareshi@Junketsu + Kareshi\n@ ; s@Watashi no + Okusuri@Watashi no + Okusuri\n@" .mangas_scan-manga
) | zenity --progress --pulsate --auto-close --no-cancel --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Récupération des données"
fi
manga=$(zenity --list --multiple --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Veuillez choisir une série" --width "1000" --height "400" --hide-column="1" --column="Référence" --column="Nom du manga" --column="Genre" --column="Note" --column="Statut" --column="Dernier chapitre" --column="Dernière màj" < $PWD/.mangas_scan-manga) || menu
dir=$(echo ${manga} | cut -d "/" -f5 | cut -d "." -f1)
telecharger_scan-manga
}
#################
### init ###
dep() {
cd $HOME/.boomeranga/
(for (( i=0 ; i < ${#paquet[*]} ; i++ ))
do
#recherche paquets non installés et les inscrit en supprimant le retour à la ligne
[[ $(aptitude show ${paquet[i]} | grep "État: non installé") ]] && echo "${paquet[i]} " | tr -d "\n" >> dépendances
done) | zenity --progress --pulsate --auto-close --no-cancel --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Vérification des dépendances"
test -f $PWD/dépendances
if [ $? = 0 ]
then
zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --info --text "Les dépendances suivantes sont nécessaires pour le bon
fonctionnement de boomeranga! :
<b>$(cat dépendances)</b>
Il est conseillé de les installer avant de redémarrer le script."
exit
else
zenity --info --ok-label "Go!" --timeout "2" --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Toutes les dépendances
sont satisfaites"
fi
}
function ch() {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
}
#vérification présence fichiers 'séries' et création si besoin
function séries {
test -f $PWD/séries
if [ $? = 1 ]
then
> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
> séries.mfox
fi
test -f $PWD/séries.scan-manga
if [ $? = 1 ]
then
> séries.scan-manga
fi
}
liste_manga() {
#récupération liste manga lel.com pour 404 / _new pour conserver ancien tant que nouveau incomplet
nb_page=$(wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=1" | sed -n "/pagination/ s@.*>\([0-9]*\)</a> ).*@\1@p")
for i in $(seq ${nb_page})
do
wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=${i}" | grep -A 7 "tr onmouseover" | sed "s@^[[:space:]]*@@ ; s@Ch.*@@ ; /td class=/d ; /--/d ; /<td>/d ; /<tr onmouseover/d ; /<table class/d"
done > .404_new
mv .404_new .404
}
############
### options ###
function ch_maj {
ch_tmp=$(zenity --file-selection --window-icon "/usr/share/pixmaps/boomeranga.svg" --title "Choisir le dossier des téléchargements boomeranga!" --directory)
echo $ch_tmp/boomeranga > $HOME/.boomeranga/ch_new
ch=$(cat $HOME/.boomeranga/ch)
ch_new=$(cat $HOME/.boomeranga/ch_new)
mv $ch $ch_new
mv $HOME/.boomeranga/ch_new $HOME/.boomeranga/ch
zenity --info --ok-label "bye!" --timeout "5" --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Merci de redémarrer boomeranga! pour que les
changements soient effectifs" & exit
}
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || menu
case "${pdf}" in
"") pdf=""
;;
esac
if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}
simple_convert() {
zenity --info --title="Conversion .cbz vers .pdf" --text="1. Choisir fichier source
2. Choisir fichier cible"
fichier1=`zenity --file-selection --title="Sélectionnez un fichier"`
fichier2=`zenity --file-selection --save`
ebook-convert $fichier1 $fichier2 --right2left | zenity --progress --text "Conversion en cours" --auto-close --auto-kill
zenity --info --title="Info" --text="Conversion de <b>$fichier1</b> terminée"
}
#à vérif. pour activ.
échec() {
while [ ${?} -ne 0 ]
do
zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
menu
done
}
#fonctions annuaire général permettant de voir quel site est le plus avancé pour une série
gb_lel() {
nb_page=$(wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=1" | sed -n "/pagination/ s@.*>\([0-9]*\)</a> ).*@\1@p")
for i in $(seq ${nb_page})
do
wget -qO - "http://www.lecture-en-ligne.com/index.php?page=liste&ordre=titre&p=${i}" | grep -A 7 "tr onmouseover" | grep -A 6 -i "manga/.*${manga}" | sed "s@<td class=\"td\"><a href=\"manga/@@ ;
s@/\" class=\"infoImages\">@\n@ ; s@</a></td>@@ ; /<tr onmouseover/d ; /<td class/d ; s@.*Ch. @@ ; s@</a>.*@@ ; /<td>/d ; /--/d ; s@^[[:space:]]*@@ ; s@N/A.*@0@"
done > .mangas
#correction temp
sed -i "s@no Aneki@no Aneki\n@" .mangas
imax=$(($(wc -l .mangas | awk '{print$1}') * 2))
for (( i=3 ; i < $imax ; i=i+4 ))
do
sed -i "$i s@\$@\nLEL@" .mangas
done
}
gb_scm() {
wget -qO - http://www.scan-manga.com/scanlation/liste_des_mangas.html | grep -A 12 "\"><span class=\"hover_text_manga" | grep -A 1 -i ">.*${manga}" > .mangas_scan-manga
sed -i "/<div class=\"texte_lettre\">/d ; /<div class=\"texte_manga book_close\">/d ; s@<h3><a class=\"texte_manga\" href=\"@@ ;
s@\"><span class=\"hover_text_manga\" rel=\"[0-9]*\">@\n@ ; s@</span></a></h3>@@ ; /<div class=\"texte_genre/d ; /<div class=\"texte_note/d ;
/<div class='bl_vote/d ; /<div class='sub/d ; /.*\"display:none/d ; /<div class=\"texte_statut/d ; s@.*class=\"texte_der_chpt\">@@ ; s@</a>.*@@ ;
/.*div.*/d ; /--/d" .mangas_scan-manga
#résolution accents
sed -i "s@à@à@ ; s@â@â@ ; s@é@é@ ; s@ê@ê@ ; s@è@è@ ; s@ô@ô@ ; s@ë@ë@ ; s@Ô@Ô@ ;
s@û@û@ ; s@’@'@ ; s@ï@ï@ ; s@amp;@@ ; s@ä@ä@ ; s@É@E@" .mangas_scan-manga
#màj
sed -i "s@<span class.*@@ ; s@</a> @\n@" .mangas_scan-manga
#correction temp
sed -i "s@Junketsu + Kareshi@Junketsu + Kareshi\n@ ; s@Watashi no + Okusuri@Watashi no + Okusuri\n@" .mangas_scan-manga
sed -i "s@Hôô @@" .mangas_scan-manga
#suppression lignes
sed -i "1549d" .mangas_scan-manga
sed -i "3733d" .mangas_scan-manga
#formatage
sed -i "s@Vol [0-9]* @@" .mangas_scan-manga
sed -i "s@^Ch @@" .mangas_scan-manga
imax=$(($(wc -l .mangas_scan-manga | awk '{print$1}') * 2))
for (( i=3 ; i < $imax ; i=i+4 ))
do
sed -i "$i s@\$@\nSCM@" .mangas_scan-manga
done
}
gb_mfx() {
nb_page=300 #préciser nb pages par recherche sed
for i in $(seq ${nb_page})
do
wget -U=firefox -qO - "http://mangafox.me/directory/${i}.htm" | grep -A 4 "<div class=\"manga_text\">" | grep -A 2 -i "${manga}" | sed "s@^[[:space:]]*@@ ; /<div class=\"manga_text\">/d ;
s@^<a class=\"title\" href=\"http://mangafox.me/manga/@@ ; s@/\" rel=\"[0-9]*\">@\n@ ; s@</a>@@ ; /.*class.*/d ; /--/d"
done > .mangas_mfox
#correction erreur sur 1 ligne
sed -i "s@ - ".*@@" .mangas_mfox
#ajouter nb chap.
imax=$(($(wc -l .mangas_mfox | awk '{print$1}') * 2))
for (( i=1 ; i < $imax ; i=i+3 ))
do
manga=$(head -n $i .mangas_mfox | tail -n 1)
chap_man=$(wget -U=firefox -qO - "http://mangafox.me/manga/${manga}/" | grep -A 1 "Chapters</h2><hr/>" | grep "Chapter " | sed "s@.*Chapter@@ ; s@.* - @@ ; s@</span></h3></div><ul class=\"chlist\" style=\"display:block\">@@")
((i++))
sed -i "$i s@\$@\n$chap_man@" .mangas_mfox
((i--))
done
#formatage
for (( i=3 ; i < $imax ; i=i+4 ))
do
sed -i "$i s@\$@\nMFX@" .mangas_mfox
done
sed -i "s@^[[:space:]]*@@" .mangas_mfox
}
gb() {
manga=`zenity --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "Le titre du manga contient :"` || menu
(gb_lel
gb_scm
gb_mfx
cp .mangas .gb
cat .mangas_scan-manga >> .gb
cat .mangas_mfox >> .gb
) | zenity --progress --pulsate --auto-close --no-cancel --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Recherche en cours"
choix=$(zenity --list --multiple --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Double-clic sur une série" --width "600" --height "400" --hide-column="1" --print-column="1,4" --column="Référence" --column="Nom du manga" --column="Dernier paru" --column="Site" < $PWD/.gb)
manga=$(echo ${choix} | cut -d "|" -f 1)
site=$(echo ${choix} | cut -d "|" -f 2)
#nettoyage
nettoyage_annuaires
gb=1
if [[ ${site} = "LEL" ]]
then télécharger
elif [[ ${site} = "MFX" ]]
then télécharger_mangafox
elif [[ ${site} = "SCM" ]]
then
dir=$(echo ${manga} | cut -d "/" -f5 | cut -d "." -f1)
telecharger_scan-manga
fi
}
###############
### stop ###
nettoyage_annuaires() {
[[ -f $PWD/.mangas ]] && mv -f $PWD/.mangas $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas2 ]] && mv -f $PWD/.mangas2 $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas_mfox ]] && mv -f $PWD/.mangas_mfox $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas_scan-manga ]] && mv -f $PWD/.mangas_scan-manga $HOME/.local/share/Trash/files
}
bye() {
cd ${ch}
nettoyage_annuaires
mv $PWD/wget* $HOME/.local/share/Trash/files
exit
}
############
### menus ###
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "450" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 0 "Rechercher un manga" 0 "Poursuivre toutes les séries" 1 "===== Menus dédiés =====" \
2 "lecture-en-ligne.com" 3 "mangafox.me" 4 "scan-manga.com" 5 "======= Options ========" 6 "Modifier le chemin de boomeranga!" 7 "Modifier préférences de conversion" 8 "======== Extra =========" 9 "Convertir .cbz en .pdf" 10 "Demander une fonctionnalité" 11 "Site du projet") || bye
case "${option}" in
0) gb
;;
0) poursuite_all
;;
1) echo "y'a rien ici :p" && menu
;;
2) menu_lecture-en-ligne.com
;;
3) menu_mangafox.me
;;
4) menu_scan-manga.com
;;
5) echo "y'a rien ici :p" && menu
;;
6) ch_maj && menu
;;
7) convert_pdf
;;
8) echo "y'a rien ici :p" && menu
;;
9) simple_convert && menu
;;
10) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
11) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
esac
}
function menu_lecture-en-ligne.com() {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "225" --cancel-label "Retour" --title "boomeranga!" --text "Menu lecture-en-ligne.com" --column=option --column=description 1 "Télécharger mangas" 2 "Voir/Modifier liste de suivi" \
3 "Annuaire mangas") || menu
case "${option}" in
1) télécharger
;;
2) zenity --text-info --editable --cancel-label "Quitter" --filename "$ch/séries" > $ch/séries_maj &&
mv $PWD/séries $HOME/.local/share/Trash/files && mv $PWD/séries_maj $PWD/séries && menu_lecture-en-ligne.com || menu
;;
3) annuaire
;;
esac
}
function menu_mangafox.me() {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "225" --cancel-label "Retour" --title "boomeranga!" --text "Menu mangafox.me" --column=option --column=description 1 "Télécharger mangas" 2 "Voir/Modifier liste de suivi" \
3 "Annuaire mangas") || menu
case "${option}" in
1) télécharger_mangafox
;;
2) zenity --text-info --editable --cancel-label "Retour" --filename "$ch/séries.mfox" > $ch/séries.mfox_maj &&
mv $PWD/séries.mfox $HOME/.local/share/Trash/files && mv $PWD/séries.mfox_maj $PWD/séries.mfox && menu_mangafox.me || menu_mangafox.me
;;
3) annuaire_mfox
;;
esac
}
function menu_scan-manga.com() {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "200" --cancel-label "Retour" --title "boomeranga!" --text "Menu scan-manga.com" --column=option --column=description 1 "Annuaire mangas" \
2 "Voir/Modifier liste de suivi") || menu
case "${option}" in
1) annuaire_scan-manga
;;
2) zenity --text-info --width "500" --height "300" --editable --cancel-label "Retour" --filename "$ch/séries.scan-manga" > $ch/séries.scan-manga_maj &&
mv $PWD/séries.scan-manga $HOME/.local/share/Trash/files && mv $PWD/séries.scan-manga_maj $PWD/séries.scan-manga && menu_scan-manga.com || menu_scan-manga.com
;;
esac
}
#############
#### lancement boomeranga! ####
zenity --progress --pulsate --timeout "8" --no-cancel --auto-close --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "Chargement informations" &
nb=$(wget -qO - http://www.lecture-en-ligne.com/ | grep -A 1 "<td class=\"count1\">Mangas :</td>" | sed "/Mangas/d ; s@<td class=\"count3\">@@ ; s@</td>@@")
nb_mfox=$(wget -U=firefox -qO - "http://mangafox.me/manga/#idx_#" | grep "<li><a href=\"http://mangafox.me/manga/" | wc -l)
nb_scanman=$(wget -qO - http://www.scan-manga.com/ | grep "Nombre de mangas :" | sed "s@.* : @@ ; s@<br>@@")
#### intro ####
zenity --info --ok-label "Go!" --title "boomeranga! v$v" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "<b>boomeranga!</b> vous permet de télécharger
des planches de manga depuis :
* lecture-en-ligne.com : <b>${nb} titres</b>
* mangafox.me : <b>${nb_mfox} titres</b>
* scan-manga.com : <b>${nb_scanman} titres</b>
Bonne lecture!"
#vérif au premier lancement : création chemin boomeranga + dépendances
test -f $HOME/.boomeranga/ch
if [ $? = 1 ]
then
mkdir -p $HOME/.boomeranga
ch_tmp=$(zenity --file-selection --window-icon "/usr/share/pixmaps/boomeranga.svg" --title "Choisir le dossier des téléchargements boomeranga!" --directory)
echo $ch_tmp/boomeranga > $HOME/.boomeranga/ch
dep
fi
#info màj
cd $HOME/.boomeranga/
wget http://goupil.eu/repo/boomeranga_version -O version
v2=$(head -n 1 $HOME/.boomeranga/version)
[ $v = $v2 ] || zenity --info --ok-label "Ok" --timeout "2" --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "La version $v2 est disponible"
#
ch
liste_manga &
séries
menu