Updated
อยากอ่านการ์ตูนย้อนหลังใน One Manga แต่ขี้เกียจคลิกทีละหน้า เลยเขียน shell scipt บน Cygwin ให้โหลดมาทีละ chapter แล้วเซฟเป็นไฟล์ .cbr จะได้เลือกอ่านได้ง่ายๆ
สคริปต์ที่ใช้ก็ประมาณนี้
#!/bin/bash
base_url="http://www.onemanga.com"
manga_name=$1
chapter=$2
last_chapter=$3
if [[ "${last_chapter}" == "" ]]; then
last_chapter=${chapter}
fi
while [[ ${chapter} -le ${last_chapter} ]]
do
next_page_chapter=$chapter
page_location=`curl -s ${base_url}/${manga_name}/${chapter}/ | grep -i "begin reading" | awk -F\" '{print $2}'`
while [[ $next_page_chapter -eq $chapter ]]
do
curl -s ${base_url}${page_location} > tmp_page
image_location=`grep "class=\"manga-page\"" < tmp_page | awk -F\" '{print $4}'`
if [[ "$image_location" != "" ]]; then
wget $image_location
fi
page_location=`grep "value=\"next page\"" < tmp_page | awk -F\' '{print $2}'`
next_page_chapter=`echo ${page_location} | cut -d\/ -f3`
done
/cygdrive/c/Program\ Files/WinRAR/Rar.exe a ${manga_name}_${chapter}.cbr *.jpg
rm *.jpg
chapter=$((chapter+1))
done
rm tmp_page
สร้าง directory ใหม่ซักอันนึง แล้วเซฟ shell script ข้างบนเป็นไฟล์ชื่ออะไรก็ได้ เช่น onemanga.sh แล้วสั่ง chmod +x onemanga.sh เพื่อให้สามารถ execute ได้
วิธีใช้ก็เรียกสคริปต์ ตามด้วยชื่อเรื่อง (หาจาก URL ใน One Manga), chapter เริ่มต้น และ chapter สุดท้าย เช่น
./onemanga.sh Hajime_no_Ippo 800 824
หรือถ้าต้องการแค่ chapter เดียว ก็ไม่ต้องใส่ chapter สุดท้าย
./onemanga.sh One_Piece 516
ปล. ถ้ารันบน Cygwin ต้องลง cURL กับ wget ด้วย (เลือกจากใน setup.exe) ถ้ารันบนลินุกซ์ หรือไม่ได้ใช้ WinRAR ก็ต้องแก้บรรทัดที่เรียก Rar.exe เป็นอย่างอื่นแทน :P
Recent comments
3 days 8 hours ago
3 days 21 hours ago
3 days 23 hours ago
1 week 4 days ago
2 weeks 21 hours ago
2 weeks 5 days ago
2 weeks 5 days ago
3 weeks 2 hours ago