diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c603d5c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +FROM alpine:latest +RUN apk update +RUN apk upgrade +RUN apk add --no-cache ca-certificates + +MAINTAINER taylorbourne taylorbourne@me.com.com + +# Extras +RUN apk add --no-cache curl +RUN apk add openssl + +# Timezone (TZ) +RUN apk update && apk add --no-cache tzdata +ENV TZ=America/Los_Angeles +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Add Bash shell & dependancies +RUN apk add --no-cache bash busybox-suid su-exec + +# Volumes +VOLUME /config +VOLUME /playlists +VOLUME /guide2go +VOLUME /root/.xteve +VOLUME /tmp/xteve + +# Add ffmpeg and vlc +RUN apk add ffmpeg +RUN apk add vlc +RUN sed -i 's/geteuid/getppid/' /usr/bin/vlc + +# Add SSL certs for lazystream +# RUN openssl s_client -showcerts -connect freegamez.ga:443 /dev/null|openssl x509 -outform PEM > /etc/ssl/certs/mf.svc.nhl.com.pem +# RUN openssl s_client -showcerts -connect freegamez.ga:443 /dev/null|openssl x509 -outform PEM > /etc/ssl/certs/playback.svcs.mlb.com.pem +# RUN openssl s_client -showcerts -connect freegamez.ga:443 /dev/null|openssl x509 -outform PEM > /etc/ssl/certs/mlb-ws-mf.media.mlb.com.pem + +# Add xTeve and guide2go +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 guide2go /usr/bin/guide2go + +# Add lazystream +ADD lazystream /usr/bin/lazystream +ADD cronjob.sh / +ADD entrypoint.sh / +ADD sample_cron.txt / +ADD sample_xteve.txt / + +# Set executable permissions +RUN chmod +x /entrypoint.sh +RUN chmod +x /cronjob.sh +RUN chmod +x /usr/bin/lazystream +RUN chmod +x /usr/bin/xteve +RUN chmod +x /usr/bin/guide2go + +# Expose Port +EXPOSE 34400 + +# Entrypoint +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/cronjob.sh b/cronjob.sh new file mode 100644 index 0000000..bcedb07 --- /dev/null +++ b/cronjob.sh @@ -0,0 +1,130 @@ +#!/bin/bash + +##### Config +use_xTeveAPI="yes" +use_embyAPI="no" +use_plexAPI="no" +use_TVH_Play="no" +use_TVH_move="no" + +### List of created lineup json files in /guide2go +# sample with 3 jsons lineups, adjust to yours +JsonList="CBLguide.json SATguide.json SATSport.json" + +### to create your lineups do as follows and follow the instructions +# docker exec -it guide2go -configure /guide2go/.json + +### xTeve ip, Port in case API is used to update XEPG +xTeveIP="192.168.1.2" +xTevePORT="34400" + +### Generate playlist and xml data from lazystream +lazystream generate xmltv /playlist/lazystream + +### Emby ip, Port, apiKey, update ID in case API is used to update EPG directly after guide2go +# ONLY when xteve API is in use, otherwise obsolete +# API Key, https://github.com/MediaBrowser/Emby/wiki/Api-Key-Authentication +# embyID, settings, scroll down click API, Scheduled Task Service, GET /ScheduledTasks, Try, Execute, look for "Refresh Guide" ID, sample here 9492d30c70f7f1bec3757c9d0a4feb45 +embyIP="192.168.1.2" +embyPORT="8096" +embyApiKey="" +embyID="9492d30c70f7f1bec3757c9d0a4feb45" + +### Plex ip, Port, Token, TV Section ID in case API is used to update EPG directly after guide2go +# ONLY when xteve API is in use, otherwise obsolete +# Plex Token, https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ +# plexID, http://YOUR_IP_HERE:32400/?X-Plex-Token=YOUR_TOKEN_HERE , look for "tv.plex.providers.epg.xmltv: ", sample here 11 +plexIP="192.168.1.2" +plexPORT="32400" +plexToken="" +plexID="11" + +### TVHeadend ip, Port in case m3u Playlist is wanted +TVHIP="192.168.1.2" +TVHPORT="9981" +TVHUSER="username" +TVHPASS="password" +TVHOUT="/root/.xteve/data/channels.m3u" + +### Copy a final xml (sample xteve) to tvheadend Data ### u have to mount TVHPATH data dir +TVHSOURCE="/root/.xteve/data/xteve.xml" +TVHPATH="/TVH" + +# cronjob, check sample_cron.txt with an editor to adjust time + +### END Config +## +# + +# run guide2go in loop +if [ "$use_guide2go" = "yes" ]; then + for jsons in $JsonList + do + jsonefile="${jsons%.*}" + filecache=' "file.cache": "/guide2go/cache_'$jsons'",' + fileoutput=' "file.output": "/guide2go/'$jsonefile'.xml",' + sed -i "/file.cache/c $filecache" /guide2go/$jsons + sed -i "/file.output/c $fileoutput" /guide2go/$jsons + guide2go -config /guide2go/$jsons + done +fi + +sleep 1 + +# get TVH playlist +if [ "$use_TVH_Play" = "yes" ]; then + if [ -z "$TVHIP" ]; then + echo "no TVHeadend credentials" + else + if [ -z "$TVHUSER" ]; then + wget -O $TVHOUT http://$TVHIP:$TVHPORT/playlist + else + wget -O $TVHOUT http://$TVHUSER:$TVHPASS@$TVHIP:$TVHPORT/playlist + fi + fi +fi + +sleep 1 + +# update xteve via API +if [ "$use_xTeveAPI" = "yes" ]; then + if [ -z "$xTeveIP" ]; then + echo "no xTeve credentials" + else + curl -X POST -d '{"cmd":"update.xmltv"}' http://$xTeveIP:$xTevePORT/api/ + sleep 1 + curl -X POST -d '{"cmd":"update.xepg"}' http://$xTeveIP:$xTevePORT/api/ + sleep 1 + fi +fi + +# copy file to TVHeadend +if [ "$use_TVH_move" = "yes" ]; then + if [ -z "$TVHPATH" ]; then + echo "no Path credential" + else + cp $TVHSOURCE $TVHPATH/guide.xml + fi +fi + +# update Emby via API +if [ "$use_embyAPI" = "yes" ]; then + if [ -z "$embyIP" ]; then + echo "no Emby credentials" + else + curl -X POST "http://$embyIP:$embyPORT/emby/ScheduledTasks/Running/$embyID?api_key=$embyApiKey" -H "accept: */*" -d "" + sleep 1 + fi +fi + +# update Plex via API +if [ "$use_plexAPI" = "yes" ]; then + if [ -z "$plexIP" ]; then + echo "no Plex credentials" + else + curl -s "http://$plexIP:$plexPORT/livetv/dvrs/$plexID/reloadGuide?X-Plex-Product=Plex%20Web&X-Plex-Version=4.8.4&X-Plex-Client-Identifier=$plexToken&X-Plex-Platform=Firefox&X-Plex-Platform-Version=69.0&X-Plex-Sync-Version=2&X-Plex-Features=external-media&X-Plex-Model=bundled&X-Plex-Device=Linux&X-Plex-Device-Name=Firefox&X-Plex-Device-Screen-Resolution=1128x657%2C1128x752&X-Plex-Language=de" -H "User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0" -H "Accept: text/plain, */*; q=0.01" -H "Accept-Language: de" --compressed -H "X-Requested-With: XMLHttpRequest" -H "Connection: keep-alive" -H "Referer: http://$plexIP:$plexPORT/web/index.html" --data "" + sleep 1 + fi +fi + +exit \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..eb1e86f --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +crond -l 2 + +CRONJOB_FILE=/config/cronjob.sh + +if [ -f "$CRONJOB_FILE" ]; then + echo "$CRONJOB_FILE exist" + chmod +x $CRONJOB_FILE + chmod 777 $CRONJOB_FILE +else + echo "$CRONJOB_FILE does not exist" + cp /cronjob.sh $CRONJOB_FILE + chmod +x $CRONJOB_FILE + chmod 777 $CRONJOB_FILE +fi + +CRON_FILE=/config/cron.txt + +if [ -f "$CRON_FILE" ]; then + . $CRON_FILE +else + printf '0 0 * * * /config/cronjob.sh' > /etc/crontabs/root + cp /sample_cron.txt /config/sample_cron.txt +fi + +XTEVE_FILE=/config/xteve.txt + +if [ -f "$XTEVE_FILE" ]; then + . $XTEVE_FILE +else + cp /sample_xteve.txt /config/sample_xteve.txt + xteve -port=34400 -config=/root/.xteve/ +fi + +exit \ No newline at end of file diff --git a/guide2go b/guide2go new file mode 100755 index 0000000..d826ed2 Binary files /dev/null and b/guide2go differ diff --git a/lazystream b/lazystream new file mode 100755 index 0000000..eb839c3 Binary files /dev/null and b/lazystream differ diff --git a/sample_cron.txt b/sample_cron.txt new file mode 100644 index 0000000..320efe4 --- /dev/null +++ b/sample_cron.txt @@ -0,0 +1,6 @@ +printf '45 04 * * * /config/cronjob.sh' > /etc/crontabs/root +### remove from here including this line ### +### edit your cron time +### rename to cron.txt +### restart docker, new cron time from then +### no cron.txt it ll update daily at 00:00 \ No newline at end of file diff --git a/sample_xteve.txt b/sample_xteve.txt new file mode 100644 index 0000000..e5df2ee --- /dev/null +++ b/sample_xteve.txt @@ -0,0 +1,6 @@ +xteve -port=34400 -config=/root/.xteve/test/ +### remove from here including this line ### +### edit your xteve command +### rename to xteve.txt +### restart docker, xteve will run with given parameter +### no xteve.txt it ll start default values -port=34400 -config=/root/.xteve/ \ No newline at end of file