add yt-restreamer and build prod docker image
This commit is contained in:
7
.build/prod/compose.yml
Normal file
7
.build/prod/compose.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
yt-restream:
|
||||||
|
build:
|
||||||
|
context: ../../
|
||||||
|
dockerfile: .build/prod/yt-restream.Dockerfile
|
||||||
|
hostname: yt-restream
|
||||||
|
image: git.shihaam.dev/sarlink/tv/yt-restream
|
||||||
12
.build/prod/yt-restream.Dockerfile
Normal file
12
.build/prod/yt-restream.Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM debian:latest
|
||||||
|
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
RUN apt update \
|
||||||
|
&& apt install -y python3-pip curl ffmpeg \
|
||||||
|
&& pip install yt-dlp --break-system-packages
|
||||||
|
|
||||||
|
COPY yt-restream.sh .
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
CMD python3 -m http.server -d live/ & /root/yt-restream.sh
|
||||||
20
yt-restream.sh
Executable file
20
yt-restream.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
CHANNEL_ID="$1"
|
||||||
|
elif [ -n "$CHANNEL_ID" ]; then
|
||||||
|
CHANNEL_ID="$CHANNEL_ID"
|
||||||
|
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))
|
||||||
|
|
||||||
|
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/*
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user