added m3u8 restreamer and better variable handiling
This commit is contained in:
@@ -5,3 +5,9 @@ services:
|
||||
dockerfile: .build/prod/yt-restream.Dockerfile
|
||||
hostname: yt-restream
|
||||
image: git.shihaam.dev/sarlink/tv/yt-restream
|
||||
m3u8-restream:
|
||||
build:
|
||||
context: ../../
|
||||
dockerfile: .build/prod/m3u8-restream.Dockerfile
|
||||
hostname: m3u8-restream
|
||||
image: git.shihaam.dev/sarlink/tv/m3u8-restream
|
||||
|
||||
11
.build/prod/m3u8-restream.Dockerfile
Normal file
11
.build/prod/m3u8-restream.Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM debian:latest
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
RUN apt update \
|
||||
&& apt install -y python3 curl ffmpeg
|
||||
|
||||
COPY m3u8-restream.sh .
|
||||
WORKDIR /var/www/html
|
||||
|
||||
CMD python3 -m http.server -d live/ & /root/m3u8-restream.sh
|
||||
20
m3u8-restream.sh
Executable file
20
m3u8-restream.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
M3U8_STREAM_URL="${1:-$M3U8_STREAM_URL}"
|
||||
SLUG="${2:-$SLUG}"
|
||||
USER_AGENT="${3:-$USER_AGENT}"
|
||||
|
||||
if [ -n "$M3U8_STREAM_URL" ] && [ -n "$SLUG" ]; then
|
||||
:
|
||||
else
|
||||
echo "Error: M3U8 URL and SLUG required. Provide both as arguments or set M3U8_STREAM_URL and SLUG environment variables."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p live
|
||||
|
||||
if [ -n "$USER_AGENT" ]; then
|
||||
ffmpeg -user_agent "$USER_AGENT" -i "$M3U8_STREAM_URL" -c copy -f hls -hls_time 6 -hls_list_size 10 -hls_flags delete_segments "live/$SLUG.m3u8"
|
||||
else
|
||||
ffmpeg -i "$M3U8_STREAM_URL" -c copy -f hls -hls_time 6 -hls_list_size 10 -hls_flags delete_segments "live/$SLUG.m3u8"
|
||||
fi
|
||||
@@ -1,20 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
CHANNEL_ID="$1"
|
||||
elif [ -n "$CHANNEL_ID" ]; then
|
||||
CHANNEL_ID="$CHANNEL_ID"
|
||||
CHANNEL_ID="${1:-$CHANNEL_ID}"
|
||||
SLUG="${2:-$SLUG}"
|
||||
if [ -n "$CHANNEL_ID" ]; then
|
||||
:
|
||||
else
|
||||
echo "Error: No channel ID provided. Use as argument or set CHANNEL_ID environment variable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
VIDEO_ID=$(curl -sL https://www.youtube.com/@$CHANNEL_ID/streams | grep "Tap to watch live" | sed 's/.*\/watch?v=\([^\\]*\).*/\1/')
|
||||
M3U8_STREAM_URL=$(yt-dlp -g -f b $(echo https://www.youtube.com/watch?v=$VIDEO_ID))
|
||||
# Use SLUG if provided, otherwise use CHANNEL_ID as slug
|
||||
SLUG="${SLUG:-$CHANNEL_ID}"
|
||||
|
||||
mkdir -p live
|
||||
timeout 21555 ffmpeg -i $M3U8_STREAM_URL -c copy -f hls -hls_time 6 -hls_list_size 10 -hls_flags delete_segments live/$CHANNEL_ID.m3u
|
||||
rm -rf live/*
|
||||
while true; do
|
||||
VIDEO_ID=$(curl -sL "https://www.youtube.com/@$CHANNEL_ID/streams" | grep "Tap to watch live" | sed 's/.*\/watch?v=\([^\\]*\).*/\1/')
|
||||
M3U8_STREAM_URL=$(yt-dlp -g -f b "https://www.youtube.com/watch?v=$VIDEO_ID")
|
||||
mkdir -p "live/$SLUG"
|
||||
timeout 21555 ffmpeg -i "$M3U8_STREAM_URL" -c copy -f hls -hls_time 6 -hls_list_size 10 -hls_flags delete_segments "live/$SLUG/live.m3u8"
|
||||
rm -rf "live/$SLUG"/*
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user