发布时间:2025-12-10 19:39:00 浏览次数:5
用 shell 脚本批量下载畅想听吧(CXT8)和 有声下吧(YSX8)的有声小说[通俗易懂]眼睛不好又迷上了小说怎么办? 那就只能用耳朵听啦。。。上下班3个小时在路上,玩手机么伤眼睛,只能听听有声小说了。最近一直在找一些有声小说听,发现想要下载下来同步到itunes里面还是有点麻烦的,都是体力活啊。于是就写了两个脚本来下载这些mp3。脚本仅供参考,请勿用于商业用途,并且最好还是支持正版吧,至少也要花点钱支持一下自己喜欢的播音员哦。CXT8的下载脚本:
眼睛不好又迷上了小说怎么办? 那就只能用耳朵听啦。。。上下班3个小时在路上,玩手机么伤眼睛,只能听听有声小说了。
最近一直在找一些有声小说听,发现想要下载下来同步到 itunes 里面还是有点麻烦的,都是体力活啊。 于是就写了两个脚本来下载这些 mp3。 脚本仅供参考,请勿用于商业用途,并且最好还是支持正版吧,至少也要花点钱支持一下自己喜欢的播音员哦。
CXT8 的下载脚本:
会自动下载所有的 mp3,前提是这些 mp3 的下载是免费的(单体下载免费即可) 目前默认使用的是电信线路,需要联通的话就自己动手改一下吧。 传入参数的 book_id 为 CXT8 的书籍 ID, 比如http://www.cxt8.com/static/chapter_2238/index_10.shtml, book_id = 2238, page_id = 10 start_page 和 end_page 为 CXT8 中需要下载的 page 起始和终止页面,比如 2 10 的话既是下载 2-10 页中的所有集数 下载下来的 mp3 没有 id3 信息,可以使用 mid3v2 工具来批量修改#!/bin/bashfail_file=`pwd`/fail.urlif [ $# != 3 ];thenecho "Usag: book_id start_page end_page"fiid=$1sta=$2end=$3download(){real=$1fileName=$2 sleep 1curl -L --connect-timeout 100 -m 600 "$real" -o $fileName}real_url(){temp=$1retry=$2perfix=`echo $temp|sed 's/\.com.*/\.com/g'` end=`curl "$temp" -v -c cookie 2>&1 |grep "Location" | sed 's/^.*\//\//g' |sed 's/.$//g'` #end=`curl "$temp" -v -c cookie 2>&1 |grep "Location" | sed 's/^.*\//\//g' |sed 's/true.*$/true/g'` full_url=$perfix$end real=`curl "$full_url" -v -b cookie 2>&1 |grep "Location"| sed 's/^.* //g' |sed 's/.$//g'`if [ '$real' == '' ];then echo "$temp" >> "$fail_file" elseecho $real fileName=`echo $real|sed 's/^.*com\///g'|sed 's/\..*/\.mp3/g'`# 是否需要下载 if [ `find . -name "$fileName" -size +6M |wc -l` == 0 ];then > "$fileName"elsereturn 0 fi echo "try download $fileName $retry times"download "$real" "$fileName" # 是否已经下载完成 if [ `find . -name "$fileName" -size +5M |wc -l` == 1 ];thenecho "$fileName download success!" return 0else echo "$temp" >> "$fail_file"return 1 fi fireturn 0}decode_url(){echo "start download page $1"res=''for url in `curl -s $1 |grep '' |grep "http:"|sed 's/^.*http/http/g'| sed 's/shtml".*/shtml/g'`;dores=''for i in `seq 1 5`;dotemp=`curl -s $url |grep '' |grep "http:"|sed 's/^.*http/http/g'| sed 's/">.*//g'`#temp=`curl -s $url |grep '' |grep "http:"|sed 's/^.*http/http/g'| sed 's/" .*//g'` if [ '$temp' == '' ];thenres=$url elsereal_url "$temp" "$i"s=$?if [ "$s" == "0" ];thenres=''breakelseres=$urlfi fidonedone}#decode_url 'http://www.cxt8.com/static/chapter_1553/'for i in `seq $sta $end`;do [ ! -d $i ] && mkdir $icd $idecode_url 'http://www.cxt8.com/static/chapter_'$id'/index_'$i'.shtml'cd ..done 是否还在为Ide开发工具频繁失效而烦恼,来吧关注以下公众号获取最新激活方式。亲测可用!
【正版授权,激活自己账号】:Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】:官方授权 正版激活 自己使用,支持Jetbrains家族下所有IDE…
YSX8 的下载脚本:
只是显示下载地址,不会直接下载,可以拷贝下载地址到迅雷中下载。 输入参数为 ysx8 的打包下载页面,比如:http://www.ysx8.net/down/d_13270.html#!/bin/bash
if [ -z $1 ];then
echo "Usag: $0 download_url"
exit -1
fi
file=$1
fail_file="$file".fail
if [ -f $fail_file ];then
rm $fail_file
fi
#for url in `cat $file |grep "http"|sed '1s/^.*http/http/g'|grep "xunlei"|sed 's/".*$//g'`;do
//g'|grep "kuai.xunlei"|sed "s/.*\(http[^']*\).*//g"`;do
sleep 4
temp=`curl -s $url |grep ''|grep -E 'xs'|sed 's/^.*href="//g'|sed 's/".*$//g'`
if [ '$temp' == '' ];then
echo $url >> "$fail_file"
else
for t in $temp;do
echo $t
done
fi
done