Updated
ตอนนี้สคริปต์ One Manga Downloader เวอร์ชันล่าสุด อยู่บน GitHub ครับ
The latest version of One Manga Downloader is now hosted on GitHub.
พอดีมีคนเจอบั๊กในสคริปต์ คือมันจะ error ตอนพยายามดาวน์โหลด chapter ที่มีเลขเป็นทศนิยม (ตัวอย่างเช่น Tengen Toppa Gurren Lagann)
สาเหตุคือผมใช้ -eq หรือ -le ในการเปรียบเทียบเลข chapter ซึ่งมันจะเปรียบเทียบไ้ด้เฉพาะเลขจำนวนเต็มเท่านั้น
วิธีแก้คือ ใช้โปรแกรม bc ในการเปรียบเทียบค่าแทน เช่นจากเดิมเป็นแบบนี้
while [[ ${chapter} -le ${last_chapter} ]]
ก็เปลี่ยนเป็น
while [[ `echo "${chapter} <= ${last_chapter}" | bc` -eq 1 ]]
สุดท้ายจะได้สคริปต์เวอร์ชันอัพเดต ตามนี้ (ต้องเลือกลง bc เพิ่มใน cygwin ด้วย)
#!/bin/bash base_url="http://www.onemanga.com" manga_name=$1 chapter=$2 last_chapter=$3 if [[ "${chapter}" == "" ]]; then echo "getting latest chapter number..." latest_chapter=`curl -s ${base_url}/${manga_name}/ | grep -i "ch-subject" | grep -v -i "chapter name" | head -1 | awk -F\/ '{print $3}'` printf "the latest chapter of ${manga_name} is ${latest_chapter}. download it? ([y]/n): " read answer if [[ "${answer}" == "y" || "${answer}" == "" ]]; then chapter=$latest_chapter else exit fi fi if [[ "${last_chapter}" == "" ]]; then last_chapter=${chapter} fi while [[ `echo "${chapter} <= ${last_chapter}" | bc` -eq 1 ]] do printf "downloading chapter ${chapter}\n[>" next_page_chapter=$chapter page_location=`curl -s ${base_url}/${manga_name}/${chapter}/ | grep -i "begin reading" | awk -F\" '{print $2}'` while [[ `echo "$next_page_chapter == $chapter" | bc` -eq 1 ]] 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 printf "\b=>" wget -q $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 cbr_file_name="${manga_name}_${chapter}.cbr" printf "\b]\ncreating ${cbr_file_name}... " /cygdrive/c/Program\ Files/WinRAR/Rar.exe a -inul ${cbr_file_name} *.jpg echo "DONE." rm *.jpg chapter=$next_page_chapter done rm tmp_page
ปล. ลืมบอกว่าแก้บั๊กตรงบรรทัดที่ 3 จากล่างด้วยครับ ใช้ $next_page_chapter แทนการบวก chapter เพิ่มทีละ 1 เพราะถ้าเลข chapter เป็นทศนิยม บวก 1 แล้วมันจะข้ามไปเลย เช่น ถ้ามี chapter 7.5 มันจะข้ามจาก 7 -> 8 โดยไม่โหลด 7.5 เป็นต้น

1 comment
you can try out this software http://forum.nihonomaru.com/everything-nothing/124510-onemanga-downloader-version-1-0-a.html
Post new comment