如何快速批量下載m3u8(ts)視頻?


安裝oopsguy/m3u8

https://github.com/oopsguy/m3u8

腳本如下

#!/usr/bin/env bash
[[ -n $DEBUG ]] && set -x
set -eou pipefail

useage() {
    cat <<HELP
USAGE:
    download_m3u8.sh CONFIGFILE DIR
HELP
}

exit_err() {
    echo >&2 "${1}"
    exit 1
}

if [ $# -lt 2 ]; then
    useage
    exit 1
fi
CONFIGFILE=$1
DIR=$2
mkdir -p "${DIR}"
while read -r line;do
arr=($line)
sub="${DIR}/${arr[0]}"
if [ ! -f "${sub}/main.ts" ];then
m3u8 -u="${arr[1]}" -o="${sub}"
fi
done < "${CONFIGFILE}"

定義索引文件 example.index

格式如下
序號 空格 m3u8地址

1 http://example.com/1/hls/index.m3u8
2 http://example.com/1/hls/index.m3u8

下載

download_m3u8.sh example.index ~/Download/example


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM