求多线程下载脚本

sh/bash/dash/ksh/zsh等Shell脚本
回复
yubinalice
帖子: 197
注册时间: 2015-12-23 16:20
系统: ubuntu 16.04

求多线程下载脚本

#1

帖子 yubinalice » 2017-08-28 18:47

最近使用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

这个是双线程的,目前我只会写着一种,不知道有没有更好的写法,也没有实际测试过这个脚本能不能用。

谢谢指点!!
头像
lilydjwg
论坛版主
帖子: 4248
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: 求多线程下载脚本

#2

帖子 lilydjwg » 2017-09-01 14:00

我曾经把 you-get 的下载部分 patch 成调用 aria2c 来下载。你会 Python 的话也可以这么干。
回复