Skip to content

Instantly share code, notes, and snippets.

@wastee
Forked from able8/you-get-retry.sh
Created February 10, 2022 06:07
Show Gist options
  • Save wastee/16ccbf6f060c1d972fa9913ec174b7a3 to your computer and use it in GitHub Desktop.
Save wastee/16ccbf6f060c1d972fa9913ec174b7a3 to your computer and use it in GitHub Desktop.
下载出错,就重新执行下载。在bilibili下载时,经常会出错下载中断,需要重新运行命令才行。该脚本可以自动重试下载,直到下载完成后结束。
#!/bin/bash
url='https://www.bilibili.com/video/av17981530'
# 一行写法
while true; do you-get $url && { echo ok完成; break; } || { echo err出错,重试; sleep 5; }; done
while true; do you-get $url --playlist && { echo ok完成; break; } || { echo err出错,重试; sleep 5; }; done
# 简明写法
while true
do
you-get $url
if [ $? -eq 0 ]; then
echo "--------------- job complete ---------------"
break;
else
echo "...............error occur, retry in 2 seconds .........."
sleep 2
fi
done
# 多任务下载
#!/bin/bash
BaseUrl="https://www.bilibili.com/video/av22856532/?p="
for i in {1..22}
do
echo "${BaseUrl}$i"
( you-get "${BaseUrl}$i" || you-get "${BaseUrl}$i" || echo "${BaseUrl}$i" >> err.txt ) &
sleep 3
if [ $((i%10)) -eq 0 ];then
wait
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment