mac 10.13 上 you-get 循环 批量 下载 脚本
you-get 批量下载脚本
参考文章:
https://blog.csdn.net/zong596568821xp/article/details/119540557
#!/bin/bash
# 在 MacPro10.13 测试通过 2022.10.05
CURRENT_DIR=$(cd $(dirname $0); pwd)
urlfile=$CURRENT_DIR/you-get-url.txt
echo $urlfile
errurlfile=you-get-error-list.txt
#declare -a urlist
# 线程数
threads=20
echo "downloading..."
start_time=`date +%s`
[ -e /tmp/fd1 ] || mkfifo /tmp/fd1
exec 3<>/tmp/fd1
rm -rf /tmp/fd1
for ((i=1;i<=$threads;i++)) # 设置进程数上限,可按需修改
do
echo >&3
done
for line in `cat $urlfile`;do
# 启动多线程
read -u3
{
if [ ! -z "$line" ];then
if [[ "$(you-get -o $CURRENT_DIR $line 2>&1 |grep "error")" != "" ]];then
echo "you-get "$line
fi
else
echo "$urlfile empty url!"
fi
echo >&3
}& # 启动多线程 结束
done
wait
stop_time=`date +%s`
echo "--------------------------------------------------"
echo "|下载视频:`sed -n '$=' $urlfile`个。下载错误:x个。线程数:$threads,用时:`expr $stop_time - $start_time`秒。"
echo "--------------------------------------------------"
exec 3<&-
exec 3>&-
exit
使用方法
把要下载的网址写到 脚本同级目录 you-get-url.txt 里即可。没有的新建。