-
-
Save chulini/d00eff89b9a307c5c3080981879526a8 to your computer and use it in GitHub Desktop.
get one piece mangas german subbed from onepiece-tube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [ ! $# -eq 1 ]; then | |
echo "Usage: ./getopger <chapter>"; | |
exit 1; | |
fi | |
# Kapitel des Mangas | |
CHAPTER="$1" | |
# URI zur Hautpseite des Kapitels | |
URI="http://onepiece-tube.com/kapitel/${CHAPTER}/1" | |
# Hauptverzeichnis des Mangas | |
BASE="onepiece/" | |
# Verzeichnis des Kapitels | |
CHAPTER_BASE="${BASE}/${CHAPTER}" | |
if [ ! -d "${CHAPTER_BASE}" ]; then | |
mkdir -p "${CHAPTER_BASE}" | |
fi | |
# gibt die Anzahl der Seiten des Kapitels | |
# | |
# @return Anzahl | |
getPageCount () { | |
local PAGES=$(wget -q "${URI}" -O - | grep 'var lastimg = ' | sed 's#.*var lastimg = ##g' | sed 's#;.*##g') | |
return $PAGES; | |
} | |
# gibt die URI des Bildes der Seite. | |
# | |
# @param string URI der Seite | |
# @output string | |
getImageUri () { | |
local IMAGEURI=$(wget -q "${1}" -O - | grep 'id="p"' | sed 's/.*src="//g' | sed 's/".*//g') | |
echo "${IMAGEURI}" | |
} | |
# gibt die URI zu der Seite eines Bildes. | |
# | |
# @param number Seitennummer | |
# @output string URI | |
getPageUri () { | |
echo "http://onepiece-tube.com/kapitel/${CHAPTER}/${1}" | |
} | |
# lädt alle Seiten des Kapitels herunter. | |
# | |
getPages () { | |
getPageCount; | |
local PAGES=$? | |
echo "Found ${PAGES} pages." | |
for (( i=1; i<=$PAGES; i++ )); do | |
URI=$(getPageUri $i) | |
IMAGEURI=$(getImageUri $URI) | |
echo -n "Get page ${i} from ${IMAGEURI}... " | |
wget -q ${IMAGEURI} --directory-prefix=${CHAPTER_BASE} -nc | |
if [ $? -eq 0 ]; then | |
echo ":)" | |
else | |
echo ":( RETRY:" | |
wget ${IMAGEURI} --directory-prefix=${CHAPTER_BASE} -nc | |
fi | |
done; | |
} | |
echo "Get chapter ${CHAPTER}..." | |
getPages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment