Compare commits

..

12 Commits

Author SHA1 Message Date
0ea2271823 Harden xTeVe update flow to prevent mapping deactivation 2026-02-09 21:04:36 +11:00
Nick
9dd5dfe180 Sync latest dockerfile changes to aarch64 dockerfile; fix mlb typo (#89)
* Sync latest dockerfile changes; edits for build to run

* add comment to explain

* fix typo
2022-10-11 09:55:44 -07:00
Cory Forsstrom
c270b5628b Use last v2 of s3 overlay 2022-10-03 10:04:33 -07:00
Cory Forsstrom
f2b90660b3 Update lazystream to v1.12.1 2022-10-03 09:40:33 -07:00
Josh Wright
20f5746fd2 feat: adds configurable starting channel number (#81)
* feat: adds configurable starting channel number

* fix: adds default values for start channel

* fix: forgot my fi
2022-01-11 14:40:45 -08:00
Johan Henkens
a64b617c24 Fix variable substitution on 127.0.0.1 (#77) 2021-12-08 00:14:05 -08:00
taylorbourne
7d7ef672e8 fix: attemping to fix plex update again (#75) 2021-11-30 12:09:33 -08:00
Cory Forsstrom
190cc66502 Fixes/host and trim (#74)
* Add host override

* Default trim to no
2021-11-10 12:36:21 -08:00
Taylor Bourne
0a4938c8a7 plex update revert 2021-11-03 17:08:13 -07:00
Taylor Bourne
7f8e113516 Merge branch 'master' into develop 2021-11-03 17:07:55 -07:00
taylorbourne
1e6334d7bd feat: make lazy stream host name configurable (#72)
* run raw plex curl request

* update sample env file

* parse raw chrome curl req

* update cronjob

* use post request to update plex

* oops

* feat: make lazystream host configurable

* feat: update xml template

* fix: revert plex update changes for now (needs more testing)

* feat: update readme
2021-11-03 17:03:49 -07:00
taylorbourne
cbbb2f7786 fix: fix plex update request (#70)
* run raw plex curl request

* update sample env file

* parse raw chrome curl req

* update cronjob

* use post request to update plex

* oops
2021-11-01 14:51:39 -07:00
9 changed files with 140 additions and 33 deletions

View File

@@ -3,7 +3,7 @@ FROM alpine:latest
LABEL maintainer="taylorbourne taylorbourne@me.com.com"
# Install S6 overlay
ARG S6_OVERLAY_RELEASE=https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-amd64.tar.gz
ARG S6_OVERLAY_RELEASE=https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-x86.tar.gz
ENV S6_OVERLAY_RELEASE=${S6_OVERLAY_RELEASE}
ADD ${S6_OVERLAY_RELEASE} /tmp/s6overlay.tar.gz
@@ -32,7 +32,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN wget https://github.com/xteve-project/xTeVe-Downloads/raw/master/xteve_linux_amd64.zip -O temp.zip; unzip temp.zip -d /usr/bin/; rm temp.zip
# Add lazystream
RUN wget https://github.com/tarkah/lazystream/releases/download/v1.11.8/lazystream-v1.11.8-x86_64-unknown-linux-musl.tar.gz -O lazystream.tar.gz; \
RUN wget https://github.com/tarkah/lazystream/releases/download/v1.12.1/lazystream-v1.12.1-x86_64-unknown-linux-musl.tar.gz -O lazystream.tar.gz; \
tar xzf lazystream.tar.gz; \
mv ././lazystream /usr/bin/lazystream; \
rm lazystream.tar.gz; \
@@ -78,7 +78,8 @@ ENV PUID=1000 \
embyApiKey= \
embyID= \
use_plexAPI=no \
trim_xmltv=yes
trim_xmltv=no \
hostOverride=
# Expose Port
EXPOSE ${XTEVE_PORT}

View File

@@ -3,7 +3,7 @@ FROM arm64v8/alpine:latest
LABEL maintainer="taylorbourne taylorbourne@me.com.com"
# Install S6 overlay
ARG S6_OVERLAY_RELEASE=https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-aarch64.tar.gz
ARG S6_OVERLAY_RELEASE=https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.3/s6-overlay-aarch64.tar.gz
ENV S6_OVERLAY_RELEASE=${S6_OVERLAY_RELEASE}
ADD ${S6_OVERLAY_RELEASE} /tmp/s6overlay.tar.gz
@@ -25,14 +25,15 @@ RUN apk upgrade --update --no-cache \
gnutls-utils
# pi4 library to run lazystream: https://github.com/ljfranklin/alpine-pkg-glibc/releases/tag/2.32-r0-arm64
# force needed due to bug: https://github.com/sgerrand/alpine-pkg-glibc/issues/185
RUN wget https://github.com/ljfranklin/alpine-pkg-glibc/releases/download/2.32-r0-arm64/glibc-2.32-r0.apk
RUN apk add --allow-untrusted glibc-2.32-r0.apk
RUN apk add --allow-untrusted --force-overwrite glibc-2.32-r0.apk
RUN wget https://github.com/ljfranklin/alpine-pkg-glibc/releases/download/2.32-r0-arm64/glibc-bin-2.32-r0.apk
RUN apk add --allow-untrusted glibc-bin-2.32-r0.apk
RUN apk add --allow-untrusted --force-overwrite glibc-bin-2.32-r0.apk
RUN wget https://github.com/ljfranklin/alpine-pkg-glibc/releases/download/2.32-r0-arm64/glibc-i18n-2.32-r0.apk
RUN apk add --allow-untrusted glibc-i18n-2.32-r0.apk
RUN apk add --allow-untrusted --force-overwrite glibc-i18n-2.32-r0.apk
# Update Timezone
ENV TZ=America/Los_Angeles
@@ -42,7 +43,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN wget https://github.com/xteve-project/xTeVe-Downloads/raw/master/xteve_linux_arm64.zip -O temp.zip; unzip temp.zip -d /usr/bin/; rm temp.zip
# Add lazystream
RUN wget https://github.com/tarkah/lazystream/releases/download/v1.11.6/lazystream-v1.11.6-aarch64-unknown-linux-gnu.tar.gz -O lazystream.tar.gz; \
RUN wget https://github.com/tarkah/lazystream/releases/download/v1.12.1/lazystream-v1.12.1-aarch64-unknown-linux-gnu.tar.gz -O lazystream.tar.gz; \
tar xzf lazystream.tar.gz; \
mv ././lazystream /usr/bin/lazystream; \
rm lazystream.tar.gz; \
@@ -88,7 +89,8 @@ ENV PUID=1000 \
embyApiKey= \
embyID= \
use_plexAPI=no \
trim_xmltv=yes
trim_xmltv=no \
hostOverride=
# Expose Port
EXPOSE ${XTEVE_PORT}

View File

@@ -42,10 +42,6 @@ or see [docker-compose.yml](docker-compose.yml) for an example docker-compose se
Defaults & behavior can be changed through environment variables. `sample.env` should be renamed to `.env` and supplied through the `--env-file` docker run option. The `.env` file can also be picked up if using this in a `docker compose` setup.
### IMPORTANT
You _MUST_ set the environment variable `lazyStreamHost` otherwise LazyStream will _not_ work.
## Cron schedule
By default, the cron job is scheduled to run every hour. A custom cron schedule can be specified by renaming the `sample_cron.txt` file in the `/config` volume to `cron.txt` and editing the schedule. Make sure to restart your container to take effect.

View File

@@ -9,6 +9,69 @@ function prepend() {
exec 1> >(prepend "[cronjob.sh] ")
LOCK_DIR=/tmp/xteve/.cronjob.lock
mkdir -p /tmp/xteve
if ! mkdir "$LOCK_DIR" 2>/dev/null; then
echo "Another cronjob instance is already running, exiting."
exit 0
fi
function cleanup() {
rmdir "$LOCK_DIR" >/dev/null 2>&1 || true
}
trap cleanup EXIT
function post_xteve_cmd() {
local cmd="$1"
local retries="${2:-5}"
local retry_sleep="${3:-2}"
local response=""
for ((attempt=1; attempt<=retries; attempt++)); do
response=$(curl -sS --max-time 120 -X POST -d "{\"cmd\":\"${cmd}\"}" "http://127.0.0.1:${XTEVE_PORT}/api/" 2>&1)
if echo "$response" | grep -q '"status"[[:space:]]*:[[:space:]]*true'; then
echo "xTeVe API ${cmd}: accepted"
return 0
fi
echo "xTeVe API ${cmd}: attempt ${attempt}/${retries} failed (${response})"
sleep "$retry_sleep"
done
echo "xTeVe API ${cmd}: failed after ${retries} attempts"
return 1
}
function xteve_internal_update_due_now() {
if [ "${skip_xteve_api_when_internal_update:-yes}" != "yes" ]; then
return 1
fi
if [ ! -f /xteve/settings.json ]; then
return 1
fi
local now_hhmm
now_hhmm=$(date +"%H%M")
local update_values
update_values=$(tr -d '\n' < /xteve/settings.json | sed -n 's/.*"update"[[:space:]]*:[[:space:]]*\[\([^]]*\)\].*/\1/p' | tr -d ' "')
if [ -z "$update_values" ]; then
return 1
fi
IFS=',' read -r -a updates <<< "$update_values"
for update_time in "${updates[@]}"; do
if [ "$update_time" = "$now_hhmm" ]; then
echo "xTeVe internal update is scheduled for ${now_hhmm}; skipping wrapper API update to avoid overlap."
return 0
fi
done
return 1
}
echo "Running scripts..."
### Generate playlist and XML data from Lazystream
@@ -19,6 +82,7 @@ if [ "$use_lazystream" = "yes" ]; then
if [ "$trim_xmltv" = "yes" ]; then args+=("--trim"); fi
if [ ! -z ${quality} ]; then args+=("--quality" "$quality"); fi
if [ "$cdn" = "l3c" ]; then args+=("--cdn" "l3c"); fi
if [ ! -z "$hostOverride" ]; then args+=("--host" "$hostOverride"); fi
if [ "$include_nhl" = "yes" ]; then
echo "Running Lazystream (NHL $quality via $cdn)..."
@@ -29,7 +93,11 @@ if [ "$use_lazystream" = "yes" ]; then
nhl_args+=("--channel-prefix")
nhl_args+=("Lazystream: NHL")
nhl_args+=("--start-channel")
nhl_args+=("1000")
if [ -z "$nhl_start_channel" ]; then
nhl_args+=("1000")
else
nhl_args+=("$nhl_start_channel")
fi
nhl_args+=("/playlists/lazystream/lazystream-nhl")
if [ "$nhl_exclude_home" = "yes" ]; then nhl_args+=("--exclude-feeds" "HOME"); fi
@@ -38,7 +106,9 @@ if [ "$use_lazystream" = "yes" ]; then
if [ "$nhl_exclude_french" = "yes" ]; then nhl_args+=("--exclude-feeds" "FRENCH"); fi
if [ "$nhl_exclude_composite" = "yes" ]; then nhl_args+=("--exclude-feeds" "COMPOSITE"); fi
set -x
lazystream generate xmltv "${args[@]}" "${nhl_args[@]}"
set +x
fi
if [ "$include_mlb" = "yes" ]; then
echo "Running Lazystream (MLB $quality via $cdn)..."
@@ -51,7 +121,11 @@ if [ "$use_lazystream" = "yes" ]; then
mlb_args+=("--channel-prefix")
mlb_args+=("Lazystream: MLB")
mlb_args+=("--start-channel")
mlb_args+=("2000")
if [ -z "$mlb_start_channel" ]; then
mlb_args+=("2000")
else
mlb_args+=("$mlb_start_channel")
fi
mlb_args+=("/playlists/lazystream/lazystream-mlb")
if [ "$mlb_exclude_home" = "yes" ]; then mlb_args+=("--exclude-feeds" "HOME"); fi
@@ -59,7 +133,9 @@ if [ "$use_lazystream" = "yes" ]; then
if [ "$mlb_exclude_national" = "yes" ]; then mlb_args+=("--exclude-feeds" "NATIONAL"); fi
if [ "$mlb_exclude_composite" = "yes" ]; then mlb_args+=("--exclude-feeds" "COMPOSITE"); fi
set -x
lazystream generate xmltv "${args[@]}" "${mlb_args[@]}"
set +x
fi
fi
@@ -81,13 +157,23 @@ sleep 1
# update xteve via API
if [ "$use_xTeveAPI" = "yes" ]; then
echo "Updating xTeVe..."
curl -s -X POST -d '{"cmd":"update.m3u"}' http://127.0.0.1:$XTEVE_PORT/api/
sleep 1
curl -s -X POST -d '{"cmd":"update.xmltv"}' http://127.0.0.1:$XTEVE_PORT/api/
sleep 1
curl -s -X POST -d '{"cmd":"update.xepg"}' http://127.0.0.1:$XTEVE_PORT/api/
sleep 1
if xteve_internal_update_due_now; then
echo "Skipping xTeVe API update in cronjob."
else
echo "Updating xTeVe..."
if post_xteve_cmd "update.m3u"; then
sleep "${xteve_m3u_settle_seconds:-2}"
if post_xteve_cmd "update.xmltv"; then
sleep "${xteve_xmltv_settle_seconds:-20}"
post_xteve_cmd "update.xepg"
sleep "${xteve_xepg_settle_seconds:-2}"
else
echo "Skipping update.xepg because update.xmltv failed."
fi
else
echo "Skipping remaining xTeVe API updates because update.m3u failed."
fi
fi
fi
# update Emby via API
@@ -104,10 +190,19 @@ fi
# update Plex via API
if [ "$use_plexAPI" = "yes" ]; then
echo "Updating Plex..."
if [ -z "$plexUpdateURL" ]; then
if [ -z "${plexUpdateURL//[[:space:]]/}" ]; then
echo "no Plex credentials provided"
elif ! echo "$plexUpdateURL" | grep -Eq '^https?://[^[:space:]]+$'; then
echo "invalid plexUpdateURL, expected a plain http(s) URL. Skipping Plex update."
else
curl -s -X POST "$plexUpdateURL"
# get protocol
proto="$(echo $plexUpdateURL | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${plexUpdateURL/$proto/})"
# extract the host
plexHostPort="$(echo ${url/} | cut -d/ -f1)"
curl --location --request POST "$plexUpdateURL" -H "authority: $plexHostPort" -H "content-length: 0" -H "pragma: no-cache" -H "cache-control: no-cache" -H "sec-ch-ua: 'Google Chrome';v='95', 'Chromium';v='95', ';Not A Brand';v='99'" -H "accept: text/plain, */*; q=0.01" -H "x-requested-with: XMLHttpRequest" -H "accept-language: en" -H "sec-ch-ua-mobile: ?0" -H "user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36" -H "sec-ch-ua-platform: 'macOS'" -H "origin: http://$plexHostPort" -H "sec-fetch-site: same-origin" -H "sec-fetch-mode: cors" -H "sec-fetch-dest: empty" -H "referer: http://$plexHostPort/web/index.html"
sleep 1
fi
fi

View File

@@ -1,4 +1,4 @@
printf '0 * * * * /cronjob.sh' > /etc/crontabs/root
printf '5 * * * * /cronjob.sh' > /etc/crontabs/root
### Remove this line and everything beneath it ###
### Edit the above cron expression, rename this file to cron.txt, and restart the container.
### If no cron.txt is found the cronjob will run every hour

View File

@@ -10,7 +10,10 @@ exec 1> >(prepend "[update-hosts] ")
# Update hosts file
export IP=$(getent ahostsv4 "$lazyStreamHost" | awk '{ print $1 }' | head -1)
if [ ! -z "$hostOverride" ]; then lazystream_host="$hostOverride"; else lazystream_host=$(lazystream host); fi
echo "Using host ${lazystream_host}"
export IP=$(getent ahostsv4 $(echo $lazystream_host | sed -e 's/https*:\/\///g') | awk '{ print $1 }' | head -1)
echo $IP playback.svcs.mlb.com >> /etc/hosts
echo $IP mf.svc.nhl.com >> /etc/hosts

View File

@@ -1 +1 @@
0 * * * * /cronjob.sh
5 * * * * /cronjob.sh

View File

@@ -7,26 +7,36 @@ PGID=1000
### Xteve Config
XTEVE_PORT=34400
use_xTeveAPI=yes
# Skip wrapper-triggered xTeVe updates if the current time matches xTeVe's internal "update" schedule.
skip_xteve_api_when_internal_update=yes
# Wait times between wrapper xTeVe update stages. XMLTV delay helps avoid mapping against in-progress downloads.
#xteve_m3u_settle_seconds=2
#xteve_xmltv_settle_seconds=20
#xteve_xepg_settle_seconds=2
### Lazystream Config
# If trim_xmltv is set to no, both NHL and MLB will output 100 placeholder channels each.
# Any unused channels will still display in your guide. Disable this feature if you have
# any trouble with Plex/Emby/etc. guide data.
trim_xmltv=yes
# If trim_xmltv is set to yes, both NHL and MLB wont output 100 placeholder channels and
# will instead only output the same number of channels as there are streams.
# Enabling this feature may cause issues with xTeVe guide data.
trim_xmltv=no
use_lazystream=yes
include_nhl=yes
nhl_start_channel=1000
#nhl_exclude_home=yes
#nhl_exclude_away=yes
#nhl_exclude_national=yes
#nhl_exclude_french=yes
#nhl_exclude_composite=yes
include_mlb=yes
mlb_start_channel=2000
#mlb_exclude_home=yes
#mlb_exclude_away=yes
#mlb_exclude_national=yes
#mlb_exclude_composite=yes
cdn=akc
#quality=720p60
# This will override the default host used by lazystream. Use in case host changes.
#hostOverride=http://yourhost.here
### Guide2go Config
use_guide2go=no

View File

@@ -172,7 +172,7 @@
<Config Name="Path" Target="/playlists" Default="/mnt/user/appdata/xteve/playlists/" Mode="rw" Description="Container Path: /playlists" Type="Path" Display="always" Required="false" Mask="false">/mnt/user/appdata/xteve/playlists/</Config>
<Config Name="Xteve API" Target="use_xTeveAPI" Default="yes" Mode="" Description="Container Variable: use_xTeveAPI" Type="Variable" Display="always" Required="false" Mask="false">yes</Config>
<Config Name="Use Lazystream" Target="use_lazystream" Default="yes" Mode="" Description="Container Variable: use_lazystream" Type="Variable" Display="always" Required="false" Mask="false">yes</Config>
<Config Name="Lazystream Host" Target="lazystream_host" Default="" Mode="" Description="Container Variable: lazyStreamHost" Type="Variable" Display="always" Required="false" Mask="false"/>
<Config Name="Lazystream Host Override" Target="hostOverride" Default="" Mode="" Description="Container Variable: hostOverride" Type="Variable" Display="always" Required="false" Mask="false"/>
<Config Name="Trim XMLTV" Target="trim_xmltv" Default="yes" Mode="" Description="Container Variable: trim_xmltv" Type="Variable" Display="always" Required="false" Mask="false">yes</Config>
<Config Name="Include NHL" Target="include_nhl" Default="yes" Mode="" Description="Container Variable: include_nhl" Type="Variable" Display="always" Required="false" Mask="false">yes</Config>
<Config Name="include MLB" Target="include_mlb" Default="yes" Mode="" Description="Container Variable: include_mlb" Type="Variable" Display="always" Required="false" Mask="false">yes</Config>