Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#51 Le 09/06/2013, à 18:38

chachatte

Re : boomeranga! pour les amateurs de mangas

Oula grosse erreur de ma part ca fonctionne niquel. Je n'attendais pas la fin du script pour la conversion .cbz . Désolé et merci.
Ps: il me manquait le paquet zip.

Dernière modification par chachatte (Le 09/06/2013, à 18:49)

Hors ligne

#52 Le 09/06/2013, à 19:12

Hizoka

Re : boomeranga! pour les amateurs de mangas

il ne sert a rien de donner une valeur a im avant la boucle.

im=01
for im in $(seq -w ${imax})
do
  wget -T 15 http://www.lecture-en-ligne.com/images/mangas/$manga/$chap/$im.jpg
done

tu peux te passer d'une etape :

erreur=$(grep -c 'ERREUR 404' info)
if [ $erreur = 1 ]
then zenity --error --title "boomeranga!" --text "chapitre non trouvé - abandon"
	cd $ch
	mv $PWD/$manga $HOME/.local/share/Trash/files & menu
fi

=>

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

pareil pour ici :

grep $manga séries
if [ $? != 0 ]
then
	echo $manga >> séries
fi

=>

[[ $(grep $manga séries) ]] && echo $manga >> séries

Simplification possible :

	nb_ligm=$(wc -l séries | cut -d " " -f1)
	((nb_ligm++))

=>

	nb_ligm=$(( $(wc -l séries | cut -d " " -f1) + 1 ))

Vive les boucle for

	while [ $nb_lig != $nb_ligm ]
	do
	manga=$(head -n $nb_lig séries | tail -n 1)
	télécharger_poursuite
	((nb_lig++))
	done

=>

	for (( nb_lig=1; nb_lig < $nb_ligm; nb_lig++ ))
	do
	manga=$(head -n $nb_lig séries | tail -n 1)
	télécharger_poursuite
	done

et mes differentes remarques précédantes tongue


KDE Neon 64bits
Tous mes softs (MKVExtractorQt, HizoSelect, HizoProgress, Qtesseract, Keneric, Services menus...) sont sur github

Hors ligne

#53 Le 10/06/2013, à 04:08

milkshake

Re : boomeranga! pour les amateurs de mangas

Je testerai demain ta nouvelle version WeetabiX, mais on dirait que ça avance bien !

Hizoka, tu maîtrises sur certains aspects et le code est beaucoup plus élégant cool
Je passe carrément à coté quand c'est fonctionnel.

Hors ligne

#54 Le 10/06/2013, à 13:40

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Encore une "micro-version" qui documente sur les dépendances à avoir et qui allège le code (en partie encore !) selon les conseils du maître Hizoka wink

#!/bin/bash
#weetabix' 2013

##################
#  Boomeranga!   #
##################

####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################

v=0.9.4-4

#fonction télécharger()
function télécharger {
mkdir $manga
cd $PWD/$manga/

#vérif page 404
erreur=$(wget -qO - http://www.lecture-en-ligne.com/$manga/1/0/0/1.html | grep -c 'ERREUR 404')
if [ $erreur = 1 ]
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 2000 "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
if [ $pdf = "o" ] ; then ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill ; fi
é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) ]] &&	echo $manga >> séries

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! "
menu
}

function télécharger_poursuite {
cd $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=$(cat $PWD/chaplast)

im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant

chapmax=$chap_man
((chapmax++))

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)

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
if [ $pdf = "o" ] ; then ebook-convert $chap.cbz $chap.pdf --right2left | zenity --title "boomeranga!" --progress --text "Création de $manga $chap.pdf" --auto-close --auto-kill ; fi
échec

#changement de chapitre
((chap++))
im=01
done

rm $PWD/infochap
echo $chapmax > $PWD/chaplast

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 ?"` || exit

	#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 ?") || exit

	#si manga vide
	if [ -z $manga ]
	then zenity --error --title "boomeranga!" --text "Erreur dans le nom - abandon" & exit
	fi
	télécharger_mangafox
fi
}

#fonction télécharger_mangafox() / pas info chap. max / vol inutile (oui et non) car redirection auto fct chapitre
function télécharger_mangafox {

mkdir $manga
cd $PWD/$manga/

info=$(zenity --forms --title "boomeranga!" --cancel-label "Quitter" --add-entry "Chapitre début (forme 001)" --add-entry "Chapitre fin (forme 001+1)" --window-icon "/usr/share/pixmaps/boomeranga.svg")
chap="c"$(echo $info | cut -d "|" -f 1)
chapmax="c"$(echo $info | cut -d "|" -f 2)

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 2000 "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=$(cat $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
if [ $pdf = "o" ] ; then 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 ; fi
échec

#changement de chapitre / volume
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=`cat $PWD/infovol`
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files
done

echo $chapmax > $PWD/chaplast

#inscrire manga dans liste 'séries' sauf si déjà présent
cd ..
[[ $(grep $manga séries.mfox) ]] && echo $manga >> séries.mfox

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
menu
}

