Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
分享一个qvod下载bash脚本
Apps Section
1051
views ·
1
replies ·
To
floor
Go
electricface
deepin
2013-08-25 06:36
Author
写的非常的难以阅读
#!/bin/bash
QVOD_PIPE=/run/shm/qvod_pipe
QVOD_DOWNLOAD_BIN=$HOME/bin/downloader.exe
QVOD_DOWNLOAD_DIR=$HOME/qvod-download
NOT_FOUND_VIDEO="【失败】没有发现可供下载的视频文件!"
TMP_HTML_FILE=/tmp/tmp_html_file
download_qvod () {
#qvod_item[0] size
#qvod_item[1] hash
#qvod_item[2] name
qvod_url=qvod://${qvod_item[0]}\|${qvod_item[1]}\|${qvod_item[2]}\|
echo $qvod_url
qvod_type=${qvod_item[2]##*.}
mkdir $QVOD_DOWNLOAD_DIR &>/dev/null
qvod_dir=$QVOD_DOWNLOAD_DIR/${qvod_item[2]}
qvod_exe=${qvod_item[1]}+${qvod_item[0]}.${qvod_type}_${qvod_item[1]}.exe
mkdir "$qvod_dir" &>/dev/null
cp $QVOD_DOWNLOAD_BIN "$qvod_dir/$qvod_exe"
qvod_pid=`pgrep ${qvod_item[1]:0:15}`
if [[ ! -z $qvod_pid ]];then
echo "【消息】下载这部电影的 wine QVOD 下载进程已经启动"
exit
fi
$qvod_dir/$qvod_exe &>> $qvod_dir/qvodDownload.log &
if [ -f "$qvod_dir/${qvod_item[1]}+${qvod_item[0]}.$qvod_type" ]; then
deepin-notify "下载完成!" "${qvod_item[2]} 好了"
fi
}
parse_qvod_item (){
num=$2
qvod_size=`echo "$1"|cut -d "|" -f $((num*3+1))`
qvod_item[0]=${qvod_size#*qvod://}
qvod_item[1]=`echo "$1"|cut -d "|" -f $((num*3+2))`
qvod_item[2]=`echo "$1"|cut -d "|" -f $((num*3+3))`
}
rm -f ${QVOD_PIPE}
rm -f ${QVOD_PIPE}.ready
mkfifo -m 777 $QVOD_PIPE
if [[ "$1" =~ qvod://[0-9]+\|[A-F0-9]+\|.+\| ]] ;then
#parse_qvod_item $1 0
echo
fi
wget "$1" -O $TMP_HTML_FILE &>/dev/null
has_utf8=`file "$TMP_HTML_FILE"|grep -i "UTF-8"`
if [[ -z $has_utf8 ]];then
iconv -f gbk -t utf8 "$TMP_HTML_FILE" -o $TMP_HTML_FILE.utf8
mv $TMP_HTML_FILE.utf8 $TMP_HTML_FILE
fi
cat $TMP_HTML_FILE | while read line; do
#wget "$1" -O - | while read line; do
#cat 0.htm|iconv -f gbk -t utf8 | while read line; do
if [[ "$line" =~ qvod://[0-9]+\|[A-F0-9]+\|.+\| ]]; then
num=0
while true ;do
parse_qvod_item "$line" "$num"
if [[ -z ${qvod_item[1]} ]] ;then
echo "${qvod_array[@]}" > $QVOD_PIPE &
touch ${QVOD_PIPE}.ready
break
fi
qvod_array[$num]="${qvod_item[@]}"
num=$((num+1))
done
fi
done
if [[ ! -f ${QVOD_PIPE}.ready ]];then
echo $NOT_FOUND_VIDEO "(未发现pipe管道)"
exit 2
fi
qvod_array=(`cat "${QVOD_PIPE}" `)
qvod_array_len=`echo ${#qvod_array[@]}/3|bc`
if [[ $qvod_array_len = 0 ]];then
echo $NOT_FOUND_VIDEO "(qvod地址数组为空)"
exit 2
fi
for ((i=0;i < qvod_array_len;i++ )) ;do
qvod_item=("${qvod_array[@]:$((i*3)):3}")
qvod_file_size=`echo scale=1 \; ${qvod_item[0]}/1000000|bc`
echo "【$((i+1))】$qvod_file_size MB" "${qvod_item[2]}"
done
printf "请选择要下载的文件,输入前面的数字:" ;read qvod_num
qvod_item=("${qvod_array[@]:$(( (qvod_num-1) *3)):3}")
download_qvod
Copy the Code
Reply
Like 0
Favorite
View the author
All Replies
136******54
deepin
2013-08-25 17:17
#1
怎么用?结合浏览器用吗?
12.06的时候用这个QVOD下载器
http://www.linuxdeepin.com/forum ... &hilit=QVOD
12.12没试过,不知道还能不能用
Reply
Like 0
View the author
Please
sign
in first
New Thread
Popular Ranking
Change
viber cant write messege with other language except English
deepin 23 internal testing update on December 20, 2024
Popular Events
More