-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathytstream
More file actions
executable file
·20 lines (20 loc) · 1.22 KB
/
ytstream
File metadata and controls
executable file
·20 lines (20 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
[ -z "$1" ] && printf "Missing link\n" 2>&1 && exit
[ -z "$2" ] && printf "%s\n" "Missing Output Name" 2>&1 && exit
raw=$(curl -s "$1" -w "\n")
m3u8=$(printf "%s" "$raw" | grep -o -i "hlsManifesturl.*\.m3u8" | sed 's/hlsManifestUrl"\:"//g')
title=$(printf "%s" "$raw" | grep -o "title\"\:.*\",\"leng" | sed -e 's/title"\:"//g' -e 's/","leng//g' -e 's/ /_/g' -e 's/\//-/g')
date=$(printf "%s" "$raw" | grep -o "startDate\" content=\".*\"></s" | grep -oP "\d{4}-\d{2}-\d{2}")
printf "%s\n" "$m3u8"
hlsStream=$(curl -s "$m3u8" | tail -n 1)
#hlsStream=$(curl -s "$m3u8" | tail -n 5 | head -n 1)
[ -z "$2" ] && filename="$(pwd)/${date}_${title}.ts" || filename="$(pwd)/$2.ts"
[ -f "$filename" ] && read -r -p "File Exists Overwrite File?[y\\N]: " is_overwrite && is_prompt="1"
if [ "${is_prompt}" == "1" ] && [ "${is_overwrite}" == "y" -o "${is_overwrite}" == "Y" ]; then
ow=" -y"
elif [ "${is_prompt}" == "1" ]; then
exit 1
fi
printf "%s\n%s" "$filename" "$hlsStream"
ffmpeg -f hls -probesize 50M -i "$hlsStream" -fflags nobuffer -c copy -avoid_negative_ts make_zero -reconnect_delay_max 5 $ow "$filename"
#ffmpeg -probesize 50M -i $hlsStream -fflags nobuffer -c copy -avoid_negative_ts make_zero -bsf:a aac_adtstoasc $ow "$filename"