function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax="c"$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "$manga - Stopper à quel chapitre (forme 001+1)? [vous êtes au n°$chap]") || exit
im=1

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

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
if [ $pdf = "o" ] ; then 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 ; fi
échec

#changement de chapitre / volume
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=$(cat $PWD/infovol)
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1
done

echo $chapmax > $PWD/chaplast

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files

cd ..
}

annuaire() {
zenity --question --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "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"
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
#mv $PWD/.mangas $HOME/.local/share/Trash/files && mv $PWD/.mangas2 $HOME/.local/share/Trash/files
télécharger
}

échec() {
while [ ${?} -ne 0 ]
do
	zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
	menu
done
}

#### intro ####
zenity --info --ok-label "Go!" --timeout "2" --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 (FR)
   * mangafox.me (EN)

Bonne lecture!"

#création chemin boomeranga
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
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"

#vérification présence fichiers 'séries' et création si besoin
function séries {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
test -f $PWD/séries
if [ $? = 1 ]
then
	> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
	> séries.mfox
fi
}

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
}

#option pdf
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || exit
case "${pdf}" in
"") pdf=""
;;
esac

if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}
séries

#menu général avec `case`
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "350" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 1 "Télécharger mangas (FR)" 2 ">> Voir/Modifier liste de suivi (FR)" \
3 "Annuaire mangas (FR)" 4 "Télécharger mangas (EN)" 5 ">> Voir/Modifier liste de suivi (EN)" 6 "================" 7 "Modifier le chemin de boomeranga!" 8 "Consulter l'aide en ligne" 9 "Demander une fonctionnalité") || exit
case "${option}" in
1) poursuite_series
;;
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
;;
3) annuaire
;;
4) poursuite_series_mangafox
;;
5) zenity --text-info --editable --cancel-label "Quitter" --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
;;
6) echo "y'a rien ici :p" && menu
;;
7) ch_maj && menu
;;
8) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
9) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
esac
}

convert_pdf
#### lancement boomeranga! ####
menu

Hors ligne

#55 Le 10/06/2013, à 17:45

Hizoka

Re : boomeranga! pour les amateurs de mangas

si tu parles des dépendances, ajoute une boucle qui les verifie et affiche une fenetre zenity proposant de les installer.


PS : oublie pas certaines conseils (pas d'obligations, hein ?!) : http://forum.ubuntu-fr.org/viewtopic.ph … #p13743831


KDE Neon 64bits
Tous mes softs (MKVExtractorQt, HizoSelect, HizoProgress, Qtesseract, Keneric, Services menus...) sont sur github

Hors ligne

#56 Le 11/06/2013, à 09:40

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Voilà la nouvelle version qui :
   * vérifie si les dépendances sont satisfaites et informe l'utilisateur mais ne permet pas leur installation (pour ne pas avoir à gérer les préférences distrib. ou util. concernant sudo/su)
   * simplifie le code selon les conseils d'Hizoka (reste des boucles for/while que je regarderai plus tard tongue)

#!/bin/bash
#weetabix' 2013

##################
#  Boomeranga!   #
##################

####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################

v=0.9.5-1
paquet=(bash calibre wget zip)

#fonction télécharger()
function télécharger {
mkdir $manga
cd $PWD/$manga/

#vérif page 404
erreur=$(wget -qO - http://www.lecture-en-ligne.com/$manga/1/0/0/1.html | grep -c 'ERREUR 404')
if [ $erreur = 1 ]
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 2000 "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) ]] &&	echo $manga >> séries

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! "
menu
}

function télécharger_poursuite {
cd $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=$(cat $PWD/chaplast)

im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant

chapmax=$chap_man
((chapmax++))

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)

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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

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 ?"` || exit

	#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 ?") || exit

	#si manga vide
	if [ -z $manga ]
	then zenity --error --title "boomeranga!" --text "Erreur dans le nom - abandon" & exit
	fi
	télécharger_mangafox
fi
}

#fonction télécharger_mangafox() / pas info chap. max / vol inutile (oui et non) car redirection auto fct chapitre
function télécharger_mangafox {

mkdir $manga
cd $PWD/$manga/

info=$(zenity --forms --title "boomeranga!" --cancel-label "Quitter" --add-entry "Chapitre début (forme 001)" --add-entry "Chapitre fin (forme 001+1)" --window-icon "/usr/share/pixmaps/boomeranga.svg")
chap="c${info%|*}"#équivaut à "c"$(echo $info | cut -d "|" -f 1)
chapmax="c${info#*|}"#équivaut à "c"$(echo $info | cut -d "|" -f 2)

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 2000 "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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=`cat $PWD/infovol`
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files
done

echo $chapmax > $PWD/chaplast

#inscrire manga dans liste 'séries' sauf si déjà présent
cd ..
[[ $(grep $manga séries.mfox) ]] && echo $manga >> séries.mfox

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
menu
}

function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax="c"$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "$manga - Stopper à quel chapitre (forme 001+1)? [vous êtes au n°$chap]") || exit
im=1

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

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=$(cat $PWD/infovol)
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1
done

