#!/bin/bash # 引数が存在しない場合、使い方を表示 if [ $# -eq 0 ]; then echo "Usage: yt-dlp_try.sh [OPTIONS] [URL]" exit 1 fi # yt-dlpのフルパスを指定 YT_DLP="yt-dlp" # yt-dlpのオプションをコマンドライン引数から受け取る OPTIONS="${@:1:$#-1}" # YouTubeの動画のURLをコマンドライン引数から受け取る URL="${@: -1}" # 定期的にyt-dlpコマンドを実行 while true; do if $YT_DLP -f 'bestvideo[height>=480]+bestaudio/best[height>=480]' $OPTIONS $URL; then echo "yt-dlp completed successfully." break else current_time=$(date +"%H:%M:%S") echo "[$current_time] yt-dlp encountered an error. Retrying in 30 minutes..." sleep 1800 # エラーが発生した場合、30分間待機 fi done