webtoon-scraper.sh/webtoon2html-segmented.sh

44 lines
1.7 KiB
Bash
Raw Permalink Normal View History

2021-11-11 05:34:00 +00:00
#!/bin/bash
underscore="_"
#indexentry() {
#
#}
episode_headders() {
echo '<!DOCTYPE html><html><head><title>'$(echo $img | cut -d'_' -f1,2)' - WebToon2HTML</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>img{display:block;}body{background-color:lightgrey;max-width:40em;font:1.1em/1.2em sans-serif;}h1,h2,h3{line-height:1.2em;}@media print{body{max-width:none}}</style></head><body><h2>'$(echo $img | cut -d'_' -f1,2)'</h2><hr>'
}
main () {
for img in *_???_???.jpg; do
if [ -f "$img" ]; then
if [ "$(echo $img | cut -d'_' -f2)" == "$current_episode" ]; then # Check to see if this isn't the first image of a new chapter.
echo "<img width=\"100%\" src=\"$img\">" >> "$(echo $img | cut -d'_' -f1,2).htm"
else # This is the first image for the chapter, do the initial setup.
# Put next and back arrows here
echo '</body></html>' >> "$(echo $img | cut -d'_' -f1)$underscore$current_episode.htm"
episode_headders > "$(echo $img | cut -d'_' -f1,2).htm"
echo "<img width=\"100%\" src=\"$img\">" >> "$(echo $img | cut -d'_' -f1,2).htm"
current_episode=$(echo $img | cut -d'_' -f2)
fi
fi
done
}
main
#main () {
# echo '<!DOCTYPE html><html><head>'"<title>${PWD##*/} - WebToon2HTML</title>"'<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>img{display:block}body{background-color:lightgrey;max-width:40em;font:1.1em/1.2em sans-serif;}h1,h2,h3{line-height:1.2em;}@media print{body{max-width:none}}</style></head><body>'"<h2>${PWD##*/}</h2><hr><div class=\"nospace\">"
# for i in *.jpg; do
# echo "<img width=\"100%\" src=\"$i\">"
# done
# echo "</div><hr></html>"
#}