From 5ce87689f763553ebdd97a330b0124e97591be22 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Mon, 18 Mar 2019 12:57:16 +0100 Subject: [PATCH] Horizon: Add terminal GUI, modify channel list; add settings --- epg.sh | 949 ++++++++++++++++++++++++++++++++++++++++++ hzn/ch_json2xml.pl | 2 +- hzn/chlist_printer.pl | 199 +++++++++ hzn/cid_json.pl | 2 +- hzn/compare_crid.pl | 112 +++++ hzn/compare_menu.pl | 81 ++++ hzn/epg_json2xml.pl | 212 ++++++---- hzn/hzn.sh | 105 ++--- hzn/settings.sh | 503 ++++++++++++++++++++++ 9 files changed, 2011 insertions(+), 154 deletions(-) create mode 100644 epg.sh create mode 100644 hzn/chlist_printer.pl create mode 100644 hzn/compare_crid.pl create mode 100644 hzn/compare_menu.pl create mode 100644 hzn/settings.sh diff --git a/epg.sh b/epg.sh new file mode 100644 index 0000000..7d74a96 --- /dev/null +++ b/epg.sh @@ -0,0 +1,949 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg/hzn +# +# Collaborators: +# - DeBaschdi ( https://github.com/DeBaschdi ) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with easyepg. If not, see . + +clear +echo " --------------------------------------------" +echo " EASYEPG SIMPLE XMLTV GRABBER " +echo " Release v0.1.1 BETA - 2019/03/18 " +echo " powered by " +echo " " +echo " ==THE=======================================" +echo " ##### ##### ##### # # ##### ##### ##### " +echo " # # # # # # # # # # " +echo " ##### ##### ##### ##### ##### ##### # ## " +echo " # # # # # # # # # " +echo " ##### # # ##### # ##### # ##### " +echo " ===================================PROJECT==" +echo " " +echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " +echo " --------------------------------------------" +echo "" + +# ################ +# INITIALIZATION # +# ################ + +# +# CHECK IF ALL MAIN SCRIPTS AND FOLDERS EXIST +# + +printf "Initializing script environment..." +sleep 0.5s + +if [ ! -e hzn/ch_json2xml.pl ] +then + printf "\nMissing file in Horzon folder: ch_json2xml.pl " + ERROR="true" +fi + +if [ ! -e hzn/cid_json.pl ] +then + printf "\nMissing file in Horzon folder: cid_json.pl " + ERROR="true" +fi + +if [ ! -e hzn/epg_json2xml.pl ] +then + printf "\nMissing file in Horzon folder: epg_json2xml.pl" + ERROR="true" +fi + +if [ ! -e hzn/settings.sh ] +then + printf "\nMissing file in Horzon folder: settings.sh " + ERROR="true" +fi + +if [ ! -e hzn/chlist_printer.pl ] +then + printf "\nMissing file in Horzon folder: chlist_printer.pl " + ERROR="true" +fi + +if [ ! -e hzn/compare_menu.pl ] +then + printf "\nMissing file in Horzon folder: compare_menu.pl " + ERROR="true" +fi + +if [ ! -e hzn/compare_crid.pl ] +then + printf "\nMissing file in Horzon folder: compare_crid.pl " + ERROR="true" +fi + +if [ ! -e hzn/hzn.sh ] +then + printf "\nMissing file in Horzon folder: hzn.sh " + ERROR="true" +fi + + +# +# CHECK IF ALL APPLICATIONS ARE INSTALLED +# + +command -v dialog >/dev/null 2>&1 || { printf "\ndialog is required but it's not installed!" >&2; ERROR2="true"; } +command -v curl >/dev/null 2>&1 || { printf "\ncurl is required but it's not installed!" >&2; ERROR2="true"; } +command -v wget >/dev/null 2>&1 || { printf "\nPhantomJS is required but it's not installed!" >&2; ERROR2="true"; } +command -v xmllint >/dev/null 2>&1 || { printf "\nlibxml2-utils is required but it's not installed!" >&2; ERROR2="true"; } +command -v perl >/dev/null 2>&1 || { printf "\nperl is required but it's not installed!" >&2; ERROR2="true"; } +command -v cpan >/dev/null 2>&1 || { printf "\ncpan is required but it's not installed!" >&2; ERROR2="true"; } +command -v jq >/dev/null 2>&1 || { printf "\nperl is required but it's not installed!" >&2; ERROR2="true"; } + +if command -v perldoc >/dev/null +then + perldoc -l JSON >/dev/null 2>&1 || { printf "\nJSON module for perl is requried but not installed!" >&2; ERROR2="true"; } + perldoc -l Data::Dumper >/dev/null 2>&1 || { printf "\nData::Dumper module for perl is requried but not installed!" >&2; ERROR2="true"; } + perldoc -l Time::Piece >/dev/null 2>&1 || { printf "\nTime::Piece module for perl is requried but not installed!" >&2; ERROR2="true"; } + perldoc -l utf8 >/dev/null 2>&1 || { printf "\nuft8 module for perl is requried but not installed!" >&2; ERROR2="true"; } +else + printf "\nperl-doc is required but it's not installed!" + ERROR2="true" +fi + +if [ ! -z "$ERROR2" ] +then + printf "\n\n[ FATAL ERROR ] Required applications are missing - Stop.\n" + exit 1 +fi + + +# +# CHECK INTERNET CONNECTIVITY +# + +if ! ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null 2> /dev/null +then + printf "\n\n[ FATAL ERROR ] Internet connection is not available - Stop.\n" + exit 1 +fi + + +# +# FINAL MESSAGE +# + +if [ ! -z "$ERROR" ] +then + printf "\n\n[ FATAL ERROR ] Script environment is broken - Stop.\n" + exit 1 +else + printf " OK!\n\n" + sleep 1s +fi + + +# ############### +# M1W00 CRONJOB # +# ############### + +if ls -l hzn/ | grep -q '^d' +then + dialog --backtitle "[M1W00] EASYEPG SIMPLE XMLTV GRABBER" --title "MAIN MENU" --infobox "Please press any button to enter the main menu.\n\nThe script will proceed in 5 seconds." 7 50 + + if read -t 5 -n1 + then + echo "M" > /tmp/value + fi +else + echo "M" > /tmp/value +fi + + +# ################# +# M1000 MAIN MENU # +# ################# + +while grep -q "M" /tmp/value +do + # M1000 MENU OVERLAY + echo 'dialog --backtitle "[M1000] EASYEPG SIMPLE XMLTV GRABBER" --title "MAIN MENU" --menu "Welcome to EasyEPG! :)\n(c) 2019 Jan-Luca Neumann\n\nIf you like this script, please support my work:\nhttps://paypal.me/sunsettrack4\n\nPlease choose an option:" 17 55 10 \' > /tmp/menu + + # M1100 ADD GRABBER + echo ' 1 "ADD GRABBER INSTANCE" \' >> /tmp/menu + + # M1200 GRABBER SETTINGS + if ls -l hzn/ | grep -q '^d' + then + echo ' 2 "OPEN GRABBER SETTINGS" \' >> /tmp/menu + fi + + # M1300 CREATE MULTI-SOURCE XML FILE + # WIP + + # M1400 CONTINUE IN GRABBER MODE + if ls -l hzn/ | grep -q '^d' + then + echo ' 4 "CONTINUE IN GRABBER MODE" \' >> /tmp/menu + fi + + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + + + # ################### + # M1100 ADD GRABBER # + # ################### + + if grep -q "1" /tmp/value + then + # M1100 MENU OVERLAY + echo 'dialog --backtitle "[M1100] EASYEPG SIMPLE XMLTV GRABBER > ADD GRABBER" --title "PROVIDERS" --menu "Please select a provider you want to use as EPG source:" 9 40 10 \' > /tmp/menu + + # M1110 HORIZON + echo ' 1 "HORIZON" \' >> /tmp/menu + + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + + + # ############### + # M1110 HORIZON # + # ############### + + if grep -q "1" /tmp/value + then + # M1110 MENU OVERLAY + echo 'dialog --backtitle "[M1110] EASYEPG SIMPLE XMLTV GRABBER > ADD GRABBER > HORIZON" --title "COUNTRY" --menu "Please select the service you want to grab:" 11 50 10 \' > /tmp/menu + + # M1111 GERMANY + if [ ! -d hzn/de ] + then + echo ' 1 "[DE] Unitymedia Germany" \' >> /tmp/menu + fi + + # M1112 AUSTRIA + if [ ! -d hzn/at ] + then + echo ' 2 "[AT] UPC Austria" \' >> /tmp/menu + fi + + # M1113 SWITZERLAND + if [ ! -d hzn/ch ] + then + echo ' 3 "[CH] UPC Switzerland" \' >> /tmp/menu + fi + + # M1114 NETHERLANDS + if [ ! -d hzn/nl ] + then + echo ' 4 "[NL] Ziggo Netherlands" \' >> /tmp/menu + fi + + # M1115 POLAND + if [ ! -d hzn/pl ] + then + echo ' 5 "[PL] Horizon Poland" \' >> /tmp/menu + fi + + # M1116 IRELAND + if [ ! -d hzn/ie ] + then + echo ' 6 "[IE] Virgin Media Ireland" \' >> /tmp/menu + fi + + # M1117 SLOVAKIA + if [ ! -d hzn/sk ] + then + echo ' 7 "[SK] Horizon Slovakia" \' >> /tmp/menu + fi + + # M1118 CZECH REPUBLIC + if [ ! -d hzn/cz ] + then + echo ' 8 "[CZ] Horizon Czech Republic" \' >> /tmp/menu + fi + + # M1119 HUNGARY + if [ ! -d hzn/hu ] + then + echo ' 9 "[HU] Horizon Hungary" \' >> /tmp/menu + fi + + # M111R ROMANIA + if [ ! -d hzn/ro ] + then + echo ' 0 "[RO] Horizon Romania" \' >> /tmp/menu + fi + + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + + + # ################## + # M1111 HORIZON DE # + # ################## + + if grep -q "1" /tmp/value + then + mkdir hzn/de + chmod 0777 hzn/de + echo '{"country":"DE","language":"de"}' > hzn/de/init.json + cp hzn/hzn.sh hzn/de/ + cp hzn/ch_json2xml.pl hzn/de/ + cp hzn/cid_json.pl hzn/de/ + cp hzn/epg_json2xml.pl hzn/de/ + cp hzn/settings.sh hzn/de/ + cp hzn/chlist_printer.pl hzn/de/ + cp hzn/compare_menu.pl hzn/de/ + cp hzn/compare_crid.pl hzn/de/ + cd hzn/de && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/de/channels.json ] + then + rm -rf hzn/de + fi + + echo "M" > /tmp/value + + + # ################## + # M1112 HORIZON AT # + # ################## + + elif grep -q "2" /tmp/value + then + mkdir hzn/at + chmod 0777 hzn/at + echo '{"country":"AT","language":"de"}' > hzn/at/init.json + cp hzn/hzn.sh hzn/at/ + cp hzn/ch_json2xml.pl hzn/at/ + cp hzn/cid_json.pl hzn/at/ + cp hzn/epg_json2xml.pl hzn/at/ + cp hzn/settings.sh hzn/at/ + cp hzn/chlist_printer.pl hzn/at/ + cp hzn/compare_menu.pl hzn/at/ + cp hzn/compare_crid.pl hzn/at/ + cd hzn/at && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/at/channels.json ] + then + rm -rf hzn/at + fi + + echo "M" > /tmp/value + + + # ################## + # M1113 HORIZON CH # + # ################## + + elif grep -q "3" /tmp/value + then + mkdir hzn/ch + chmod 0777 hzn/ch + echo '{"country":"CH","language":"de"}' > hzn/ch/init.json + cp hzn/hzn.sh hzn/ch/ + cp hzn/ch_json2xml.pl hzn/ch/ + cp hzn/cid_json.pl hzn/ch/ + cp hzn/epg_json2xml.pl hzn/ch/ + cp hzn/settings.sh hzn/ch/ + cp hzn/chlist_printer.pl hzn/ch/ + cp hzn/compare_menu.pl hzn/ch/ + cp hzn/compare_crid.pl hzn/ch/ + cd hzn/ch && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ch/channels.json ] + then + rm -rf hzn/ch + fi + + echo "M" > /tmp/value + + + # ################## + # M1114 HORIZON NL # + # ################## + + elif grep -q "4" /tmp/value + then + mkdir hzn/nl + chmod 0777 hzn/nl + echo '{"country":"NL","language":"nl"}' > hzn/nl/init.json + cp hzn/hzn.sh hzn/nl/ + cp hzn/ch_json2xml.pl hzn/nl/ + cp hzn/cid_json.pl hzn/nl/ + cp hzn/epg_json2xml.pl hzn/nl/ + cp hzn/settings.sh hzn/nl/ + cp hzn/chlist_printer.pl hzn/nl/ + cp hzn/compare_menu.pl hzn/nl/ + cp hzn/compare_crid.pl hzn/nl/ + cd hzn/nl && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/nl/channels.json ] + then + rm -rf hzn/nl + fi + + echo "M" > /tmp/value + + + # ################## + # M1115 HORIZON PL # + # ################## + + elif grep -q "5" /tmp/value + then + mkdir hzn/pl + chmod 0777 hzn/pl + echo '{"country":"PL","language":"pl"}' > hzn/pl/init.json + cp hzn/hzn.sh hzn/pl/ + cp hzn/ch_json2xml.pl hzn/pl/ + cp hzn/cid_json.pl hzn/pl/ + cp hzn/epg_json2xml.pl hzn/pl/ + cp hzn/settings.sh hzn/pl/ + cp hzn/chlist_printer.pl hzn/pl/ + cp hzn/compare_menu.pl hzn/pl/ + cp hzn/compare_crid.pl hzn/pl/ + cd hzn/pl && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/pl/channels.json ] + then + rm -rf hzn/pl + fi + + echo "M" > /tmp/value + + + # ################## + # M1116 HORIZON IE # + # ################## + + elif grep -q "6" /tmp/value + then + mkdir hzn/ie + chmod 0777 hzn/ie + echo '{"country":"IE","language":"en"}' > hzn/ie/init.json + cp hzn/hzn.sh hzn/ie/ + cp hzn/ch_json2xml.pl hzn/ie/ + cp hzn/cid_json.pl hzn/ie/ + cp hzn/epg_json2xml.pl hzn/ie/ + cp hzn/settings.sh hzn/ie/ + cp hzn/chlist_printer.pl hzn/ie/ + cp hzn/compare_menu.pl hzn/ie/ + cp hzn/compare_crid.pl hzn/ie/ + cd hzn/ie && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ie/channels.json ] + then + rm -rf hzn/ie + fi + + echo "M" > /tmp/value + + + # ################## + # M1117 HORIZON SK # + # ################## + + elif grep -q "7" /tmp/value + then + mkdir hzn/sk + chmod 0777 hzn/sk + echo '{"country":"SK","language":"sk"}' > hzn/sk/init.json + cp hzn/hzn.sh hzn/sk/ + cp hzn/ch_json2xml.pl hzn/sk/ + cp hzn/cid_json.pl hzn/sk/ + cp hzn/epg_json2xml.pl hzn/sk/ + cp hzn/settings.sh hzn/sk/ + cp hzn/chlist_printer.pl hzn/sk/ + cp hzn/compare_menu.pl hzn/sk/ + cp hzn/compare_crid.pl hzn/sk/ + cd hzn/sk && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/sk/channels.json ] + then + rm -rf hzn/sk + fi + + echo "M" > /tmp/value + + + # ################## + # M1118 HORIZON CZ # + # ################## + + elif grep -q "8" /tmp/value + then + mkdir hzn/cz + chmod 0777 hzn/cz + echo '{"country":"CZ","language":"cs"}' > hzn/cz/init.json + cp hzn/hzn.sh hzn/cz/ + cp hzn/ch_json2xml.pl hzn/cz/ + cp hzn/cid_json.pl hzn/cz/ + cp hzn/epg_json2xml.pl hzn/cz/ + cp hzn/settings.sh hzn/cz/ + cp hzn/chlist_printer.pl hzn/cz/ + cp hzn/compare_menu.pl hzn/cz/ + cp hzn/compare_crid.pl hzn/cz/ + cd hzn/cz && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/cz/channels.json ] + then + rm -rf hzn/cz + fi + + echo "M" > /tmp/value + + + # ################## + # M1119 HORIZON HU # + # ################## + + elif grep -q "9" /tmp/value + then + mkdir hzn/hu + chmod 0777 hzn/hu + echo '{"country":"HU","language":"hu"}' > hzn/hu/init.json + cp hzn/hzn.sh hzn/hu/ + cp hzn/ch_json2xml.pl hzn/hu/ + cp hzn/cid_json.pl hzn/hu/ + cp hzn/epg_json2xml.pl hzn/hu/ + cp hzn/settings.sh hzn/hu/ + cp hzn/chlist_printer.pl hzn/hu/ + cp hzn/compare_menu.pl hzn/hu/ + cp hzn/compare_crid.pl hzn/hu/ + cd hzn/hu && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/hu/channels.json ] + then + rm -rf hzn/hu + fi + + echo "M" > /tmp/value + + + # ################## + # M111R HORIZON RO # + # ################## + + elif grep -q "0" /tmp/value + then + mkdir hzn/ro + chmod 0777 hzn/ro + echo '{"country":"RO","language":"ro"}' > hzn/ro/init.json + cp hzn/hzn.sh hzn/ro/ + cp hzn/ch_json2xml.pl hzn/ro/ + cp hzn/cid_json.pl hzn/ro/ + cp hzn/epg_json2xml.pl hzn/ro/ + cp hzn/settings.sh hzn/ro/ + cp hzn/chlist_printer.pl hzn/ro/ + cp hzn/compare_menu.pl hzn/ro/ + cp hzn/compare_crid.pl hzn/ro/ + cd hzn/ro && bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ro/channels.json ] + then + rm -rf hzn/ro + fi + + echo "M" > /tmp/value + + + # ############ + # M111X EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + + + # ############ + # M1X00 EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + + + # ############################# + # M1200 OPEN GRABBER SETTINGS # + # ############################# + + elif grep -q "2" /tmp/value + then + # M1200 MENU OVERLAY + echo 'dialog --backtitle "[M1200] EASYEPG SIMPLE XMLTV GRABBER > SETTINGS" --title "PROVIDERS" --menu "Please select a provider you want to change:" 9 40 10 \' > /tmp/menu + + # M1210 HORIZON + echo ' 1 "HORIZON" \' >> /tmp/menu + + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + + + # ############### + # M1210 HORIZON # + # ############### + + if grep -q "1" /tmp/value + then + # M1210 MENU OVERLAY + echo 'dialog --backtitle "[M1210] EASYEPG SIMPLE XMLTV GRABBER > SETTINGS > HORIZON" --title "COUNTRY" --menu "Please select the service you want to change:" 11 50 10 \' > /tmp/menu + + # M1211 GERMANY + if [ -d hzn/de ] + then + echo ' 1 "[DE] Unitymedia Germany" \' >> /tmp/menu + fi + + # M1212 AUSTRIA + if [ -d hzn/at ] + then + echo ' 2 "[AT] UPC Austria" \' >> /tmp/menu + fi + + # M1213 SWITZERLAND + if [ -d hzn/ch ] + then + echo ' 3 "[CH] UPC Switzerland" \' >> /tmp/menu + fi + + # M1214 NETHERLANDS + if [ -d hzn/nl ] + then + echo ' 4 "[NL] Ziggo Netherlands" \' >> /tmp/menu + fi + + # M1215 POLAND + if [ -d hzn/pl ] + then + echo ' 5 "[PL] Horizon Poland" \' >> /tmp/menu + fi + + # M1216 IRELAND + if [ -d hzn/ie ] + then + echo ' 6 "[IE] Virgin Media Ireland" \' >> /tmp/menu + fi + + # M1217 SLOVAKIA + if [ -d hzn/sk ] + then + echo ' 7 "[SK] Horizon Slovakia" \' >> /tmp/menu + fi + + # M1218 CZECH REPUBLIC + if [ -d hzn/cz ] + then + echo ' 8 "[CZ] Horizon Czech Republic" \' >> /tmp/menu + fi + + # M1219 HUNGARY + if [ -d hzn/hu ] + then + echo ' 9 "[HU] Horizon Hungary" \' >> /tmp/menu + fi + + # M121R ROMANIA + if [ -d hzn/ro ] + then + echo ' 0 "[RO] Horizon Romania" \' >> /tmp/menu + fi + + # M121E ERROR + if ! grep -q '[0-9] "\[[A-Z][A-Z]\] ' /tmp/menu + then + dialog --backtitle "[M121E] EASYEPG SIMPLE XMLTV GRABBER > SETTINGS > HORIZON" --title "ERROR" --infobox "No service available! Please setup a service first!" 3 55 + sleep 2s + echo "M" > /tmp/value + else + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + fi + + + # ################## + # M1211 HORIZON DE # + # ################## + + if grep -q "1" /tmp/value + then + cd hzn/de + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/de/channels.json ] + then + rm -rf hzn/de + fi + + echo "M" > /tmp/value + + + # ################## + # M1212 HORIZON AT # + # ################## + + elif grep -q "2" /tmp/value + then + cd hzn/at + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/at/channels.json ] + then + rm -rf hzn/at + fi + + echo "M" > /tmp/value + + + # ################## + # M1213 HORIZON CH # + # ################## + + elif grep -q "3" /tmp/value + then + cd hzn/ch + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ch/channels.json ] + then + rm -rf hzn/ch + fi + + echo "M" > /tmp/value + + + # ################## + # M1214 HORIZON NL # + # ################## + + elif grep -q "4" /tmp/value + then + cd hzn/nl + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/nl/channels.json ] + then + rm -rf hzn/nl + fi + + echo "M" > /tmp/value + + + # ################## + # M1215 HORIZON PL # + # ################## + + elif grep -q "5" /tmp/value + then + cd hzn/pl + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/pl/channels.json ] + then + rm -rf hzn/pl + fi + + echo "M" > /tmp/value + + + # ################## + # M1216 HORIZON IE # + # ################## + + elif grep -q "6" /tmp/value + then + cd hzn/ie + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ie/channels.json ] + then + rm -rf hzn/ie + fi + + echo "M" > /tmp/value + + + # ################## + # M1217 HORIZON SK # + # ################## + + elif grep -q "7" /tmp/value + then + cd hzn/sk + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/sk/channels.json ] + then + rm -rf hzn/sk + fi + + echo "M" > /tmp/value + + + # ################## + # M1218 HORIZON CZ # + # ################## + + elif grep -q "8" /tmp/value + then + cd hzn/cz + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/cz/channels.json ] + then + rm -rf hzn/cz + fi + + echo "M" > /tmp/value + + + # ################## + # M1219 HORIZON HU # + # ################## + + elif grep -q "9" /tmp/value + then + cd hzn/hu + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/hu/channels.json ] + then + rm -rf hzn/hu + fi + + echo "M" > /tmp/value + + + # ################## + # M121R HORIZON RO # + # ################## + + elif grep -q "0" /tmp/value + then + cd hzn/ro + bash settings.sh + cd - > /dev/null + + if [ ! -e hzn/ro/channels.json ] + then + rm -rf hzn/ro + fi + + echo "M" > /tmp/value + + # ############ + # M121X EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + + + # ############ + # M12X0 EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + + + # ################################ + # M1400 CONTINUE IN GRABBER MODE # + # ################################ + + elif grep -q "4" /tmp/value + then + clear + + # + # HORIZON + # + + if ls -l hzn/ | grep -q '^d' + then + echo "" + echo " --------------------------------------------" + echo " HORIZON EPG SIMPLE XMLTV GRABBER " + echo " " + echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " + echo " --------------------------------------------" + echo "" + + cd hzn/de 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/at 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/ch 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/nl 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/pl 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/ie 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/sk 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/cz 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/hu 2> /dev/null && bash hzn.sh && cd - > /dev/null + cd hzn/ro 2> /dev/null && bash hzn.sh && cd - > /dev/null + fi + + + # ############ + # M1X00 EXIT # + # ############ + + else + dialog --backtitle "[M1X00] EASYEPG SIMPLE XMLTV GRABBER > EXIT" --title "EXIT" --yesno "Do you want to quit?" 5 30 + + response=$? + + if [ $response = 1 ] + then + echo "M" > /tmp/value + elif [ $response = 0 ] + then + clear + exit 0 + else + echo "M" > /tmp/value + fi + fi +done diff --git a/hzn/ch_json2xml.pl b/hzn/ch_json2xml.pl index f6d4104..32f7ed6 100644 --- a/hzn/ch_json2xml.pl +++ b/hzn/ch_json2xml.pl @@ -100,7 +100,7 @@ print "{$cname} . "\">\n"; } else { print "\n"; - print STDERR "CHLIST WARNING: Channel ID unknown: " . $cname . "\n"; + print STDERR "[ CHLIST WARNING ] Channel ID unknown: " . $cname . "\n"; } # CHANNEL NAME (language) diff --git a/hzn/chlist_printer.pl b/hzn/chlist_printer.pl new file mode 100644 index 0000000..c8c3526 --- /dev/null +++ b/hzn/chlist_printer.pl @@ -0,0 +1,199 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg/hzn +# +# Collaborators: +# - DeBaschdi ( https://github.com/DeBaschdi ) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with easyepg. If not, see . + +# ############################## +# HORIZON CHANNEL LIST CREATOR # +# ############################## + +# CREATE JSON FILE FOR COMPARISM + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: NEW CHLIST +my $chlist_new; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/chlist" or die; + $chlist_new = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: OLD CHLIST +my $chlist_old; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "chlist_old" or die; + $chlist_old = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: CHANNEL CONFIG +my $chlist_config; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "channels.json" or die; + $chlist_config = <$fh>; + close $fh; +} + +# CONVERT JSON TO PERL STRUCTURES +my $newdata = decode_json($chlist_new); +my $olddata = decode_json($chlist_old); +my $configdata = decode_json($chlist_config); + + +# ################## +# NEW CHANNEL LIST # +# ################## + +# TOOL: NAME ==> ID + +print "{ \"newname2id\": {\n"; + +my @newchannels_name2id = @{ $newdata->{'channels'} }; +foreach my $newchannels ( @newchannels_name2id ) { + my @newschedule = @{ $newchannels->{'stationSchedules'} }; + + foreach my $newschedule ( @newschedule ) { + my $newitem = $newschedule->{'station'}; + + # + # DEFINE JSON VALUES + # + + # DEFINE NEW CHANNEL NAME + my $newcname = $newitem->{'title'}; + $newcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE NEW CHANNEL ID + my $newcid = $newitem->{'id'}; + + # PRINT NEW CHANNEL NAMES + print "\"$newcname\": \"$newcid\",\n"; + } +} + +# TOOL: ID ==> NAME + +print "\"DUMMY\": \"DUMMY\" },\n\"newid2name\": {\n"; + +my @newchannels_id2name = @{ $newdata->{'channels'} }; +foreach my $newchannels ( @newchannels_id2name ) { + my @newschedule = @{ $newchannels->{'stationSchedules'} }; + + foreach my $newschedule ( @newschedule ) { + my $newitem = $newschedule->{'station'}; + + # + # DEFINE JSON VALUES + # + + # DEFINE NEW CHANNEL NAME + my $newcname = $newitem->{'title'}; + $newcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE NEW CHANNEL ID + my $newcid = $newitem->{'id'}; + + # PRINT NEW CHANNEL NAMES newcid + print "\"$newcid\": \"$newcname\",\n"; + } +} + + +# ################## +# OLD CHANNEL LIST # +# ################## + +# TOOL: NAME ==> ID + +print "\"DUMMY\": \"DUMMY\" },\n\"oldname2id\": {\n"; + +my @oldchannels_name2id = @{ $olddata->{'channels'} }; +foreach my $oldchannels ( @oldchannels_name2id ) { + my @oldschedule = @{ $oldchannels->{'stationSchedules'} }; + + foreach my $oldschedule ( @oldschedule ) { + my $olditem = $oldschedule->{'station'}; + + # + # DEFINE JSON VALUES + # + + # DEFINE OLD CHANNEL NAME + my $oldcname = $olditem->{'title'}; + $oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE OLD CHANNEL ID + my $oldcid = $olditem->{'id'}; + + # PRINT OLD CHANNEL NAMES + print "\"$oldcname\": \"$oldcid\",\n"; + } +} + +# TOOL: ID ==> NAME + +print "\"DUMMY\": \"DUMMY\" },\n\"oldid2name\": {\n"; + +my @oldchannels_id2name = @{ $olddata->{'channels'} }; +foreach my $oldchannels ( @oldchannels_id2name ) { + my @oldschedule = @{ $oldchannels->{'stationSchedules'} }; + + foreach my $oldschedule ( @oldschedule ) { + my $olditem = $oldschedule->{'station'}; + + # + # DEFINE JSON VALUES + # + + # DEFINE OLD CHANNEL NAME + my $oldcname = $olditem->{'title'}; + $oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE OLD CHANNEL ID + my $oldcid = $olditem->{'id'}; + + # PRINT OLD CHANNEL NAMES + print "\"$oldcid\": \"$oldcname\",\n"; + } +} + + +# ####################### +# CHANNEL CONFIGURATION # +# ####################### + +print "\"DUMMY\": \"DUMMY\" },\n\"config\": [\n"; + +my @configdata = @{ $configdata->{'channels'} }; + +foreach my $configname ( @configdata ) { + print "\"$configname\",\n"; +} + +print "\"DUMMY\"]\n}"; diff --git a/hzn/cid_json.pl b/hzn/cid_json.pl index 6ee1d52..0b29c0f 100644 --- a/hzn/cid_json.pl +++ b/hzn/cid_json.pl @@ -37,7 +37,7 @@ my $json; { local $/; #Enable 'slurp' mode - open my $fh, "<", "chlist" or die; + open my $fh, "<", "/tmp/chlist" or die; $json = <$fh>; close $fh; } diff --git a/hzn/compare_crid.pl b/hzn/compare_crid.pl new file mode 100644 index 0000000..864761a --- /dev/null +++ b/hzn/compare_crid.pl @@ -0,0 +1,112 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg/hzn +# +# Collaborators: +# - DeBaschdi ( https://github.com/DeBaschdi ) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with easyepg. If not, see . + +# ############################## +# HORIZON CHANNEL LIST CREATOR # +# ############################## + +# COMPARE STRINGS, CREATE CRID LIST + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: COMPARISM LIST +my $compare; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/compare.json" or die; + $compare = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: PROGRAMME LIST +my $programme; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "day/dayNUMBER" or die; + $programme = <$fh>; + close $fh; +} + +# CONVERT JSON TO PERL STRUCTURES +my $comparedata = decode_json($compare); +my $programmedata = decode_json($programme); + +# +# DEFINE JSON VALUES +# + +# DEFINE COMPARE DATA +my $new_name2id = $comparedata->{'newname2id'}; +my $new_id2name = $comparedata->{'newid2name'}; +my $old_name2id = $comparedata->{'oldname2id'}; +my $old_id2name = $comparedata->{'oldid2name'}; +my @configname = @{ $comparedata->{'config'} }; + +# DEFINE PROGRAMME STRINGS +my @entries = @{ $programmedata->{'entries'} }; + +my $crid = "i"; +my $crid_location; + +# +# COMPARE VALUES + CREATE CRID LIST +# + +foreach my $entries ( @entries ) { + my @lid = @{ $entries->{'l'} }; + my $oid = $entries->{'o'}; + + foreach my $lid ( @lid ) { + my $crid = $lid->{'i'}; + + foreach my $configname ( @configname ) { + + my $old_id = $old_name2id->{$configname}; + + # FIND MATCH VIA NEW CHANNEL NAME + CONFIG NAME + if( defined $new_name2id->{$configname} ) { + my $matched_id = $new_name2id->{$configname}; + + if( $oid eq $matched_id ) { + print $crid . "\n"; + } + + # IF MATCH NOT FOUND FOR NEW CHANNEL NAME: FIND MATCH VIA OLD CHANNEL NAME + CONFIG NAME + } elsif( defined $old_id ) { + if( defined $new_id2name->{$old_id} ) { + print STDERR "[ INFO ] CHANNEL \"$configname\" received new Channel Name!\n"; + + if ( $oid eq $old_id ) { + print $crid . "\n"; + } + } + } else { + print STDERR "[ INFO ] CHANNEL $configname not found in channel lists!\n"; + } + } + } +} diff --git a/hzn/compare_menu.pl b/hzn/compare_menu.pl new file mode 100644 index 0000000..45659a8 --- /dev/null +++ b/hzn/compare_menu.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg/hzn +# +# Collaborators: +# - DeBaschdi ( https://github.com/DeBaschdi ) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with easyepg. If not, see . + +# ############################## +# HORIZON CHANNEL LIST CREATOR # +# ############################## + +# COMPARE STRINGS, CREATE MENU LIST + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: COMPARISM LIST +my $json; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/compare.json" or die; + $json = <$fh>; + close $fh; +} + +# CONVERT JSON TO PERL STRUCTURES +my $data = decode_json($json); + + +# +# DEFINE JSON VALUES +# + +my $new_name2id = $data->{'newname2id'}; +my $new_id2name = $data->{'newid2name'}; +my $old_name2id = $data->{'oldname2id'}; +my $old_id2name = $data->{'oldid2name'}; +my @configname = @{ $data->{'config'} }; + + +# +# COMPARE VALUES + CREATE MENU LIST +# + +foreach my $configname ( @configname ) { + + my $old_id = $old_name2id->{$configname}; + + # FIND MATCH - NEW CHANNEL NAME + CONFIG NAME + if( defined $new_name2id->{$configname} ) { + print "$configname\n"; + + # IF MATCH NOT FOUND: FIND MATCH - OLD CHANNEL NAME + CONFIG NAME + } elsif( defined $old_id ) { + if( defined $new_id2name->{$old_id} ) { + print $new_id2name->{$old_id} . "\n"; + print STDERR "[ INFO ] CHANNEL \"$configname\" received new Channel Name!\n"; + } + } else { + print STDERR "[ INFO ] CHANNEL $configname not found in channel lists!\n"; + } +} diff --git a/hzn/epg_json2xml.pl b/hzn/epg_json2xml.pl index 9407d0b..a01d17a 100644 --- a/hzn/epg_json2xml.pl +++ b/hzn/epg_json2xml.pl @@ -79,6 +79,15 @@ $init = <$fh>; close $fh; } + +# READ SETTINGS FILE +my $settings; +{ + local $/; #Enable 'slurp' mode + open my $fh, '<', "settings.json" or die; + $settings = <$fh>; + close $fh; +} # CONVERT JSON TO PERL STRUCTURES my $data = decode_json($json); @@ -86,6 +95,7 @@ my $chiddata = decode_json($chidlist); my $genredata = decode_json($genrelist); my $initdata = decode_json($init); +my $setupdata = decode_json($settings); print "\n\n\n"; @@ -145,18 +155,35 @@ # DEFINE EIT GENRES (language) my $eit = $genredata->{'categories'}{$countryVER}; + + # DEFINE SETTINGS + my $setup_general = $setupdata->{'settings'}; + my $setup_cid = $setup_general->{'cid'}; + my $setup_genre = $setup_general->{'genre'}; + my $setup_category = $setup_general->{'category'}; + my $setup_episode = $setup_general->{'episode'}; + + # DEFINE SETTINGS VALUES + my $enabled = "enabled"; + my $disabled = "disabled"; + my $xmltv_ns = "xmltv_ns"; + my $onscreen = "onscreen"; # ################## # PRINT XML OUTPUT # # ################## - # BEGIN OF PROGRAMME: START / STOP / CHANNEL (condition) + # BEGIN OF PROGRAMME: START / STOP / CHANNEL (condition) (settings) if( defined $cidEXT->{$cid} ) { - if( defined $rytec->{$cidEXT->{$cid}} ) { - print "{$cidEXT->{$cid}} . "\">\n"; + if( $setup_cid eq $enabled ) { + if( defined $rytec->{$cidEXT->{$cid}} ) { + print "{$cidEXT->{$cid}} . "\">\n"; + } else { + print "{$cid} . "\">\n"; + print STDERR "[ EPG WARNING ] Rytec ID not matched for: " . $cidEXT->{$cid} . "\n"; + } } else { print "{$cid} . "\">\n"; - print STDERR "[ EPG WARNING ] Rytec ID not matched for: " . $cidEXT->{$cid} . "\n"; } } else { print "\n"; @@ -237,92 +264,121 @@ print " $date\n"; } - # CATEGORIES (USE MOST DETAILLED CATEGORY) (condition) (language) - # if ( defined $genre2 ) { - # if ( defined $eit->{ $genre2 } ) { - # print " " . $eit->{ $genre2 } . "\n"; - # } else { - # print " $genre2\n"; - # print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . $genre2 . "\n";; - # } elsif ( defined $genre1 ) { - # if ( defined $eit->{ $genre1 } ) { - # print " " . $eit->{ $genre1 } . "\n"; - # } else { - # print " $genre1\n"; - # print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . $genre1 . "\n";; - # } - # } - - # CATEGORIES (PRINT ALL CATEGORIES) (condition) (language) - if ( defined $genre1 ) { - if ( defined $eit->{ $genre1 } ) { - print " " . $eit->{ $genre1 } . "\n"; - } else { - print " $genre1\n"; - print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . $genre1 . "\n";; + # CATEGORIES (USE MOST DETAILLED CATEGORY) (condition) (language) (settings) + if( $setup_category eq $disabled ) { + if ( defined $genre2 ) { + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre2 } ) { + print " " . $eit->{ $genre2 } . "\n"; + } else { + print " $genre2\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre2" . "\n";; + } + } else { + print " $genre2\n"; + } + } elsif ( defined $genre1 ) { + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre1 } ) { + print " " . $eit->{ $genre1 } . "\n"; + } else { + print " $genre1\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre1" . "\n";; + } + } else { + print " $genre1\n"; + } } } - if ( defined $genre2 ) { - if ( defined $eit->{ $genre2 } ) { - print " " . $eit->{ $genre2 } . "\n"; - } else { - print " $genre2\n"; - print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . $genre2 . "\n";; + + # CATEGORIES (PRINT ALL CATEGORIES) (condition) (language) (settings) + if( $setup_category eq $enabled ) { + if ( defined $genre1 ) { + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre1 } ) { + print " " . $eit->{ $genre1 } . "\n"; + } else { + print " $genre1\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre1" . "\n";; + } + } else { + print " $genre1\n"; + } } - } - if ( defined $genre3 ) { - if ( defined $eit->{ $genre3 } ) { - print " " . $eit->{ $genre3 } . "\n"; - } else { - print " $genre3\n"; - print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . $genre3 . "\n";; + if ( defined $genre2 ) { + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre2 } ) { + print " " . $eit->{ $genre2 } . "\n"; + } else { + print " $genre2\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre2" . "\n";; + } + } else { + print " $genre2\n"; + } } - } - - # SEASON/EPISODE (XMLTV_NS) (condition) - if( defined $series ) { - if( $series =~ m/\d{4}/) { - undef $series; # REMOVE USELESS SERIES STRINGS + if ( defined $genre3 ) { + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre3 } ) { + print " " . $eit->{ $genre3 } . "\n"; + } else { + print " $genre3\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre3" . "\n";; + } + } else { + print " $genre3\n"; + } } } - if( defined $episode ) { - if( $episode =~ m/\d{7}/) { - undef $episode; # REMOVE USELESS EPISODE STRINGS + + # SEASON/EPISODE (XMLTV_NS) (condition) (settings) + if( $setup_episode eq $xmltv_ns ) { + if( defined $series ) { + if( $series =~ m/\d{4}/) { + undef $series; # REMOVE USELESS SERIES STRINGS + } } - } - if( defined $series ) { - my $XMLseries = $series - 1; if( defined $episode ) { + if( $episode =~ m/\d{7}/) { + undef $episode; # REMOVE USELESS EPISODE STRINGS + } + } + if( defined $series ) { + my $XMLseries = $series - 1; + if( defined $episode ) { + my $XMLepisode = $episode - 1; + print " $XMLseries . $XMLepisode . \n"; + } else { + print " $XMLseries . 0 . \n"; + } + } elsif( defined $episode ) { my $XMLepisode = $episode - 1; - print " $XMLseries . $XMLepisode . \n"; - } else { - print " $XMLseries . 0 . \n"; + print " 0 . $XMLepisode . \n"; } - } elsif( defined $episode ) { - my $XMLepisode = $episode - 1; - print " 0 . $XMLepisode . \n"; } - # SEASON/EPISODE (ONSCREEN) (condition) - # if( defined $series ) { - # if( $series =~ m/\d{4}/) { - # undef $series; # REMOVE USELESS SERIES STRINGS - # } - # } - # if( defined $episode ) { - # if( $episode =~ m/\d{7}/) { - # undef $episode; # REMOVE USELESS EPISODE STRINGS - # } - # } - # if( defined $series ) { - # if( defined $episode ) { - # print " S$series E$episode\n"; - # } else { - # print " S$series\n"; - # } - # } elsif( defined $episode ) { - # print " E$episode\n"; - # } + # SEASON/EPISODE (ONSCREEN) (condition) (settings) + if( $setup_episode eq $onscreen ) { + if( defined $series ) { + if( $series =~ m/\d{4}/) { + undef $series; # REMOVE USELESS SERIES STRINGS + } + } + if( defined $episode ) { + if( $episode =~ m/\d{7}/) { + undef $episode; # REMOVE USELESS EPISODE STRINGS + } + } + if( defined $series ) { + if( defined $episode ) { + print " S$series E$episode\n"; + } else { + print " S$series\n"; + } + } elsif( defined $episode ) { + print " E$episode\n"; + } + } # AGE RATING (condition) if( defined $age) { diff --git a/hzn/hzn.sh b/hzn/hzn.sh index 6ec081c..3458a4d 100644 --- a/hzn/hzn.sh +++ b/hzn/hzn.sh @@ -19,19 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -clear +echo "" echo " --------------------------------------------" echo " HORIZON EPG SIMPLE XMLTV GRABBER " -echo " Release v0.1.0 BETA - 2019/03/10 " -echo " powered by " -echo " " -echo " ==THE=======================================" -echo " ##### ##### ##### # # ##### ##### ##### " -echo " # # # # # # # # # # " -echo " ##### ##### ##### ##### ##### ##### # ## " -echo " # # # # # # # # # " -echo " ##### # # ##### # ##### # ##### " -echo " ===================================PROJECT==" echo " " echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " echo " --------------------------------------------" @@ -46,49 +36,8 @@ sleep 2s # SETUP ENVIRONMENT # -mkdir ~/hzn 2> /dev/null # main folder -mkdir ~/hzn/cache 2> /dev/null # cache -mkdir ~/hzn/day 2> /dev/null # download scripts - -cd ~/hzn - -# -# SET VARIABLES -# - -if [ ! -s init.json ] -then - echo "Please choose your country:" - echo "[1] DE | 2 [AT] | 3 [CH] | 4 [NL] | 5 [PL]" - echo "[6] IE | 7 [SK] | 8 [CZ] | 9 [HU] | 0 [RO]" - - printf "\n" - read -p "Number....: " -n1 n - printf "\n" - - case $n in - 1) echo '{"country":"DE","language":"de"}' > init.json - echo "Country selected: DE" && printf "\n";; - 2) echo '{"country":"AT","language":"de"}' > init.json - echo "Country selected: AT" && printf "\n";; - 3) echo '{"country":"CH","language":"de"}' > init.json - echo "Country selected: CH" && printf "\n";; - 4) echo '{"country":"NL","language":"nl"}' > init.json - echo "Country selected: NL" && printf "\n";; - 5) echo '{"country":"PL","language":"pl"}' > init.json - echo "Country selected: PL" && printf "\n";; - 6) echo '{"country":"IE","language":"en"}' > init.json - echo "Country selected: IE" && printf "\n";; - 7) echo '{"country":"SK","language":"sk"}' > init.json - echo "Country selected: SK" && printf "\n";; - 8) echo '{"country":"CZ","language":"cz"}' > init.json - echo "Country selected: CZ" && printf "\n";; - 9) echo '{"country":"HU","language":"hu"}' > init.json - echo "Country selected: HU" && printf "\n";; - 0) echo '{"country":"RO","language":"ro"}' > init.json - echo "Country selected: RO" && printf "\n";; - esac -fi +mkdir cache 2> /dev/null # cache +mkdir day 2> /dev/null # download scripts if grep -q "DE" init.json 2> /dev/null then @@ -141,7 +90,7 @@ then baseurl='https://web-api-pepper.horizon.tv/oesp/v2/RO/ron/web' baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/RO\/ron\/web' else - echo "ERROR: WRONG INIT INPUT DETECTED - Stop." + echo "[ FATAL ERROR ] WRONG INIT INPUT DETECTED - Stop." rm init.json 2> /dev/null exit 1 fi @@ -208,13 +157,13 @@ printf "\rDownloading EPG manifest files... " for i in {1..4..1} do - curl -s $baseurl/programschedules/$date1/${i} | grep '"updated"' >> day/day1 & - curl -s $baseurl/programschedules/$date2/${i} | grep '"updated"' >> day/day2 & - curl -s $baseurl/programschedules/$date3/${i} | grep '"updated"' >> day/day3 & - curl -s $baseurl/programschedules/$date4/${i} | grep '"updated"' >> day/day4 & - curl -s $baseurl/programschedules/$date5/${i} | grep '"updated"' >> day/day5 & - curl -s $baseurl/programschedules/$date6/${i} | grep '"updated"' >> day/day6 & - curl -s $baseurl/programschedules/$date7/${i} | grep '"updated"' >> day/day7 & + if grep -q '"day": "[1-7]"' settings.json; then curl -s $baseurl/programschedules/$date1/${i} | grep '"updated"' > day/day1_${i}; fi & + if grep -q '"day": "[2-7]"' settings.json; then curl -s $baseurl/programschedules/$date2/${i} | grep '"updated"' > day/day2_${i}; fi & + if grep -q '"day": "[3-7]"' settings.json; then curl -s $baseurl/programschedules/$date3/${i} | grep '"updated"' > day/day3_${i}; fi & + if grep -q '"day": "[4-7]"' settings.json; then curl -s $baseurl/programschedules/$date4/${i} | grep '"updated"' > day/day4_${i}; fi & + if grep -q '"day": "[5-7]"' settings.json; then curl -s $baseurl/programschedules/$date5/${i} | grep '"updated"' > day/day5_${i}; fi & + if grep -q '"day": "[6-7]"' settings.json; then curl -s $baseurl/programschedules/$date6/${i} | grep '"updated"' > day/day6_${i}; fi & + if grep -q '"day": "[7]"' settings.json; then curl -s $baseurl/programschedules/$date7/${i} | grep '"updated"' > day/day7_${i}; fi & done wait @@ -225,14 +174,22 @@ wait printf "\rCreating EPG lists... " +curl -s $baseurl/channels > /tmp/chlist +perl chlist_printer.pl > /tmp/compare.json + for time in {1..7..1} do - sed -i 's/"i":"/\n/g' day/day${time} - sed -i '/{"entryCount/d' day/day${time} - sed -i 's/","r":.*//g' day/day${time} - cp day/day${time} day/daydlnew_${time} + for part in {1..4..1} + do + sed "s/dayNUMBER/day${time}_${part}/g" compare_crid.pl > /tmp/compare_crid_day${time}_${part}.pl 2> /dev/null + perl /tmp/compare_crid_day${time}_${part}.pl > day/daydlnew_${time}_${part} 2> /dev/null + cat day/daydlnew_${time}_${part} >> day/daydlnew_${time} 2> /dev/null + cp day/daydlnew_${time} day/day${time} 2> /dev/null + rm day/daydlnew_${time}_${part} day/day${time}_${part} 2> /dev/null + touch day/day${time} + done done - + # # COPY CACHE FILES TO NEW FOLDER @@ -701,13 +658,13 @@ perl cid_json.pl > hzn_cid.json && rm chlist # COMBINING ALL EPG PARTS TO ONE FILE printf "\rCopying JSON files to common file... " -cat cache/new_$date1/* > workfile -cat cache/new_$date2/* >> workfile -cat cache/new_$date3/* >> workfile -cat cache/new_$date4/* >> workfile -cat cache/new_$date5/* >> workfile -cat cache/new_$date6/* >> workfile -cat cache/new_$date7/* >> workfile +cat cache/new_$date1/* > workfile 2> /dev/null +cat cache/new_$date2/* >> workfile 2> /dev/null +cat cache/new_$date3/* >> workfile 2> /dev/null +cat cache/new_$date4/* >> workfile 2> /dev/null +cat cache/new_$date5/* >> workfile 2> /dev/null +cat cache/new_$date6/* >> workfile 2> /dev/null +cat cache/new_$date7/* >> workfile 2> /dev/null # SORT BY CID AND START TIME printf "\rSorting data by channel ID and start time... " diff --git a/hzn/settings.sh b/hzn/settings.sh new file mode 100644 index 0000000..1c83fb9 --- /dev/null +++ b/hzn/settings.sh @@ -0,0 +1,503 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg/hzn +# +# Collaborators: +# - DeBaschdi ( https://github.com/DeBaschdi ) +# +# This Program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This Program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with easyepg. If not, see . + +# SETTINGS MENU + +# ################ +# INITIALIZATION # +# ################ + +if grep -q "DE" init.json 2> /dev/null +then + COUNTRY='DE' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/DE/deu/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/DE\/deu\/web' +elif grep -q "AT" init.json 2> /dev/null +then + COUNTRY='AT' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/AT/deu/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/AT\/deu\/web' +elif grep -q "CH" init.json 2> /dev/null +then + COUNTRY='CH' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/CH/deu/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/CH\/deu\/web' +elif grep -q "NL" init.json 2> /dev/null +then + COUNTRY='NL' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/NL/nld/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/NL\/nld\/web' +elif grep -q "PL" init.json 2> /dev/null +then + COUNTRY='PL' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/PL/pol/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/PL\/pol\/web' +elif grep -q "IE" init.json 2> /dev/null +then + COUNTRY='IE' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/IE/eng/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/IE\/eng\/web' +elif grep -q "SK" init.json 2> /dev/null +then + COUNTRY='SK' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/SK/slk/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/SK\/slk\/web' +elif grep -q "CZ" init.json 2> /dev/null +then + COUNTRY='CZ' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/CZ/ces/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/CZ\/ces\/web' +elif grep -q "HU" init.json 2> /dev/null +then + COUNTRY='HU' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/HU/hun/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/HU\/hun\/web' +elif grep -q "RO" init.json 2> /dev/null +then + COUNTRY='RO' + baseurl='https://web-api-pepper.horizon.tv/oesp/v2/RO/ron/web' + baseurl_sed='web-api-pepper.horizon.tv\/oesp\/v2\/RO\/ron\/web' +else + echo "[ FATAL ERROR ] WRONG INIT INPUT DETECTED - Stop." + rm init.json 2> /dev/null + exit 1 +fi + +rm /tmp/settings_new 2> /dev/null + +# ######################## +# H1000 HORIZON SETTINGS # +# ######################## + +echo "H" > /tmp/value + +while grep -q "H" /tmp/value +do + # H1000 MENU OVERLAY + echo 'dialog --backtitle "[H1000] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS [X]" --title "SETTINGS" --menu "Please select the option you want to change:" 14 60 10 \' > /tmp/menu + + if [ ! -e settings.json ] + then + if [ ! -e /tmp/settings_new ] + then + # INSERT DEFAULT VALUES + echo "day=7" > /tmp/settings_new # grab 7 days by default + echo "cid=disabled" >> /tmp/settings_new # do not use Rytec IDs by default + echo "genre=enabled" >> /tmp/settings_new # use EIT format for genres by default + echo "category=enabled" >> /tmp/settings_new # insert all categories by default + echo "episode=xmltv_ns" >> /tmp/settings_new # use XMLTV_NS format for episodes by default + fi + else + # EXTRACT VALUES FROM JSON FILE + grep '"day":' settings.json | sed 's/\("day": "\)\(.*\)",/day=\2/g' > /tmp/settings_new + grep '"cid":' settings.json | sed 's/\("cid": "\)\(.*\)",/cid=\2/g' >> /tmp/settings_new + grep '"genre":' settings.json | sed 's/\("genre": "\)\(.*\)",/genre=\2/g' >> /tmp/settings_new + grep '"category":' settings.json | sed 's/\("category": "\)\(.*\)",/category=\2/g' >> /tmp/settings_new + grep '"episode":' settings.json | sed 's/\("episode": "\)\(.*\)",/episode=\2/g' >> /tmp/settings_new + fi + + # H1100 CHANNEL LIST + echo ' 1 "MODIFY CHANNEL LIST" \' >> /tmp/menu + + # H1200 TIME PERIOD + if grep -q "day=1" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 1 day)" \' >> /tmp/menu + elif grep -q "day=2" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 2 days)" \' >> /tmp/menu + elif grep -q "day=3" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 3 days)" \' >> /tmp/menu + elif grep -q "day=4" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 4 days)" \' >> /tmp/menu + elif grep -q "day=5" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 5 days)" \' >> /tmp/menu + elif grep -q "day=6" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 6 days)" \' >> /tmp/menu + elif grep -q "day=7" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 7 days)" \' >> /tmp/menu + elif grep -q "day=0" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: disabled)" \' >> /tmp/menu + fi + + # H1300 CONVERT CHANNEL IDs + if grep -q "cid=enabled" /tmp/settings_new + then + echo ' 3 "CONVERT CHANNEL IDs INTO RYTEC FORMAT (enabled)" \' >> /tmp/menu + elif grep -q "cid=disabled" /tmp/settings_new + then + echo ' 3 "CONVERT CHANNEL IDs INTO RYTEC FORMAT (disabled)" \' >> /tmp/menu + fi + + # H1400 CONVERT CATEGORIES + if grep -q "genre=enabled" /tmp/settings_new + then + echo ' 4 "CONVERT CATEGORIES INTO EIT FORMAT (enabled)" \' >> /tmp/menu + elif grep -q "genre=disabled" /tmp/settings_new + then + echo ' 4 "CONVERT CATEGORIES INTO EIT FORMAT (disabled)" \' >> /tmp/menu + fi + + # H1500 MULTIPLE CATEGORIES + if grep -q "category=enabled" /tmp/settings_new + then + echo ' 5 "USE MULTIPLE CATEGORIES (enabled)" \' >> /tmp/menu + elif grep -q "category=disabled" /tmp/settings_new + then + echo ' 5 "USE MULTIPLE CATEGORIES (disabled)" \' >> /tmp/menu + fi + + # H1600 EPISODE FORMAT + if grep -q "episode=xmltv_ns" /tmp/settings_new + then + echo ' 6 "EPISODE FORMAT (currently: xmltv_ns)" \' >> /tmp/menu + elif grep -q "episode=onscreen" /tmp/settings_new + then + echo ' 6 "EPISODE FORMAT (currently: onscreen)" \' >> /tmp/menu + fi + + # H1700 DELETE INSTANCE + echo ' 7 "REMOVE GRABBER INSTANCE" \' >> /tmp/menu + + echo "2> /tmp/value" >> /tmp/menu + + if [ ! -e channels.json ] + then + echo "1" > /tmp/value + else + sed -i "s/\[X\]/[$COUNTRY]/g" /tmp/menu + bash /tmp/menu + input="$(cat /tmp/value)" + fi + + + # #################### + # H1100 CHANNEL LIST # + # #################### + + if grep -q "1" /tmp/value + then + # H1100 MENU OVERLAY + echo 'dialog --backtitle "[H1100] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CHANNEL LIST [X]" --title "CHANNELS" --checklist "Please choose the channels you want to grab:" 15 50 10 \' > /tmp/chmenu + + printf "\rLoading channel list..." + curl -s $baseurl/channels > /tmp/chlist + + printf "\rLoading channel configuration..." + perl cid_json.pl > /tmp/chvalues + sed -i '/{/d;/}/d;s/.*":"//g;s/",//g;/DUMMY/d' /tmp/chvalues + sort -u /tmp/chvalues > /tmp/chvalues_sorted && mv /tmp/chvalues_sorted /tmp/chvalues + + if [ ! -e channels.json ] + then + nl /tmp/chvalues > /tmp/chvalues_count + sed -i 's/\( \)\([0-9].*\)/[\2/g;s/\( \)\([0-9].*\)/[\2/g;s/\( \)\([0-9].*\)/[\2/g;s/[\t]/] /g;s/\&/\&/g' /tmp/chvalues_count + mv /tmp/chvalues_count /tmp/chvalues + sed -i 's/.*/"&" "" off \\/g' /tmp/chvalues + sed -i '$s/.*/&\n2>\/tmp\/chconf/g' /tmp/chvalues + cat /tmp/chvalues >> /tmp/chmenu + + sed -i "s/\[X\]/[$COUNTRY]/g" /tmp/chmenu + bash /tmp/chmenu + + if [ -s /tmp/chconf ] + then + sed 's/" "/","/g;s/\\\[[^ ]* //g;s/\\(/(/g;s/\\)/)/g;s/.*/{"channels":[&]}/g;s/\\\&/\&/g' /tmp/chconf > channels.json + cp /tmp/chlist chlist_old + echo "H" > /tmp/value + else + echo "M" > /tmp/value + exit 1 + fi + else + perl chlist_printer.pl > /tmp/compare.json + perl compare_menu.pl > /tmp/enabled_chvalues + comm -12 <(sort -u /tmp/enabled_chvalues) <(sort -u /tmp/chvalues) > /tmp/comm_menu_enabled + comm -2 -3 <(sort -u /tmp/chvalues) <(sort -u /tmp/enabled_chvalues) > /tmp/comm_menu_disabled + sed -i 's/.*/&" [ON]/g' /tmp/comm_menu_enabled + sed -i 's/.*/&" [OFF]/g' /tmp/comm_menu_disabled + cat /tmp/comm_menu_disabled >> /tmp/comm_menu_enabled + sort /tmp/comm_menu_enabled > /tmp/chvalues + nl /tmp/chvalues > /tmp/chvalues_count + sed -i 's/\( \)\([0-9].*\)/"[\2/g;s/\( \)\([0-9].*\)/"[\2/g;s/\( \)\([0-9].*\)/"[\2/g;s/[\t]/] /g;s/\&/\&/g' /tmp/chvalues_count + mv /tmp/chvalues_count /tmp/chvalues + sed -i 's/\[ON\]/"" on \\/g;s/\[OFF\]/"" off \\/g' /tmp/chvalues + sed -i '$s/.*/&\n2>\/tmp\/chconf/g' /tmp/chvalues + cat /tmp/chvalues >> /tmp/chmenu + + sed -i "s/\[X\]/[$COUNTRY]/g" /tmp/chmenu + bash /tmp/chmenu + + if [ -s /tmp/chconf ] + then + sed 's/" "/","/g;s/\\\[[^ ]* //g;s/\\(/(/g;s/\\)/)/g;s/.*/{"channels":[&]}/g;s/\\\&/\&/g' /tmp/chconf > channels.json + echo "H" > /tmp/value + else + echo "H" > /tmp/value + fi + fi + + + # ################### + # H1200 TIME PERIOD # + # ################### + + elif grep -q "2" /tmp/value + then + echo "X" > /tmp/value + + while grep -q "X" /tmp/value + do + # H1200 MENU OVERLAY + dialog --backtitle "[H1200] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > TIME PERIOD" --title "EPG GRABBER" --inputbox "Please enter the number of days you want to retrieve the EPG information. (0=disable | 1-7=enable)" 10 46 2>/tmp/value + + sed -i 's/.*/epg&-/g' /tmp/value + + # H1210 INPUT: DISABLED + if grep -q "epg0-" /tmp/value + then + sed -i '/day=/d' /tmp/settings_new + echo "day=0" >> /tmp/settings_new + dialog --backtitle "[H1210] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber disabled!" 5 26 + echo "H" > /tmp/value + + # H1220 INPUT: 1 DAY + elif grep -q "epg1-" /tmp/value + then + sed -i '/day=/d' /tmp/settings_new + echo "day=1" >> /tmp/settings_new + dialog --backtitle "[H1220] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber is enabled for 1 day!" 5 42 + echo "H" > /tmp/value + + # H1230 INPUT: 2-7 DAYS + elif grep -q "epg[2-7]-" /tmp/value + then + sed -i 's/epg//g;s/-//g' /tmp/value + sed -i '/day=/d' /tmp/settings_new + echo "day=$(> /tmp/settings_new + dialog --backtitle "[H1230] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber is enabled for $( /tmp/value + + # H1240 WRONG INPUT + elif [ -s /tmp/value ] + then + dialog --backtitle "[H1240] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > TIME PERIOD" --title "ERROR" --msgbox "Wrong input detected!" 5 30 + echo "X" > /tmp/value + + # H12X0 EXIT + else + echo "H" > /tmp/value + fi + done + + + # ########################### + # H1300 CONVERT CHANNEL IDs # + # ########################### + + elif grep -q "3" /tmp/value + then + # H1400 MENU OVERLAY + dialog --backtitle "[H1400] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CHANNEL IDs" --title "CHANNEL IDs" --yesno "Do you want to use the Rytec ID format?\n\nRytec ID example: ChannelNameHD.de\nUsual ID example: Channel Name HD" 8 55 + + response=$? + + # H1310 NO + if [ $response = 1 ] + then + dialog --backtitle "[H1310] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CHANNEL IDs" --title "INFO" --msgbox "Rytec Channel IDs disabled!" 5 32 + sed -i '/cid=/d' /tmp/settings_new + echo "cid=disabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H1320 YES + elif [ $response = 0 ] + then + dialog --backtitle "[H1320] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CHANNEL IDs" --title "INFO" --msgbox "Rytec Channel IDs enabled!" 5 30 + sed -i '/cid=/d' /tmp/settings_new + echo "cid=enabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H13X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[H13X0] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CHANNEL IDs" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ########################### + # H1400 CONVERT CATEGORIES # + # ########################### + + elif grep -q "4" /tmp/value + then + # H1400 MENU OVERLAY + dialog --backtitle "[H1400] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CATEGORIES" --title "CATEGORIES" --yesno "Do you want to use the EIT format for tvHeadend?" 5 55 + + response=$? + + # H1410 NO + if [ $response = 1 ] + then + dialog --backtitle "[H1410] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CATEGORIES" --title "INFO" --msgbox "EIT categories disabled!" 5 32 + sed -i '/genre=/d' /tmp/settings_new + echo "genre=disabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H1420 YES + elif [ $response = 0 ] + then + dialog --backtitle "[H1420] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CATEGORIES" --title "INFO" --msgbox "EIT categories enabled!" 5 30 + sed -i '/genre=/d' /tmp/settings_new + echo "genre=enabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H14X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[H14X0] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > CONVERT CATEGORIES" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ########################### + # H1500 MULTIPLE CATEGORIES # + # ########################### + + elif grep -q "5" /tmp/value + then + # H1400 MENU OVERLAY + dialog --backtitle "[H1500] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > MULTIPLE CATEGORIES" --title "MULTIPLE CATEGORIES" --yesno "Do you want to use multiple categories for tvHeadend?" 5 60 + + response=$? + + # H1510 NO + if [ $response = 1 ] + then + dialog --backtitle "[H1510] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > MULTIPLE CATEGORIES" --title "INFO" --msgbox "Multiple categories disabled!" 5 35 + sed -i '/category=/d' /tmp/settings_new + echo "category=disabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H1520 YES + elif [ $response = 0 ] + then + dialog --backtitle "[H1520] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > MULTIPLE CATEGORIES" --title "INFO" --msgbox "Multiple categories enabled!" 5 35 + sed -i '/category=/d' /tmp/settings_new + echo "category=enabled" >> /tmp/settings_new + echo "H" > /tmp/value + + # H15X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[H15X0] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > MULTIPLE CATEGORIES" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ###################### + # H1600 EPISODE FORMAT # + # ###################### + + elif grep -q "6" /tmp/value + then + # H1600 MENU OVERLAY + dialog --backtitle "[H1600] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > EPISODE FORMAT" --title "EPISODE" --menu "Please select the format you want to use.\n\nonscreen: move the episode data into the broadcast description\nxmltv_ns: episode data to be parsed by tvHeadend" 14 60 10 \ + 1 "ONSCREEN" \ + 2 "XMLTV_NS" \ + 2>/tmp/value + + # H1610 ONSCREEN + if grep -q "1" /tmp/value + then + dialog --backtitle "[H1610] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > EPISODE FORMAT" --title "INFO" --msgbox "Episode format 'onscreen' enabled!" 5 30 + sed -i '/episode=/d' /tmp/settings_new + echo "episode=onscreen" >> /tmp/settings_new + echo "H" > /tmp/value + + # H1620 XMLTV_NS + elif grep -q "2" /tmp/value + then + dialog --backtitle "[H1620] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > EPISODE FORMAT" --title "INFO" --msgbox "Episode format 'xmltv_ns' enabled!" 5 30 + sed -i '/episode=/d' /tmp/settings_new + echo "episode=xmltv_ns" >> /tmp/settings_new + echo "H" > /tmp/value + + # H16X0 EXIT + else + echo "H" > /tmp/value + fi + + + # ####################### + # H1700 DELETE INSTANCE # + # ####################### + + elif grep -q "7" /tmp/value + then + # H1700 MENU OVERLAY + dialog --backtitle "[H1700] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > DELETE INSTANCE" --title "WARNING" --yesno "Do you want to delete this service?" 5 50 + + response=$? + + # H1710 NO + if [ $response = 1 ] + then + dialog --backtitle "[H1710] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service not deleted!" 5 32 + echo "H" > /tmp/value + + # H1720 YES + elif [ $response = 0 ] + then + dialog --backtitle "[H1720] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service deleted!" 5 30 + rm channels.json + echo "M" > /tmp/value + + # H17X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[H17X0] EASYEPG SIMPLE XMLTV GRABBER > HORIZON SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service not deleted!" 5 30 + echo "H" > /tmp/value + fi + + + # ############ + # H1X00 EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + +sed -i 's/.*/"&",/g' /tmp/settings_new +sed -i 's/=/": "/g' /tmp/settings_new +sed -i '1i{ "settings": {' /tmp/settings_new +sed '$s/.*/&\n"settings": "true" }\n}/g' /tmp/settings_new > settings.json +rm /tmp/settings_new + +done