#!/bin/bash
read -p "Input m3u8 url (xxx.m3u8):" urlm3u8
read -p "sava name:" savename
#num=$((`echo $urlm3u8 | sed 's/\//\n/g' | wc -l` - 1 ))
#echo $num
#baseurl=`echo $urlm3u8 | cut -d \/ -f 1-$num `
baseurl=`echo $urlm3u8 | cut -d \/ -f 1-3`
echo $baseurl
mkdir $savename
cd $savename
wget $urlm3u8 -O filem3u8
grep .ts filem3u8 > filelist
num=$((`tail -1 filelist | sed 's/\//\n/g' | wc -l`))
echo $num
nu=`expr $num - 1`
basepath=`tail -1 filelist | cut -d \/ -f 1-$nu`
echo $basepath
wget $baseurl$basepath/key.key
basepath2=$(echo $basepath | sed 's/\//\\\//g')
echo $basepath2
sed -i "s/'$basepath2'//g" filem3u8
sed -i 's/\///g' filem3u8
cut -d \/ -f $num filelist > filelist1
sed -i 's/^/file /g' filelist1
for i in `cat filelist`
do
wget -q --show-progress ${baseurl}/$i
done
f#fmpeg -allowed_extensions ALL -i filem3u8 $savename.mp4
exit
下载