echo $chapmax > $PWD/chaplast

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files

cd ..
}

annuaire() {
zenity --question --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "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"
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
#mv $PWD/.mangas $HOME/.local/share/Trash/files && mv $PWD/.mangas2 $HOME/.local/share/Trash/files
télécharger
}

échec() {
while [ ${?} -ne 0 ]
do
	zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
	menu
done
}

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
}

#### intro ####
zenity --info --ok-label "Go!" --timeout "2" --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 (FR)
   * mangafox.me (EN)

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"

#vérification présence fichiers 'séries' et création si besoin
function séries {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
test -f $PWD/séries
if [ $? = 1 ]
then
	> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
	> séries.mfox
fi
}

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
}

#option pdf
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || exit
case "${pdf}" in
"") pdf=""
;;
esac

if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}
séries

#menu général avec `case`
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "350" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 1 "Télécharger mangas (FR)" 2 ">> Voir/Modifier liste de suivi (FR)" \
3 "Annuaire mangas (FR)" 4 "Télécharger mangas (EN)" 5 ">> Voir/Modifier liste de suivi (EN)" 6 "================" 7 "Modifier le chemin de boomeranga!" 8 "Consulter l'aide en ligne" 9 "Demander une fonctionnalité") || exit
case "${option}" in
1) poursuite_series
;;
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
;;
3) annuaire
;;
4) poursuite_series_mangafox
;;
5) zenity --text-info --editable --cancel-label "Quitter" --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
;;
6) echo "y'a rien ici :p" && menu
;;
7) ch_maj && menu
;;
8) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
9) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
esac
}

convert_pdf
#### lancement boomeranga! ####
menu

Hors ligne

#57 Le 11/06/2013, à 19:14

Sink-soul

Re : boomeranga! pour les amateurs de mangas

Bonjour,
Superbe idée comme script ! big_smile
Je l'ai essayer, c'est assez simple.
Le problème c'est que les mangas que je lis le plus me donnent un message d'erreur, comme Fairy Tail par exemple ("Manga non trouvé,  abandon").
Et problème majeur pour moi, il n'y a pas mon manga préféré : Naruto, gros problème tongue haha
Il faudrait réussir à prendre en charge un autre site, mais j'imagine que ca ne doit pas être simple...
Edit : Je viens d'essayer de télécharger un manga = "Erreur opération"...

Dernière modification par Sink-soul (Le 11/06/2013, à 19:17)


Voyager 13.10 sur HP-DV7
avec Windows 7 en Dual Boot

Hors ligne

#58 Le 11/06/2013, à 19:41

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Je viens d'essayer avec Fairy Tail, effectivement il y a une erreur 404 car la vérification se fait sur le chapitre 1 or le premier disponible est le n°231.
Je corrige pour la prochaine version wink
N'hesite pas à proposer un autre site, je regarderai !

Dernière modification par WeetabiX (Le 11/06/2013, à 21:56)

Hors ligne

#59 Le 11/06/2013, à 20:17

Sink-soul

Re : boomeranga! pour les amateurs de mangas

Je te propose le site http://www.scan-manga.com/ qui est pas mal.
Et celui-ci en anglais, très complet : http://www.mangapanda.com/

Dernière modification par Sink-soul (Le 11/06/2013, à 20:39)


Voyager 13.10 sur HP-DV7
avec Windows 7 en Dual Boot

Hors ligne

#60 Le 12/06/2013, à 13:35

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Nouvelle mise à jour que je conseille vivement :

0.9.5-2
modification vérification 404 (manga sans chap.1)
restauration ajout série (régression constatée)
désactivation échec()
##à faire :
nettoyage du code (while/for)
correction échec()

#!/bin/bash
#weetabix' 2013

##################
#  Boomeranga!   #
##################

####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################

v=0.9.5-2
paquet=(bash calibre wget zip)#gestion dépendances

#fonction télécharger()
function télécharger {
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 2000 "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! "
menu
}

function télécharger_poursuite {
cd $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=$(cat $PWD/chaplast)

im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant

chapmax=$chap_man
((chapmax++))

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)

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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

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 ?"` || exit

	#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 ?") || exit

	#si manga vide
	if [ -z $manga ]
	then zenity --error --title "boomeranga!" --text "Erreur dans le nom - abandon" & exit
	fi
	télécharger_mangafox
