Last active
April 2, 2023 03:42
-
-
Save able8/f4fc87ca3930d565ee9c5383c49cae16 to your computer and use it in GitHub Desktop.
下载出错,就重新执行下载。在bilibili下载时,经常会出错下载中断,需要重新运行命令才行。该脚本可以自动重试下载,直到下载完成后结束。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
老铁你好,请问$?这个变数是怎么来的?