如何快速批量下载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
posted @ 2019-12-20 11:07  futuretea  阅读(3446)  评论(0编辑  收藏  举报