fi
}

#fonction télécharger_mangafox() / pas info chap. max / vol inutile (oui et non) car redirection auto fct chapitre
function télécharger_mangafox {

mkdir $manga
cd $PWD/$manga/

info=$(zenity --forms --title "boomeranga!" --cancel-label "Quitter" --add-entry "Chapitre début (forme 001)" --add-entry "Chapitre fin (forme 001+1)" --window-icon "/usr/share/pixmaps/boomeranga.svg")
chap="c${info%|*}"#équivaut à "c"$(echo $info | cut -d "|" -f 1)
chapmax="c${info#*|}"#équivaut à "c"$(echo $info | cut -d "|" -f 2)

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 2000 "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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=`cat $PWD/infovol`
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files
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
menu
}

function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax="c"$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "$manga - Stopper à quel chapitre (forme 001+1)? [vous êtes au n°$chap]") || exit
im=1

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

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=$(cat $PWD/infovol)
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1
done

echo $chapmax > $PWD/chaplast

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files

cd ..
}

annuaire() {
zenity --question --title "boomeranga" --window-icon "/usr/share/pixmaps/boomeranga.svg" --text "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"
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
#mv $PWD/.mangas $HOME/.local/share/Trash/files && mv $PWD/.mangas2 $HOME/.local/share/Trash/files
télécharger
}

échec() {
while [ ${?} -ne 0 ]
do
	zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
	menu
done
}

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
}

liste_manga() {
#récupération liste manga lel.com pour 404
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
}

#### intro ####
zenity --info --ok-label "Go!" --timeout "2" --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 (FR)
   * mangafox.me (EN)

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"

#vérification présence fichiers 'séries' et création si besoin
function séries {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
test -f $PWD/séries
if [ $? = 1 ]
then
	> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
	> séries.mfox
fi
}

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
}

#option pdf
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || exit
case "${pdf}" in
"") pdf=""
;;
esac

if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}
séries
liste_manga &

#menu général avec `case`
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "350" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 1 "Télécharger mangas (FR)" 2 ">> Voir/Modifier liste de suivi (FR)" \
3 "Annuaire mangas (FR)" 4 "Télécharger mangas (EN)" 5 ">> Voir/Modifier liste de suivi (EN)" 6 "================" 7 "Modifier le chemin de boomeranga!" 8 "Consulter l'aide en ligne" 9 "Demander une fonctionnalité") || exit
case "${option}" in
1) poursuite_series
;;
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
;;
3) annuaire
;;
4) poursuite_series_mangafox
;;
5) zenity --text-info --editable --cancel-label "Quitter" --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
;;
6) echo "y'a rien ici :p" && menu
;;
7) ch_maj && menu
;;
8) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
9) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
esac
}

convert_pdf
#### lancement boomeranga! ####
menu

Hors ligne

#61 Le 12/06/2013, à 23:43

Sink-soul

Re : boomeranga! pour les amateurs de mangas

Merci pour cette m-à-j smile


Voyager 13.10 sur HP-DV7
avec Windows 7 en Dual Boot

Hors ligne

#62 Le 13/06/2013, à 12:42

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Chaud devant big_smile

0.9.6
annuaire mangafox
mise en cache annuaires
fonction nettoyage en quittant
affichage nb titres accueil

#!/bin/bash
#weetabix' 2013

##################
#  Boomeranga!   #
##################

####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################

v=0.9.6
paquet=(bash calibre wget zip)

#fonction télécharger()
function télécharger {
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 2000 "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! "
menu
}

function télécharger_poursuite {
cd $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=$(cat $PWD/chaplast)

im=01
chapn=$(($chap_man-$chap+1)) # définir chapitres restant

chapmax=$chap_man
((chapmax++))

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)

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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

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
}

#fonction télécharger_mangafox() / pas info chap. max / vol inutile (oui et non) car redirection auto fct chapitre
function télécharger_mangafox {
mkdir $manga
cd $PWD/$manga/

info=$(zenity --forms --title "boomeranga" --cancel-label "Quitter" --add-entry "Chapitre début (forme 001)" --add-entry "Chapitre fin (forme 001+1)" --window-icon "/usr/share/pixmaps/boomeranga.svg")
#chap="c${info%|*}"
chap="c"$(echo $info | cut -d "|" -f 1)
#chapmax="c${info#*|}"
chapmax="c"$(echo $info | cut -d "|" -f 2)

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 2000 "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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=`cat $PWD/infovol`
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files
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
menu
}

function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax="c"$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "$manga - Stopper à quel chapitre (forme 001+1)? [vous êtes au n°$chap]") || exit
im=1

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

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=$(cat $PWD/infovol)
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1
done

echo $chapmax > $PWD/chaplast

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files

cd ..
}

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
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
) | 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
télécharger_mangafox
}

échec() {
while [ ${?} -ne 0 ]
do
	zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
	menu
done
}

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
}

liste_manga() {
#récupération liste manga lel.com pour 404
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
}

nettoyage_annuaires() {
[[ -f $PWD/.mangas2 ]] && mv $PWD/.mangas2 $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas_mfox ]] && mv $PWD/.mangas_mfox $HOME/.local/share/Trash/files
}

bye() {
cd ${ch}
nettoyage_annuaires
mv $PWD/wget* $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas ]] && mv $PWD/.mangas $HOME/.local/share/Trash/files
exit
}

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>@@")


#### intro ####
zenity --info --ok-label "Go!" --timeout "3" --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 (FR) : <b>${nb} titres</b>
   * mangafox.me (EN)

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"

#vérification présence fichiers 'séries' et création si besoin
function séries {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
test -f $PWD/séries
if [ $? = 1 ]
then
	> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
	> séries.mfox
fi
}

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
}

#option pdf
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || exit
case "${pdf}" in
"") pdf=""
;;
esac

if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}

séries
#404 lel
liste_manga &

#menu général avec `case`
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "370" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 1 "Télécharger mangas (FR)" 2 ">> Voir/Modifier liste de suivi (FR)" \
3 "Annuaire mangas (FR)" 4 "Télécharger mangas (EN)" 5 ">> Voir/Modifier liste de suivi (EN)" 6 "Annuaire mangas (EN)" 7 "================" 8 "Modifier le chemin de boomeranga!" 9 "Consulter l'aide en ligne" 10 "Demander une fonctionnalité") || bye
case "${option}" in
1) poursuite_series
;;
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
;;
3) annuaire
;;
4) poursuite_series_mangafox
;;
5) zenity --text-info --editable --cancel-label "Quitter" --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
;;
6) annuaire_mfox
;;
7) echo "y'a rien ici :p" && menu
;;
8) ch_maj && menu
;;
9) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
10) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
esac
}

convert_pdf
#### lancement boomeranga! ####
menu

Hors ligne

#63 Le 15/06/2013, à 12:24

hishaime

Re : boomeranga! pour les amateurs de mangas

Merci à tous pour vos améliorations ! smile

Avec la 0.9.6 (mais c'était le cas avant également), j'ai également un soucis avec fairytail. Lors de la récupération de nouveaux chapitres sur ce manga, boomeranga tourne à l'infini hmm

Quand j'ouvre le dossier "fairytail" je remarque que même si le dernier chapitre est le 335, il a tenté de télécharger dès chapitres inexistants  (j'avais killer le processus pour ne pas qu'il créer d'autres .cbz vide). C'est aussi le seul dossier qui détient 3 fichiers texte : il y a les raditionnels:
-"chaplast"
-"infochap2" et
-mais aussi un dossier "infochap"(sans le 2).

C'est d'autant plus bizarre qu'avec l'annuaire, c'est bien le chap 335 qui est reconnu comme étant le dernier.

Hors ligne

#64 Le 15/06/2013, à 13:07

WeetabiX

Re : boomeranga! pour les amateurs de mangas

Bizarre,

Je viens de tester, pas de problème chez moi. Le problème continue si tu essayes de ne télécharger qu'un chapitre puis lances la poursuite de la série ?

Hors ligne

#65 Le 15/06/2013, à 14:03

hishaime

Re : boomeranga! pour les amateurs de mangas

Oui le bug persiste.
Voilà comment j'ai procédé pour constater le bug :

1) J'ai éffacé Fairy Tail (le dossier et le titre dans le fichier série)
2) j'ai téléchargé le num 334
3) le téléchargement terminé, j'ai séléctionné "suivre les séries en cours"
4) une notification m'informe du Téléchargement de la suite de Fairytail
5) j'ai dû killer boomeranga pour qu'il arrête de téléchargé la suite, car i crée des fichier .cbz au dessus du n°335 alors que celui-ci est le dernier.

Je suis le seul à avoir ce problème?

Au faite, quand tu décides de télécharger fairytail, le message suivant s'affiche "fairytail - Télécharger tous les chapitres disponibles ?   [ paru(s) / -333 nouveau(x)]" ...ce qui est normal, mais ce qui l'est moins c'est qu'il indique -333 nouveaux chapitres, alors que ce manga commence au chapitre 231. il devrait donc proposer (334-231= ) 103 chapitres à télécharger.

Hors ligne

#66 Le 15/06/2013, à 14:23

hishaime

Re : boomeranga! pour les amateurs de mangas

J'ai compris d'où vient le problème: rien ne s'inscrit dans infochap2 avec la série Fairy tail.

Normalement, les fichiers devraient avoir inscrit :
- le prochain numéro  (n°336) téléchargé dans chaplast
-le dernier numéro téléchargé (n°335) dans infochap2

Or ici, aucun numéro n'est inscrit pour le fichier infochap2. Du coup il crée également le fichier infochap dans le dossier de fairytail, alors que ce dossier n'est normalement pas présent dans les autres mangas.

Hors ligne

#67 Le 15/06/2013, à 14:48

WeetabiX

Re : boomeranga! pour les amateurs de mangas

arghh... Changez de manga tongue

En route pour la correction :

#!/bin/bash
#weetabix' 2013

##################
#  Boomeranga!   #
##################

####dépendances#####################
# bash, wget, zip, calibre, zenity #
####################################

v=0.9.6-1
#gestion dépendances
paquet=(bash calibre wget zip)

#fonction télécharger()
function télécharger {
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 2000 "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! "
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++))

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)

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
}

#fonction télécharger_mangafox() / pas info chap. max / vol inutile (oui et non) car redirection auto fct chapitre
function télécharger_mangafox {
mkdir $manga
cd $PWD/$manga/

info=$(zenity --forms --title "boomeranga" --cancel-label "Quitter" --add-entry "Chapitre début (forme 001)" --add-entry "Chapitre fin (forme 001+1)" --window-icon "/usr/share/pixmaps/boomeranga.svg")
#chap="c${info%|*}"
chap="c"$(echo $info | cut -d "|" -f 1)
#chapmax="c${info#*|}"
chapmax="c"$(echo $info | cut -d "|" -f 2)

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 2000 "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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=`cat $PWD/infovol`
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files
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
menu
}

function télécharger_poursuite_mfox {
cd $manga
vol="v01"
chap=$(cat $PWD/chaplast)
chapmax="c"$(zenity --title "boomeranga!" --window-icon "/usr/share/pixmaps/boomeranga.svg" --entry --cancel-label "Quitter" --text "$manga - Stopper à quel chapitre (forme 001+1)? [vous êtes au n°$chap]") || exit
im=1

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

#info
notify-send -i /usr/share/pixmaps/boomeranga.svg -t 2000 "Téléchargement de la suite de $manga"

#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
wget -U=firefox http://mangafox.me/manga/$manga/$vol/$chap/$im.html -O infovol
grep '<p><span>Next Chapter:</span>' infovol > infovol2
cut -d "/" -f7 infovol2 > infovol
vol=$(cat $PWD/infovol)
cut -d "/" -f8 infovol2 > infovol
chap=$(cat $PWD/infovol)
im=1
done

echo $chapmax > $PWD/chaplast

mv $PWD/infovol $HOME/.local/share/Trash/files ; mv $PWD/infovol2 $HOME/.local/share/Trash/files

cd ..
}

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
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
) | 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
télécharger_mangafox
}

échec() {
while [ ${?} -ne 0 ]
do
	zenity --title "boomeranga!" --info --text "Echec de l'opération - retour au menu"
	menu
done
}

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
}

liste_manga() {
#récupération liste manga lel.com pour 404
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
}

nettoyage_annuaires() {
[[ -f $PWD/.mangas2 ]] && mv $PWD/.mangas2 $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas_mfox ]] && mv $PWD/.mangas_mfox $HOME/.local/share/Trash/files
}

bye() {
cd ${ch}
nettoyage_annuaires
mv $PWD/wget* $HOME/.local/share/Trash/files
[[ -f $PWD/.mangas ]] && mv $PWD/.mangas $HOME/.local/share/Trash/files
exit
}

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)


#### intro ####
zenity --info --ok-label "Go!" --timeout "3" --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 (FR) : <b>${nb} titres</b>
   * mangafox.me (EN) : 					        <b>${nb_mfox} 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"

#vérification présence fichiers 'séries' et création si besoin
function séries {
ch=$(cat $HOME/.boomeranga/ch)
mkdir -p $ch/
cd $ch
test -f $PWD/séries
if [ $? = 1 ]
then
	> séries
fi
test -f $PWD/séries.mfox
if [ $? = 1 ]
then
	> séries.mfox
fi
}

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
}

#option pdf
function convert_pdf {
pdf=$(zenity --list --checklist --cancel-label "Quitter" --title "boomeranga!" --text "Convertir en .pdf ?" --column=option --column=description 1 "activer conversion pdf") || exit
case "${pdf}" in
"") pdf=""
;;
esac

if [[ -z $pdf ]]
then pdf="n"
else pdf="o"
fi
}

séries
#404 lel
liste_manga &

