最近使用you-get下载大量的优酷的视频。眼下需要多线程下载,这样才能利用带宽。
但是目前不太懂如何写多线程的下载脚本。我是使用shell来写的。
估计写的可能不对,
高手指点!!
#!/bin/bash
for ((a=1;a<100;a++))
do
for ((i=1;i<11;i++))
do
if [ $i == 1 ]
then
echo $i time
else
echo $i times
fi
echo the ${2*a-1} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a-1}p link-down` &
echo the ${2*a} file of `cat link-down|wc -l` files in total
you-get `sed -n ${2*a}p link-down`
done
done
这个是双线程的,目前我只会写着一种,不知道有没有更好的写法,也没有实际测试过这个脚本能不能用。
谢谢指点!!
求多线程下载脚本
-
- 帖子: 197
- 注册时间: 2015-12-23 16:20
- 系统: ubuntu 16.04
- lilydjwg
- 论坛版主
- 帖子: 4248
- 注册时间: 2009-04-11 23:46
- 系统: Arch Linux
- 联系:
Re: 求多线程下载脚本
我曾经把 you-get 的下载部分 patch 成调用 aria2c 来下载。你会 Python 的话也可以这么干。