分享一个qvod下载bash脚本
Tofloor
poster avatar
electricface
deepin
2013-08-25 06:36
Author
写的非常的难以阅读
  1. #!/bin/bash
  2. QVOD_PIPE=/run/shm/qvod_pipe
  3. QVOD_DOWNLOAD_BIN=$HOME/bin/downloader.exe
  4. QVOD_DOWNLOAD_DIR=$HOME/qvod-download
  5. NOT_FOUND_VIDEO="【失败】没有发现可供下载的视频文件!"
  6. TMP_HTML_FILE=/tmp/tmp_html_file
  7. download_qvod () {
  8.         #qvod_item[0] size
  9.         #qvod_item[1] hash
  10.         #qvod_item[2] name
  11.         qvod_url=qvod://${qvod_item[0]}\|${qvod_item[1]}\|${qvod_item[2]}\|
  12.         echo $qvod_url
  13.         qvod_type=${qvod_item[2]##*.}
  14.         mkdir $QVOD_DOWNLOAD_DIR &>/dev/null
  15.         qvod_dir=$QVOD_DOWNLOAD_DIR/${qvod_item[2]}
  16.         qvod_exe=${qvod_item[1]}+${qvod_item[0]}.${qvod_type}_${qvod_item[1]}.exe
  17.         mkdir "$qvod_dir" &>/dev/null
  18.         cp $QVOD_DOWNLOAD_BIN "$qvod_dir/$qvod_exe"
  19.         qvod_pid=`pgrep ${qvod_item[1]:0:15}`
  20.         if [[ ! -z $qvod_pid ]];then
  21.                 echo "【消息】下载这部电影的 wine QVOD 下载进程已经启动"       
  22.                 exit
  23.         fi
  24.         $qvod_dir/$qvod_exe &>> $qvod_dir/qvodDownload.log &
  25.         if [ -f "$qvod_dir/${qvod_item[1]}+${qvod_item[0]}.$qvod_type" ]; then
  26.                 deepin-notify "下载完成!" "${qvod_item[2]} 好了"
  27.         fi
  28. }
  29. parse_qvod_item (){
  30.         num=$2
  31.         qvod_size=`echo "$1"|cut -d "|" -f $((num*3+1))`
  32.         qvod_item[0]=${qvod_size#*qvod://}
  33.         qvod_item[1]=`echo "$1"|cut -d "|" -f $((num*3+2))`
  34.         qvod_item[2]=`echo "$1"|cut -d "|" -f $((num*3+3))`                       
  35. }
  36. rm -f ${QVOD_PIPE}
  37. rm -f ${QVOD_PIPE}.ready
  38. mkfifo -m 777 $QVOD_PIPE
  39. if [[ "$1" =~ qvod://[0-9]+\|[A-F0-9]+\|.+\| ]] ;then
  40.         #parse_qvod_item $1        0
  41.         echo
  42. fi
  43. wget "$1" -O $TMP_HTML_FILE &>/dev/null
  44. has_utf8=`file "$TMP_HTML_FILE"|grep -i "UTF-8"`
  45. if [[ -z $has_utf8 ]];then
  46.         iconv -f gbk -t utf8 "$TMP_HTML_FILE" -o $TMP_HTML_FILE.utf8
  47.         mv $TMP_HTML_FILE.utf8 $TMP_HTML_FILE
  48. fi
  49. cat $TMP_HTML_FILE | while read line; do
  50. #wget "$1" -O - | while read line; do
  51. #cat 0.htm|iconv -f gbk -t utf8  | while read line; do
  52.     if [[ "$line" =~ qvod://[0-9]+\|[A-F0-9]+\|.+\| ]]; then
  53.                 num=0
  54.                 while true ;do
  55.                         parse_qvod_item "$line" "$num"
  56.                         if [[ -z ${qvod_item[1]} ]] ;then
  57.                                 echo "${qvod_array[@]}" > $QVOD_PIPE &
  58.                                 touch ${QVOD_PIPE}.ready
  59.                                 break
  60.                         fi
  61.                         qvod_array[$num]="${qvod_item[@]}"
  62.                         num=$((num+1))
  63.                 done
  64.     fi
  65. done
  66. if [[ ! -f ${QVOD_PIPE}.ready ]];then
  67.         echo $NOT_FOUND_VIDEO "(未发现pipe管道)"
  68.         exit 2
  69. fi
  70. qvod_array=(`cat "${QVOD_PIPE}" `)
  71. qvod_array_len=`echo ${#qvod_array[@]}/3|bc`
  72. if [[ $qvod_array_len = 0 ]];then
  73.         echo $NOT_FOUND_VIDEO "(qvod地址数组为空)"
  74.         exit 2
  75. fi
  76. for ((i=0;i < qvod_array_len;i++ )) ;do
  77.         qvod_item=("${qvod_array[@]:$((i*3)):3}")
  78.         qvod_file_size=`echo scale=1 \; ${qvod_item[0]}/1000000|bc`
  79.         echo "【$((i+1))】$qvod_file_size MB" "${qvod_item[2]}"
  80. done
  81. printf "请选择要下载的文件,输入前面的数字:" ;read qvod_num
  82. qvod_item=("${qvod_array[@]:$(( (qvod_num-1) *3)):3}")
  83. download_qvod
Copy the Code
Reply 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 View the author