#menu général avec `case`
function menu {
option=$(zenity --list --window-icon "/usr/share/pixmaps/boomeranga.svg" --width "350" --height "370" --cancel-label "Quitter" --title "boomeranga!" --text "Menu principal" --column=option --column=description 1 "Télécharger mangas (FR)" 2 ">> Voir/Modifier liste de suivi (FR)" \
3 "Annuaire mangas (FR)" 4 "Télécharger mangas (EN)" 5 ">> Voir/Modifier liste de suivi (EN)" 6 "Annuaire mangas (EN)" 7 "================" 8 "Modifier le chemin de boomeranga!" 9 "Consulter l'aide en ligne" 10 "Demander une fonctionnalité") || bye
case "${option}" in
1) poursuite_series
;;
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
;;
3) annuaire
;;
4) poursuite_series_mangafox
;;
5) zenity --text-info --editable --cancel-label "Quitter" --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
;;
6) annuaire_mfox
;;
7) echo "y'a rien ici :p" && menu
;;
8) ch_maj && menu
;;
9) xdg-open 'http://blog.goupil.eu/?boomeranga' & menu
;;
10) xdg-open 'http://forum.ubuntu-fr.org/viewtopic.php?id=1282211' & menu
;;
esac
}

convert_pdf
#### lancement boomeranga! ####
menu

Hors ligne

#68 Le 15/06/2013, à 15:43

hishaime

Re : boomeranga! pour les amateurs de mangas

merci pour la Màj !
J'ai une bonne et une mauvaise nouvelle :
le bug pour fairytail a disparu : il ne telecharge pas ( dans le vide ) des épisodes qui n'existe , mais il ne télécharge plus les nouveaux épisodes. J'ai télécharger le 334, et il ne fait pas la màj vers le 335 quand je fais "mettre à jours les séries". [Edit : il ne télécharge pas de nouveaux épisodes sûrement parce que toujours rien n'est inscrit dans infochap2]

Mais pas grave, pas besoin de se casser la tête pour un seul manga wink

Dernière modification par hishaime (Le 15/06/2013, à 15:47)

Hors ligne

#69 Le 15/06/2013, à 21:22

Hizoka

Re : boomeranga! pour les amateurs de mangas

Je me suis un peu repenché sur le logiciel :

Vis a vis des dependances :

time aptitude show zenity | grep "État: non installé"
real    0m3.115s

time ( dpkg_list=$(dpkg -l) ; egrep "^ii  zenity" <<< "${dpkg_list}")
real    0m0.100s

donc je te propose une version beaucoup plus rapide (30 fois plus rapide)

dep()
{
# Destruction de la variable des dependances manquantes
unset dep_manquante

# Liste les paquets installés
dpkg_list=$(dpkg -l)

# Boucle traitants les dependances
for dep in bash calibre wget zip
do
	# Dependance à tester
	[[ -z $(egrep "^ii  ${dep}" <<< "${dpkg_list}") ]] && dep_manquante+=(${dep})
done

# Si la variable existe alors il faut installer des paquets
if [[ ${dep_manquante[@]} ]]
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>${dep_manquante[@]}</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
}

Suffisamment rapide pour ne pas avoir besoin de la fenêtre zenity.

Evite++++++ les accents dans les commandes et noms de fonction, ca peut foutre le bordel.

Le dossier de config ne doit pas etre ~/.boomeranga mais ~/.config/boomeranga

Le demarrage est assez long, affiche une fenetre zenity qui indique que le script est lancé sinon on risque de le lancer plusieurs fois.

voilou quelques idées tongue


EDIT : voila la suite smile
le ! de boomeranga fout le bordel : ! veut dire la dernière commande
=> enlève le des fenêtres zenity

travailler avec les adresses complètes évite des soucis et des cd et co

remplacer notify-send par zenity --notification
=> quitte a utiliser zenity autant le faire pour tout

proposer de ne rien faire juste conserver les fichiers...
=> perso je préfère lire les fichiers jpg

Et voila ma version de la fonction de telechargement.
1) Recupere la page du manga contenant les chapitres disponnibles
2) Affiche les chapitres dispo (meme les chapitres bonus) et te renvoie les adresses des chapitres
3) boucle sur les chapitres pour les telecharger avec une fenetre zenity indiquant que le travail est en cours

# telechargement de la page du manga
wget -U=firefox "http://www.lecture-en-ligne.com/manga/${manga}/" -O "/tmp/${manga}.html"

# Liste affichant les chapitres dispos et renvoyant leur adresse
chap_a_dl=$(egrep -A 2 '<td class="td">.*chapitre.*</td>' "/tmp/${manga}.html" | sed 's@.*<td class="td">\(.*\)</td>@\1@ ; s@.*<a href="../../\(.*\)" class.*@\1@ ; /<td class="td">/d ; /<td>.*<\/td>/d ; /^--$/d' | zenity --list --multiple --column="Numero des chapitres disponnibles" --column="adresses" --hide-column="2" --print-column="2" --separator "\n")

# Verification qu'une selection s'est faite
if [[ -z "${chap_a_dl}" ]]
then
	echo "Erreur"
	exit
fi

# Boucle travaillant chaque chapitre
while read LINK
do
    imax=$(wget -U=firefox -qO - "http://www.lecture-en-ligne.com/${LINK}" | sed -n "/current_total_pages/ s/.*'\(.*\)'.*/\1/p")

    chap=${LINK#*/}
    chap=${chap%%/*}

    # Verification de la validité du chapitre
    if [[ -z "${imax}" ]]
    then
        echo "Erreur"
        exit
    fi

    # Creation du dossier recevant les images
    mkdir -p "/home/hizoka/Download/boomeranga/${manga}/${chap}"

    # Recuperation des images
    for im in $(seq -w ${imax})
    do
        wget -U=firefox -T 10 -t 50 http://www.lecture-en-ligne.com/images/mangas/${manga}/${chap}/${im}.jpg -O "/home/hizoka/Download/boomeranga/${manga}/${chap}/${im}.jpg"
    done | zenity --title "boomeranga" --progress --text "Récupération en cours" --text "Récupération du chapitre ${chap} en cours" --auto-close --no-cancel --pulsate

    #création du .cbz
    zip -r "/home/hizoka/Download/boomeranga/${manga}/${chap}.cbz" "/home/hizoka/Download/boomeranga/${manga}/${chap}"
    rm -r "/home/hizoka/Download/boomeranga/${manga}/${chap}"

    #conversion pdf
    [[ ${pdf} = "o" ]] && ebook-convert "/home/hizoka/Download/boomeranga/${manga}/${chap}.cbz" "/home/hizoka/Download/boomeranga/${manga}/${chap}.pdf" --right2left
done <<< "${chap_a_dl}"

# SUppression du fichier du manga
[[ -f "/tmp/${manga}.html" ]] && rm "/tmp/${manga}.html"

Dernière modification par Hizoka (Le 16/06/2013, à 09:27)


KDE Neon 64bits
Tous mes softs (MKVExtractorQt, HizoSelect, HizoProgress, Qtesseract, Keneric, Services menus...) sont sur github

Hors ligne

#70 Le 16/06/2013, à 11:24

Hizoka

Re : boomeranga! pour les amateurs de mangas

Bon bah finalement me suis fait une version en repartant de 0 en utilisant glade2script smile

voir les photos :
http://hizo.fr/linux/boomeranga/01.png
http://hizo.fr/linux/boomeranga/02.png

tout ce qu'on voit est fonctionnel.

Je n'ai pas implanté manga fox.

Le tout bien plus rapide et plus simple.

EDIT : tu peux filer ton icone boomeranga stp ?

Pour ceux qui veulent tester : http://hizo.fr/linux/boomeranga/boomeranga.tar.gz
dependance : python-gtk2

Il suffit de lancer le fichier go_boomeranga.sh

Dernière modification par Hizoka (Le 16/06/2013, à 13:59)


KDE Neon 64bits
Tous mes softs (MKVExtractorQt, HizoSelect, HizoProgress, Qtesseract, Keneric, Services menus...) sont sur github

Hors ligne

#71 Le 16/06/2013, à 13:09

chachatte

Re : boomeranga! pour les amateurs de mangas

@Hizoka Ton lien pour télécharger n'est pas valide.

Hors ligne

#72 Le 16/06/2013, à 13:29

lynn

Re : boomeranga! pour les amateurs de mangas

chachatte a écrit :

@Hizoka Ton lien pour télécharger n'est pas valide.

Ca doit être plutôt cette adresse : http://hizo.fr/linux/boomeranga/boomeranga.tar.gz tongue


«C'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!»

Coluche

Hors ligne

#73 Le 16/06/2013, à 13:42

chachatte

Re : boomeranga! pour les amateurs de mangas

@lynn Oui exact c'est ca smile

Ca ne fonctionne pas chez moi j'ai une erreur

[chachatte@cha boomeranga]$ python2 ./go_boomeranga.sh 
  File "./go_boomeranga.sh", line 6
    chemin="$(cd "$(dirname "$0")";pwd)"
                  ^
SyntaxError: invalid syntax

Dernière modification par chachatte (Le 16/06/2013, à 13:47)

Hors ligne

#74 Le 16/06/2013, à 13:44

lynn

Re : boomeranga! pour les amateurs de mangas

Fonctionne chez moi avec cette commande

./go_boomeranga.sh

«C'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!»

Coluche

Hors ligne

#75 Le 16/06/2013, à 13:47

chachatte

Re : boomeranga! pour les amateurs de mangas

@lynn

[chachatte@cha boomeranga]$ ./go_boomeranga.sh 
  File "./boomeranga.py", line 205
    print x, y
          ^
SyntaxError: invalid syntax

Hors ligne