如何快速批量下载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