added m3u8 restreamer and better variable handiling
This commit is contained in:
@@ -5,3 +5,9 @@ services:
|
|||||||
dockerfile: .build/prod/yt-restream.Dockerfile
|
dockerfile: .build/prod/yt-restream.Dockerfile
|
||||||
hostname: yt-restream
|
hostname: yt-restream
|
||||||
image: git.shihaam.dev/sarlink/tv/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
|
#!/bin/bash
|
||||||
|
|
||||||
|
CHANNEL_ID="${1:-$CHANNEL_ID}"
|
||||||
if [ -n "$1" ]; then
|
SLUG="${2:-$SLUG}"
|
||||||
CHANNEL_ID="$1"
|
if [ -n "$CHANNEL_ID" ]; then
|
||||||
elif [ -n "$CHANNEL_ID" ]; then
|
:
|
||||||
CHANNEL_ID="$CHANNEL_ID"
|
|
||||||
else
|
else
|
||||||
echo "Error: No channel ID provided. Use as argument or set CHANNEL_ID environment variable."
|
echo "Error: No channel ID provided. Use as argument or set CHANNEL_ID environment variable."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
# Use SLUG if provided, otherwise use CHANNEL_ID as slug
|
||||||
VIDEO_ID=$(curl -sL https://www.youtube.com/@$CHANNEL_ID/streams | grep "Tap to watch live" | sed 's/.*\/watch?v=\([^\\]*\).*/\1/')
|
SLUG="${SLUG:-$CHANNEL_ID}"
|
||||||
M3U8_STREAM_URL=$(yt-dlp -g -f b $(echo https://www.youtube.com/watch?v=$VIDEO_ID))
|
|
||||||
|
|
||||||
mkdir -p live
|
while true; do
|
||||||
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
|
VIDEO_ID=$(curl -sL "https://www.youtube.com/@$CHANNEL_ID/streams" | grep "Tap to watch live" | sed 's/.*\/watch?v=\([^\\]*\).*/\1/')
|
||||||
rm -rf live/*
|
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
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user