From 5337c037576a6897384d92bc9d38ace3686568a6 Mon Sep 17 00:00:00 2001 From: Jan-Luca Neumann Date: Sat, 5 Oct 2019 17:11:34 +0200 Subject: [PATCH 01/23] Horizon: Add channel logos to XML file * also use UTF-8 for STDERR --- hzn/ch_json2xml.pl | 26 +++++++++++++++++++++++--- hzn/chlist_printer.pl | 1 + hzn/cid_json.pl | 1 + hzn/compare_menu.pl | 1 + hzn/epg_json2xml.pl | 1 + hzn/hzn.sh | 2 +- hzn/url_printer.pl | 1 + 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hzn/ch_json2xml.pl b/hzn/ch_json2xml.pl index 47a6ef7..5fc162f 100755 --- a/hzn/ch_json2xml.pl +++ b/hzn/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -105,6 +106,10 @@ $cname =~ s/†//g; # REMOVE "SELECTED AREA" $cname =~ s/‡//g; $cname =~ s/\ \ /\ /g; + + # DEFINE LOGO + my @logo = @{ $item->{'images'} }; + my $image_location; # DEFINE LANGUAGE VERSION my $languageVER = $initdata->{'language'}; @@ -142,9 +147,24 @@ print ""; } - # CHANNEL NAME (language) - print "" . $cname . "\n"; + # CHANNEL NAME + LOGO (language) (loop) + if( @logo ) { + while( my( $image_id, $image ) = each( @logo ) ) { + if( $image->{'assetType'} eq "station-logo-large" ) { + $image_location = $image_id; + last; + } + } + if( defined $image_location ) { + my $logo_def = $item->{'images'}[$image_location]{'url'}; + $logo_def =~ s/\?w.*//g; + print "" . $cname . ""; + print "\n"; + } else { + print "" . $cname . "\n"; + } + } + } } } - } } diff --git a/hzn/chlist_printer.pl b/hzn/chlist_printer.pl index 6a384ee..710755c 100755 --- a/hzn/chlist_printer.pl +++ b/hzn/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/hzn/cid_json.pl b/hzn/cid_json.pl index 81d263d..563a95d 100755 --- a/hzn/cid_json.pl +++ b/hzn/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/hzn/compare_menu.pl b/hzn/compare_menu.pl index 3c7fa2f..5855a7c 100755 --- a/hzn/compare_menu.pl +++ b/hzn/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/hzn/epg_json2xml.pl b/hzn/epg_json2xml.pl index 1923446..0fa993a 100755 --- a/hzn/epg_json2xml.pl +++ b/hzn/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/hzn/hzn.sh b/hzn/hzn.sh index dde3a4f..94a2721 100755 --- a/hzn/hzn.sh +++ b/hzn/hzn.sh @@ -356,7 +356,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/hzn_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > horizon_channels sort -u horizon_channels > /tmp/horizon_channels && mv /tmp/horizon_channels horizon_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 17:12:59 +0200 Subject: [PATCH 02/23] Swisscom: Add channel logos to XML file * also use UTF-8 for STDERR --- swc/ch_json2xml.pl | 7 ++++++- swc/chlist_printer.pl | 1 + swc/cid_json.pl | 1 + swc/compare_menu.pl | 1 + swc/epg_json2xml.pl | 1 + swc/swc.sh | 2 +- swc/url_printer.pl | 1 + 7 files changed, 12 insertions(+), 2 deletions(-) diff --git a/swc/ch_json2xml.pl b/swc/ch_json2xml.pl index f2f75b6..4cdd57d 100755 --- a/swc/ch_json2xml.pl +++ b/swc/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -98,6 +99,7 @@ # DEFINE CHANNEL ID + NAME my $cname = $attributes->{'Title'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + my $cid = $attributes->{'Identifier'}; # DEFINE LANGUAGE VERSION # my $languageVER = $initdata->{'language'}; @@ -137,7 +139,10 @@ } # CHANNEL NAME (language) - print "" . $cname . "\n"; + print "" . $cname . ""; + + # CHANNEL LOGO + print "\n" } } } diff --git a/swc/chlist_printer.pl b/swc/chlist_printer.pl index 3d5c9ad..4f43799 100755 --- a/swc/chlist_printer.pl +++ b/swc/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/swc/cid_json.pl b/swc/cid_json.pl index fbea914..8a697fc 100755 --- a/swc/cid_json.pl +++ b/swc/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/swc/compare_menu.pl b/swc/compare_menu.pl index d71618d..2fc8836 100755 --- a/swc/compare_menu.pl +++ b/swc/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/swc/epg_json2xml.pl b/swc/epg_json2xml.pl index 829e4a4..e803c2e 100755 --- a/swc/epg_json2xml.pl +++ b/swc/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/swc/swc.sh b/swc/swc.sh index 35e2fdc..0e4c976 100755 --- a/swc/swc.sh +++ b/swc/swc.sh @@ -304,7 +304,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/swc_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > swisscom_channels sort -u swisscom_channels > /tmp/swisscom_channels && mv /tmp/swisscom_channels swisscom_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 19:03:21 +0200 Subject: [PATCH 03/23] Telekom: Add channel logos to XML file * also use UTF-8 for STDERR --- tkm/ch_json2xml.pl | 24 +++++++++++++++++++++--- tkm/chlist_printer.pl | 1 + tkm/cid_json.pl | 1 + tkm/compare_menu.pl | 1 + tkm/epg_json2xml.pl | 1 + tkm/tkm.sh | 2 +- tkm/url_printer.pl | 1 + 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tkm/ch_json2xml.pl b/tkm/ch_json2xml.pl index 3f93a61..aa7198b 100755 --- a/tkm/ch_json2xml.pl +++ b/tkm/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -98,6 +99,10 @@ # DEFINE CHANNEL ID + NAME my $cname = $attributes->{'name'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE LOGO + my @logo = @{ $attributes->{'pictures'} }; + my $image_location; # DEFINE LANGUAGE VERSION my $languageVER = $initdata->{'language'}; @@ -135,8 +140,21 @@ print ""; } - # CHANNEL NAME (language) - print "" . $cname . "\n"; + # CHANNEL NAME + LOGO (language) (loop) + if( @logo ) { + while( my( $image_id, $image ) = each( @logo ) ) { + if( $image->{'imageType'} eq "15" ) { + $image_location = $image_id; + last; + } + } + if( defined $image_location ) { + print "" . $cname . ""; + print "{'pictures'}[$image_location]{'href'} . "\" />\n"; + } else { + print "" . $cname . "\n"; + } + } + } } - } } diff --git a/tkm/chlist_printer.pl b/tkm/chlist_printer.pl index 327197e..3961ddb 100755 --- a/tkm/chlist_printer.pl +++ b/tkm/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tkm/cid_json.pl b/tkm/cid_json.pl index f924143..674fd50 100755 --- a/tkm/cid_json.pl +++ b/tkm/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tkm/compare_menu.pl b/tkm/compare_menu.pl index ee2f400..41c2ed2 100755 --- a/tkm/compare_menu.pl +++ b/tkm/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tkm/epg_json2xml.pl b/tkm/epg_json2xml.pl index 42c3532..eb9d2fe 100755 --- a/tkm/epg_json2xml.pl +++ b/tkm/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tkm/tkm.sh b/tkm/tkm.sh index 52bc3ec..6f3096d 100755 --- a/tkm/tkm.sh +++ b/tkm/tkm.sh @@ -235,7 +235,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/tkm_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > magenta_channels sort -u magenta_channels > /tmp/magenta_channels && mv /tmp/magenta_channels magenta_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 19:17:26 +0200 Subject: [PATCH 04/23] tvPlayer: Add channel logos to XML file * also use UTF-8 for STDERR --- tvp/ch_json2xml.pl | 9 ++++++++- tvp/chlist_printer.pl | 1 + tvp/cid_json.pl | 1 + tvp/compare_crid.pl | 1 + tvp/compare_menu.pl | 1 + tvp/epg_json2xml.pl | 1 + tvp/tvp.sh | 2 +- 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tvp/ch_json2xml.pl b/tvp/ch_json2xml.pl index 9ce752e..f97d067 100755 --- a/tvp/ch_json2xml.pl +++ b/tvp/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -98,6 +99,9 @@ # DEFINE CHANNEL ID + NAME my $cname = $attributes->{'name'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE LOGO + my $logo = $attributes->{'logo'}{'colour'}; # DEFINE LANGUAGE VERSION my $languageVER = $initdata->{'language'}; @@ -136,7 +140,10 @@ } # CHANNEL NAME (language) - print "" . $cname . "\n"; + print "" . $cname . ""; + + # CHANNEL LOGO + print "\n"; } } } diff --git a/tvp/chlist_printer.pl b/tvp/chlist_printer.pl index 4fe06f2..baf9d68 100755 --- a/tvp/chlist_printer.pl +++ b/tvp/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvp/cid_json.pl b/tvp/cid_json.pl index 8a0b930..e7ab9f4 100755 --- a/tvp/cid_json.pl +++ b/tvp/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvp/compare_crid.pl b/tvp/compare_crid.pl index 62b6a17..8293236 100755 --- a/tvp/compare_crid.pl +++ b/tvp/compare_crid.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvp/compare_menu.pl b/tvp/compare_menu.pl index 67afad0..1571ab4 100755 --- a/tvp/compare_menu.pl +++ b/tvp/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvp/epg_json2xml.pl b/tvp/epg_json2xml.pl index 1f25a92..65908b4 100755 --- a/tvp/epg_json2xml.pl +++ b/tvp/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvp/tvp.sh b/tvp/tvp.sh index 37754bd..1affdc6 100755 --- a/tvp/tvp.sh +++ b/tvp/tvp.sh @@ -136,7 +136,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/tvp_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > tvp_channels sort -u tvp_channels > /tmp/tvp_channels && mv /tmp/tvp_channels tvp_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 19:26:37 +0200 Subject: [PATCH 05/23] TV-Spielfilm: Add channel logos to XML file * also use UTF-8 for STDERR --- tvs/ch_json2xml.pl | 13 ++++++++++--- tvs/chlist_printer.pl | 5 +++-- tvs/cid_json.pl | 5 +++-- tvs/compare_menu.pl | 5 +++-- tvs/epg_json2xml.pl | 7 ++++--- tvs/tvs.sh | 2 +- tvs/url_printer.pl | 5 +++-- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/tvs/ch_json2xml.pl b/tvs/ch_json2xml.pl index f2f7a46..6745e94 100644 --- a/tvs/ch_json2xml.pl +++ b/tvs/ch_json2xml.pl @@ -19,9 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -# ############################### +# ################################## # TVSPIELFILM JSON > XML CONVERTER # -# ############################### +# ################################## # CHANNELS @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -98,6 +99,9 @@ # DEFINE CHANNEL ID + NAME my $cname = $items->{'name'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE CHANNEL LOGO + my $logo = $items->{'image_large'}{'url'}; # DEFINE LANGUAGE VERSION # my $languageVER = $initdata->{'language'}; @@ -137,7 +141,10 @@ } # CHANNEL NAME (language) - print "" . $cname . "\n"; + print "" . $cname . ""; + + # CHANNEL LOGO + print "\n"; } } } diff --git a/tvs/chlist_printer.pl b/tvs/chlist_printer.pl index baa8d99..8e83e58 100644 --- a/tvs/chlist_printer.pl +++ b/tvs/chlist_printer.pl @@ -19,9 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -# ################################ +# #################################### # TV-SPIELFILM CHANNEL LIST CREATOR # -# ################################ +# #################################### # CREATE JSON FILE FOR COMPARISM @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvs/cid_json.pl b/tvs/cid_json.pl index 5943865..095acbb 100644 --- a/tvs/cid_json.pl +++ b/tvs/cid_json.pl @@ -19,9 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -# ############################### +# ################################## # TVSPIELFILM CHANNEL ID CREATOR # -# ############################### +# ################################## # CHANNEL IDs @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvs/compare_menu.pl b/tvs/compare_menu.pl index 04ec9b1..e95f374 100644 --- a/tvs/compare_menu.pl +++ b/tvs/compare_menu.pl @@ -19,9 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -# ################################# +# ###################################### # TV-SPIELFILM TV CHANNEL LIST CREATOR # -# ################################# +# ###################################### # COMPARE STRINGS, CREATE MENU LIST @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/tvs/epg_json2xml.pl b/tvs/epg_json2xml.pl index 4f90386..c323c1f 100644 --- a/tvs/epg_json2xml.pl +++ b/tvs/epg_json2xml.pl @@ -19,9 +19,9 @@ # You should have received a copy of the GNU General Public License # along with easyepg. If not, see . -# ################################# +# ################################### # TV-SPIELFILM JSON > XML CONVERTER # -# ################################# +# ################################### # EPG @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -360,4 +361,4 @@ print "\n"; } } -} \ No newline at end of file +} diff --git a/tvs/tvs.sh b/tvs/tvs.sh index 892f2b7..abeacc1 100644 --- a/tvs/tvs.sh +++ b/tvs/tvs.sh @@ -232,7 +232,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/tvs_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > tv-spielfilm_channels sort -u tv-spielfilm_channels > /tmp/tv-spielfilm_channels && mv /tmp/tv-spielfilm_channels tv-spielfilm_channels -sed -i 's/>\n\n. -# ################################# +# ###################################### # TV-SPIELFILM TV MANIFEST URL PRINTER # -# ################################# +# ###################################### use strict; use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; From 7c62c4fae7073605f290175acb4d3315872de2e0 Mon Sep 17 00:00:00 2001 From: Jan-Luca Neumann Date: Sat, 5 Oct 2019 19:37:23 +0200 Subject: [PATCH 06/23] Vodafone: Add channel logos to XML file * also use UTF-8 for STDERR --- vdf/ch_json2xml.pl | 9 ++++++++- vdf/chlist_printer.pl | 1 + vdf/cid_json.pl | 1 + vdf/compare_crid.pl | 3 ++- vdf/compare_menu.pl | 1 + vdf/epg_json2xml.pl | 3 ++- vdf/url_printer.pl | 1 + vdf/vdf.sh | 4 ++-- 8 files changed, 18 insertions(+), 5 deletions(-) diff --git a/vdf/ch_json2xml.pl b/vdf/ch_json2xml.pl index a47e9bf..f7208dd 100644 --- a/vdf/ch_json2xml.pl +++ b/vdf/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -98,6 +99,9 @@ # DEFINE CHANNEL ID + NAME my $cname = $items->{'lname'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE CHANNEL LOGO + my $logo = $items->{'logo'}; # DEFINE LANGUAGE VERSION # my $languageVER = $initdata->{'language'}; @@ -137,7 +141,10 @@ } # CHANNEL NAME (language) - print "" . $cname . "\n"; + print "" . $cname . ""; + + # CHANNEL LOGO + print "\n"; } } } diff --git a/vdf/chlist_printer.pl b/vdf/chlist_printer.pl index 2e4e6ae..2136b16 100644 --- a/vdf/chlist_printer.pl +++ b/vdf/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/vdf/cid_json.pl b/vdf/cid_json.pl index c61edf9..6c92860 100644 --- a/vdf/cid_json.pl +++ b/vdf/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/vdf/compare_crid.pl b/vdf/compare_crid.pl index c58ac2f..141a549 100644 --- a/vdf/compare_crid.pl +++ b/vdf/compare_crid.pl @@ -27,6 +27,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -63,4 +64,4 @@ print $crid . "\n"; } -} \ No newline at end of file +} diff --git a/vdf/compare_menu.pl b/vdf/compare_menu.pl index b406295..7f090c7 100644 --- a/vdf/compare_menu.pl +++ b/vdf/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/vdf/epg_json2xml.pl b/vdf/epg_json2xml.pl index dbecc11..c496277 100644 --- a/vdf/epg_json2xml.pl +++ b/vdf/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -464,4 +465,4 @@ print "\n"; } -} \ No newline at end of file +} diff --git a/vdf/url_printer.pl b/vdf/url_printer.pl index aafc472..db75a63 100644 --- a/vdf/url_printer.pl +++ b/vdf/url_printer.pl @@ -27,6 +27,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/vdf/vdf.sh b/vdf/vdf.sh index cda213d..845cda3 100644 --- a/vdf/vdf.sh +++ b/vdf/vdf.sh @@ -333,7 +333,7 @@ then sed "s/.*/curl --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 -s 'https:\/\/tv-manager.vodafone.de\/tv-manager\/backend\/auth-service\/proxy\/epg-data-service\/epg\/tv\/data\/item\/&' | grep 'channelId' > cache\/&/g" day/daydlnew > day/common sed -i '1s/.*/#\!\/bin\/bash\n&/g' day/common 2> /dev/null sed -i '/^$/d' day/common - printf "\n$(echo $(wc -l < day/common)) missing Broadastsfiles to be downloaded!\n\n" + printf "\n$(echo $(wc -l < day/common)) missing Broadcastsfiles to be downloaded!\n\n" bash day/common 2> /dev/null & wait find cache -size 0 | sed 's/cache\///g' >missingbroadcasts if [ -s missingbroadcasts ] @@ -372,7 +372,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/vdf_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > vodafone_channels sort -u vodafone_channels > /tmp/vodafone_channels && mv /tmp/vodafone_channels vodafone_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 20:06:47 +0200 Subject: [PATCH 07/23] waipu.tv: Add channel logos to XML file * also use UTF-8 for STDERR --- wpu/ch_json2xml.pl | 9 ++++++++- wpu/chlist_printer.pl | 1 + wpu/cid_json.pl | 1 + wpu/compare_menu.pl | 1 + wpu/epg_json2xml.pl | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/wpu/ch_json2xml.pl b/wpu/ch_json2xml.pl index 9be5e50..b2445af 100755 --- a/wpu/ch_json2xml.pl +++ b/wpu/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -99,6 +100,9 @@ # DEFINE CHANNEL ID + NAME my $cname = $channels->{'displayName'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE CHANNEL LOGO + my $logo = $channels->{'links'}[4]{'href'}; # DEFINE LANGUAGE VERSION my $languageVER = $initdata->{'language'}; @@ -137,7 +141,10 @@ } # CHANNEL NAME (language) - print " " . $cname . "\n\n"; + print " " . $cname . "\n"; + + # CHANNEL LOGO + print " \n\n" } } } diff --git a/wpu/chlist_printer.pl b/wpu/chlist_printer.pl index 611f52f..76da344 100755 --- a/wpu/chlist_printer.pl +++ b/wpu/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/wpu/cid_json.pl b/wpu/cid_json.pl index f391436..90e35d8 100755 --- a/wpu/cid_json.pl +++ b/wpu/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/wpu/compare_menu.pl b/wpu/compare_menu.pl index fe1de63..52c22e9 100755 --- a/wpu/compare_menu.pl +++ b/wpu/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/wpu/epg_json2xml.pl b/wpu/epg_json2xml.pl index fe5e7c6..e3ac2a0 100755 --- a/wpu/epg_json2xml.pl +++ b/wpu/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; From fb6c9e2480709d1124d6ccd9cf01216932793685 Mon Sep 17 00:00:00 2001 From: Jan-Luca Neumann Date: Sat, 5 Oct 2019 20:20:06 +0200 Subject: [PATCH 08/23] Zattoo: Add channel logos to XML file * also use UTF-8 for STDERR --- ztt/ch_json2xml.pl | 10 +++++++++- ztt/chlist_printer.pl | 1 + ztt/cid_json.pl | 1 + ztt/compare_crid.pl | 1 + ztt/compare_menu.pl | 1 + ztt/epg_json2xml.pl | 1 + ztt/ztt.sh | 2 +- 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ztt/ch_json2xml.pl b/ztt/ch_json2xml.pl index 87c5179..7d5ebde 100755 --- a/ztt/ch_json2xml.pl +++ b/ztt/ch_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; @@ -102,6 +103,10 @@ my $cname = $schedule->{'title'}; $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + # DEFINE CHANNEL LOGO + my $logo = $schedule->{'qualities'}[0]{'logo_black_84'}; + $logo =~ s/84x48.png/210x120.png/g; + # DEFINE LANGUAGE VERSION my $languageVER = $initdata->{'language'}; @@ -139,7 +144,10 @@ } # CHANNEL NAME (language) - print "" . $cname . "\n"; + print "" . $cname . ""; + + # CHANNEL LOGO + print "\n"; } } } diff --git a/ztt/chlist_printer.pl b/ztt/chlist_printer.pl index 6fca02a..dccc4cd 100755 --- a/ztt/chlist_printer.pl +++ b/ztt/chlist_printer.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/ztt/cid_json.pl b/ztt/cid_json.pl index 66a2c75..bbeeef1 100755 --- a/ztt/cid_json.pl +++ b/ztt/cid_json.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/ztt/compare_crid.pl b/ztt/compare_crid.pl index 6787ada..881af62 100755 --- a/ztt/compare_crid.pl +++ b/ztt/compare_crid.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/ztt/compare_menu.pl b/ztt/compare_menu.pl index 5255d03..4fda9ee 100755 --- a/ztt/compare_menu.pl +++ b/ztt/compare_menu.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/ztt/epg_json2xml.pl b/ztt/epg_json2xml.pl index 3af47d5..1e9ba22 100755 --- a/ztt/epg_json2xml.pl +++ b/ztt/epg_json2xml.pl @@ -29,6 +29,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; use JSON; diff --git a/ztt/ztt.sh b/ztt/ztt.sh index 3d9a6c7..db8cfae 100755 --- a/ztt/ztt.sh +++ b/ztt/ztt.sh @@ -1535,7 +1535,7 @@ curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/ztt_g printf "\rConverting CHANNEL JSON file into XML format... " perl ch_json2xml.pl 2>warnings.txt > zattoo_channels sort -u zattoo_channels > /tmp/zattoo_channels && mv /tmp/zattoo_channels zattoo_channels -sed -i 's/>\n\n Date: Sat, 5 Oct 2019 20:43:49 +0200 Subject: [PATCH 09/23] Add channel logos to combined XML files * also use UTF-8 for STDERR --- ch_combine.pl | 15 +++++++++++---- prog_combine.pl | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ch_combine.pl b/ch_combine.pl index ee581c4..c11337e 100755 --- a/ch_combine.pl +++ b/ch_combine.pl @@ -23,6 +23,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; # READ XML INPUT FILE @@ -50,6 +51,7 @@ # DEFINE XML RULES my @rules = ( 'display-name' => 'as is', + 'icon' => 'as is', 'channel' => 'as array no content' ); @@ -79,6 +81,7 @@ # DEFINE CHANNEL STRINGS my $channel_id = $channel->{id}; + my $ch_logo = $channel->{'icon'}->{'src'}; my $ch_lang = $channel->{'display-name'}->{lang}; my $ch_name = $channel->{'display-name'}->{_content}; @@ -88,11 +91,15 @@ if( $channel_id eq $configdata ) { - # CHANNEL ID + NAME + # CHANNEL ID + NAME + LOGO (condition) print "\n"; - print " " . $ch_name . "<\/display-name>\n<\/channel>\n"; - + print " " . $ch_name . "<\/display-name>\n"; + + if( defined $ch_logo ) { + print " \n\n"; + } else { + print "\n"; + } } - } } diff --git a/prog_combine.pl b/prog_combine.pl index c45ddba..ea8793c 100755 --- a/prog_combine.pl +++ b/prog_combine.pl @@ -23,6 +23,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; # READ XML INPUT FILE From 9875e6cc84321475fc6827aa39cd7042a22a04b5 Mon Sep 17 00:00:00 2001 From: Jan-Luca Neumann Date: Sun, 6 Oct 2019 17:14:01 +0200 Subject: [PATCH 10/23] Add option to backup / restore the main setup --- backup.sh | 643 ++++++++++++++++++++++++++++++++++++++++++++++++++ epg.sh | 97 +++++++- restore.sh | 670 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1406 insertions(+), 4 deletions(-) create mode 100644 backup.sh create mode 100644 restore.sh diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..07bf59c --- /dev/null +++ b/backup.sh @@ -0,0 +1,643 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ############### +# BACKUP SCRIPT # +# ############### + +# +# CHECK IF BACKUP ZIP ALREADY EXISTS +# + +if [ -e easyepg_backup.zip ] +then + printf "Backup ZIP already exists - overwrite file?\n\n[0] NO\n[X] YES\n" + read -n1 option + + if echo "$option" | grep -q "0" + then + printf " - STOP.\n\n" + exit 0 + else + rm easyepg_backup.zip + fi +fi + +# +# CREATE BACKUP FOLDER TO STORE THE FILES +# + +mkdir easyepg_backup 2> /dev/null +rm easyepg_backup/* 2> /dev/null + +# +# START BACKUP PROCESS +# + +printf "Starting BACKUP process...\n\n" + +# HORIZON DE + +if [ -e hzn/de ] +then + echo "Backing up: Horizon DE" + cp hzn/de/chlist_old easyepg_backup/hzn_de_chlist_old + cp hzn/de/channels.json easyepg_backup/hzn_de_channels.json + cp hzn/de/init.json easyepg_backup/hzn_de_init.json + cp hzn/de/settings.json easyepg_backup/hzn_de_settings.json +else + echo "Skipping backup: Horizon DE - no setup found" +fi + +# HORIZON AT + +if [ -e hzn/at ] +then + echo "Backing up: Horizon AT" + cp hzn/at/chlist_old easyepg_backup/hzn_at_chlist_old + cp hzn/at/channels.json easyepg_backup/hzn_at_channels.json + cp hzn/at/init.json easyepg_backup/hzn_at_init.json + cp hzn/at/settings.json easyepg_backup/hzn_at_settings.json +else + echo "Skipping backup: Horizon AT - no setup found" +fi + +# HORIZON CH + +if [ -e hzn/ch ] +then + echo "Backing up: Horizon CH" + cp hzn/ch/chlist_old easyepg_backup/hzn_ch_chlist_old + cp hzn/ch/channels.json easyepg_backup/hzn_ch_channels.json + cp hzn/ch/init.json easyepg_backup/hzn_ch_init.json + cp hzn/ch/settings.json easyepg_backup/hzn_ch_settings.json +else + echo "Skipping backup: Horizon CH - no setup found" +fi + +# HORIZON NL + +if [ -e hzn/nl ] +then + echo "Backing up: Horizon NL" + cp hzn/nl/chlist_old easyepg_backup/hzn_nl_chlist_old + cp hzn/nl/channels.json easyepg_backup/hzn_nl_channels.json + cp hzn/nl/init.json easyepg_backup/hzn_nl_init.json + cp hzn/nl/settings.json easyepg_backup/hzn_nl_settings.json +else + echo "Skipping backup: Horizon NL - no setup found" +fi + +# HORIZON PL + +if [ -e hzn/pl ] +then + echo "Backing up: Horizon PL" + cp hzn/pl/chlist_old easyepg_backup/hzn_pl_chlist_old + cp hzn/pl/channels.json easyepg_backup/hzn_pl_channels.json + cp hzn/pl/init.json easyepg_backup/hzn_pl_init.json + cp hzn/pl/settings.json easyepg_backup/hzn_pl_settings.json +else + echo "Skipping backup: Horizon PL - no setup found" +fi + +# HORIZON IE + +if [ -e hzn/ie ] +then + echo "Backing up: Horizon IE" + cp hzn/ie/chlist_old easyepg_backup/hzn_ie_chlist_old + cp hzn/ie/channels.json easyepg_backup/hzn_ie_channels.json + cp hzn/ie/init.json easyepg_backup/hzn_ie_init.json + cp hzn/ie/settings.json easyepg_backup/hzn_ie_settings.json +else + echo "Skipping backup: Horizon IE - no setup found" +fi + +# HORIZON SK + +if [ -e hzn/sk ] +then + echo "Backing up: Horizon SK" + cp hzn/sk/chlist_old easyepg_backup/hzn_sk_chlist_old + cp hzn/sk/channels.json easyepg_backup/hzn_sk_channels.json + cp hzn/sk/init.json easyepg_backup/hzn_sk_init.json + cp hzn/sk/settings.json easyepg_backup/hzn_sk_settings.json +else + echo "Skipping backup: Horizon SK - no setup found" +fi + +# HORIZON CZ + +if [ -e hzn/cz ] +then + echo "Backing up: Horizon CZ" + cp hzn/cz/chlist_old easyepg_backup/hzn_cz_chlist_old + cp hzn/cz/channels.json easyepg_backup/hzn_cz_channels.json + cp hzn/cz/init.json easyepg_backup/hzn_cz_init.json + cp hzn/cz/settings.json easyepg_backup/hzn_cz_settings.json +else + echo "Skipping backup: Horizon CZ - no setup found" +fi + +# HORIZON HU + +if [ -e hzn/hu ] +then + echo "Backing up: Horizon HU" + cp hzn/hu/chlist_old easyepg_backup/hzn_hu_chlist_old + cp hzn/hu/channels.json easyepg_backup/hzn_hu_channels.json + cp hzn/hu/init.json easyepg_backup/hzn_hu_init.json + cp hzn/hu/settings.json easyepg_backup/hzn_hu_settings.json +else + echo "Skipping backup: Horizon HU - no setup found" +fi + +# HORIZON RO + +if [ -e hzn/ro ] +then + echo "Backing up: Horizon RO" + cp hzn/ro/chlist_old easyepg_backup/hzn_ro_chlist_old + cp hzn/ro/channels.json easyepg_backup/hzn_ro_channels.json + cp hzn/ro/init.json easyepg_backup/hzn_ro_init.json + cp hzn/ro/settings.json easyepg_backup/hzn_ro_settings.json +else + echo "Skipping backup: Horizon RO - no setup found" +fi + +# ZATTOO DE + +if [ -e ztt/de ] +then + echo "Backing up: Zattoo DE" + cp ztt/de/user/userfile easyepg_backup/ztt_de_user_userfile + cp ztt/de/chlist_old easyepg_backup/ztt_de_chlist_old + cp ztt/de/channels.json easyepg_backup/ztt_de_channels.json + cp ztt/de/init.json easyepg_backup/ztt_de_init.json + cp ztt/de/settings.json easyepg_backup/ztt_de_settings.json +else + echo "Skipping backup: Zattoo DE - no setup found" +fi + +# ZATTOO CH + +if [ -e ztt/ch ] +then + echo "Backing up: Zattoo CH" + cp ztt/ch/user/userfile easyepg_backup/ztt_ch_user_userfile + cp ztt/ch/chlist_old easyepg_backup/ztt_ch_chlist_old + cp ztt/ch/channels.json easyepg_backup/ztt_ch_channels.json + cp ztt/ch/init.json easyepg_backup/ztt_ch_init.json + cp ztt/ch/settings.json easyepg_backup/ztt_ch_settings.json +else + echo "Skipping backup: Zattoo CH - no setup found" +fi + +# SWISSCOM CH + +if [ -e swc/ch ] +then + echo "Backing up: Swisscom CH" + cp swc/ch/chlist_old easyepg_backup/swc_ch_chlist_old + cp swc/ch/channels.json easyepg_backup/swc_ch_channels.json + cp swc/ch/init.json easyepg_backup/swc_ch_init.json + cp swc/ch/settings.json easyepg_backup/swc_ch_settings.json +else + echo "Skipping backup: Swisscom CH - no setup found" +fi + +# TVPLAYER UK + +if [ -e tvp/uk ] +then + echo "Backing up: tvPlayer UK" + cp tvp/uk/chlist_old easyepg_backup/tvp_uk_chlist_old + cp tvp/uk/channels.json easyepg_backup/tvp_uk_channels.json + cp tvp/uk/init.json easyepg_backup/tvp_uk_init.json + cp tvp/uk/settings.json easyepg_backup/tvp_uk_settings.json +else + echo "Skipping backup: tvPlayer UK - no setup found" +fi + +# MAGENTA TV DE + +if [ -e tkm/de ] +then + echo "Backing up: Magenta TV DE" + cp tkm/de/chlist_old easyepg_backup/tkm_de_chlist_old + cp tkm/de/channels.json easyepg_backup/tkm_de_channels.json + cp tkm/de/init.json easyepg_backup/tkm_de_init.json + cp tkm/de/settings.json easyepg_backup/tkm_de_settings.json +else + echo "Skipping backup: Magenta TV DE - no setup found" +fi + +# RADIOTIMES UK + +if [ -e rdt/uk ] +then + echo "Backing up: RadioTimes UK" + cp rdt/uk/chlist_old easyepg_backup/rdt_uk_chlist_old + cp rdt/uk/channels.json easyepg_backup/rdt_uk_channels.json + cp rdt/uk/init.json easyepg_backup/rdt_uk_init.json + cp rdt/uk/settings.json easyepg_backup/rdt_uk_settings.json +else + echo "Skipping backup: RadioTimes UK - no setup found" +fi + +# WAIPU.TV DE + +if [ -e wpu/de ] +then + echo "Backing up: waipu.tv DE" + cp wpu/de/user/userfile easyepg_backup/wpu_de_user_userfile + cp wpu/de/chlist_old easyepg_backup/wpu_de_chlist_old + cp wpu/de/channels.json easyepg_backup/wpu_de_channels.json + cp wpu/de/init.json easyepg_backup/wpu_de_init.json + cp wpu/de/settings.json easyepg_backup/wpu_de_settings.json +else + echo "Skipping backup: waipu.tv DE - no setup found" +fi + +# TV-SPIELFILM DE + +if [ -e tvs/de ] +then + echo "Backing up: TV-Spielfilm DE" + cp tvs/de/chlist_old easyepg_backup/tvs_de_chlist_old + cp tvs/de/channels.json easyepg_backup/tvs_de_channels.json + cp tvs/de/init.json easyepg_backup/tvs_de_init.json + cp tvs/de/settings.json easyepg_backup/tvs_de_settings.json +else + echo "Skipping backup: TV-Spielfilm DE - no setup found" +fi + +# VODAFONE DE + +if [ -e vdf/de ] +then + echo "Backing up: Vodafone DE" + cp vdf/de/chlist_old easyepg_backup/vdf_de_chlist_old + cp vdf/de/channels.json easyepg_backup/vdf_de_channels.json + cp vdf/de/init.json easyepg_backup/vdf_de_init.json + cp vdf/de/settings.json easyepg_backup/vdf_de_settings.json +else + echo "Skipping backup: Vodafone DE - no setup found" +fi + +# EXTERNAL 1 + +if [ -e ext/oa ] +then + echo "Backing up: External 1" + cp ext/oa/chlist_old easyepg_backup/ext_oa_chlist_old + cp ext/oa/channels.json easyepg_backup/ext_oa_channels.json + cp ext/oa/settings.json easyepg_backup/ext_oa_settings.json +else + echo "Skipping backup: External 1 - no setup found" +fi + +# EXTERNAL 2 + +if [ -e ext/ob ] +then + echo "Backing up: External 2" + cp ext/ob/chlist_old easyepg_backup/ext_ob_chlist_old + cp ext/ob/channels.json easyepg_backup/ext_ob_channels.json + cp ext/ob/settings.json easyepg_backup/ext_ob_settings.json +else + echo "Skipping backup: External 2 - no setup found" +fi + +# EXTERNAL 3 + +if [ -e ext/oc ] +then + echo "Backing up: External 3" + cp ext/oc/chlist_old easyepg_backup/ext_oc_chlist_old + cp ext/oc/channels.json easyepg_backup/ext_oc_channels.json + cp ext/oc/settings.json easyepg_backup/ext_oc_settings.json +else + echo "Skipping backup: External 3 - no setup found" +fi + +# +# BACKUP XML FILES FOR COMBINED SETUP +# + +printf "\nBacking up provider XML files...\n\n" + +# HORIZON DE + +if [ -e xml/horizon_de.xml ] +then + echo "Backing up XML: Horizon DE" + cp xml/horizon_de.xml easyepg_backup/xml_hzn_de.xml +else + echo "Skipping backup: Horizon DE - XML file not found" +fi + +# HORIZON AT + +if [ -e xml/horizon_at.xml ] +then + echo "Backing up XML: Horizon AT" + cp xml/horizon_at.xml easyepg_backup/xml_hzn_at.xml +else + echo "Skipping backup: Horizon AT - XML file not found" +fi + +# HORIZON CH + +if [ -e xml/horizon_ch.xml ] +then + echo "Backing up XML: Horizon CH" + cp xml/horizon_ch.xml easyepg_backup/xml_hzn_ch.xml +else + echo "Skipping backup: Horizon CH - XML file not found" +fi + +# HORIZON NL + +if [ -e xml/horizon_nl.xml ] +then + echo "Backing up XML: Horizon NL" + cp xml/horizon_nl.xml easyepg_backup/xml_hzn_nl.xml +else + echo "Skipping backup: Horizon NL - XML file not found" +fi + +# HORIZON PL + +if [ -e xml/horizon_pl.xml ] +then + echo "Backing up XML: Horizon PL" + cp xml/horizon_pl.xml easyepg_backup/xml_hzn_pl.xml +else + echo "Skipping backup: Horizon PL - XML file not found" +fi + +# HORIZON IE + +if [ -e xml/horizon_ie.xml ] +then + echo "Backing up XML: Horizon IE" + cp xml/horizon_ie.xml easyepg_backup/xml_hzn_ie.xml +else + echo "Skipping backup: Horizon IE - XML file not found" +fi + +# HORIZON SK + +if [ -e xml/horizon_sk.xml ] +then + echo "Backing up XML: Horizon SK" + cp xml/horizon_sk.xml easyepg_backup/xml_hzn_sk.xml +else + echo "Skipping backup: Horizon SK - XML file not found" +fi + +# HORIZON CZ + +if [ -e xml/horizon_cz.xml ] +then + echo "Backing up XML: Horizon CZ" + cp xml/horizon_cz.xml easyepg_backup/xml_hzn_cz.xml +else + echo "Skipping backup: Horizon CZ - XML file not found" +fi + +# HORIZON HU + +if [ -e xml/horizon_hu.xml ] +then + echo "Backing up XML: Horizon HU" + cp xml/horizon_hu.xml easyepg_backup/xml_hzn_hu.xml +else + echo "Skipping backup: Horizon HU - XML file not found" +fi + +# HORIZON RO + +if [ -e xml/horizon_ro.xml ] +then + echo "Backing up XML: Horizon RO" + cp xml/horizon_ro.xml easyepg_backup/xml_hzn_ro.xml +else + echo "Skipping backup: Horizon RO - XML file not found" +fi + +# ZATTOO DE + +if [ -e xml/zattoo_de.xml ] +then + echo "Backing up XML: Zattoo DE" + cp xml/zattoo_de.xml easyepg_backup/xml_ztt_de.xml +else + echo "Skipping backup: Zattoo DE - XML file not found" +fi + +# ZATTOO CH + +if [ -e xml/zattoo_ch.xml ] +then + echo "Backing up XML: Zattoo CH" + cp xml/zattoo_ch.xml easyepg_backup/xml_ztt_ch.xml +else + echo "Skipping backup: Zattoo CH - XML file not found" +fi + +# SWISSCOM CH + +if [ -e xml/swisscom_ch.xml ] +then + echo "Backing up XML: Swisscom CH" + cp xml/swisscom_ch.xml easyepg_backup/xml_swc_ch.xml +else + echo "Skipping backup: Swisscom CH - XML file not found" +fi + +# TVPLAYER UK + +if [ -e xml/tvp_uk.xml ] +then + echo "Backing up XML: tvPlayer UK" + cp xml/tvp_uk.xml easyepg_backup/xml_tvp_uk.xml +else + echo "Skipping backup: tvPlayer UK - XML file not found" +fi + +# MAGENTA TV DE + +if [ -e xml/magentatv_de.xml ] +then + echo "Backing up XML: Magenta TV DE" + cp xml/magentatv_de.xml easyepg_backup/xml_tkm_de.xml +else + echo "Skipping backup: Magenta TV DE - XML file not found" +fi + +# RADIOTIMES UK + +if [ -e xml/radiotimes_uk.xml ] +then + echo "Backing up XML: RadioTimes UK" + cp xml/radiotimes_uk.xml easyepg_backup/xml_rdt_uk.xml +else + echo "Skipping backup: RadioTimes UK - XML file not found" +fi + +# WAIPU.TV DE + +if [ -e xml/waipu_de.xml ] +then + echo "Backing up XML: waipu.tv DE" + cp xml/waipu_de.xml easyepg_backup/xml_wpu_de.xml +else + echo "Skipping backup: waipu.tv DE - XML file not found" +fi + +# TV-SPIELFILM DE + +if [ -e xml/tv-spielfilm_de.xml ] +then + echo "Backing up XML: TV-Spielfilm DE" + cp xml/tv-spielfilm_de.xml easyepg_backup/xml_tvs_de.xml +else + echo "Skipping backup: TV-Spielfilm DE - XML file not found" +fi + +# VODAFONE DE + +if [ -e xml/vodafone_de.xml ] +then + echo "Backing up XML: Vodafone DE" + cp xml/vodafone_de.xml easyepg_backup/xml_vdf_de.xml +else + echo "Skipping backup: Vodafone DE - XML file not found" +fi + +# EXTERNAL 1 + +if [ -e xml/external_oa.xml ] +then + echo "Backing up XML: External 1" + cp xml/external_oa.xml easyepg_backup/xml_ext_oa.xml +else + echo "Skipping backup: External 1 - XML file not found" +fi + +# EXTERNAL 2 + +if [ -e xml/external_ob.xml ] +then + echo "Backing up XML: External 2" + cp xml/external_ob.xml easyepg_backup/xml_ext_ob.xml +else + echo "Skipping backup: External 2 - XML file not found" +fi + +# EXTERNAL 3 + +if [ -e xml/external_oc.xml ] +then + echo "Backing up XML: External 3" + cp xml/external_oc.xml easyepg_backup/xml_ext_oc.xml +else + echo "Skipping backup: External 3 - XML file not found" +fi + + +# +# BACKUP SETUP FILES FOR COMBINED XML +# + +printf "\nBacking up combined XML setups...\n\n" + +# CREATING LIST + +ls combine > /tmp/combine_list 2> /dev/null + +if [ ! -s /tmp/combine_list ] +then + echo "Skipping backup: No combined XML setups found" +fi + +while [ -s /tmp/combine_list ] +do + folder=$(sed -n "1p" /tmp/combine_list) + echo "Backing up files for $folder..." + + cp combine/$folder/settings.json easyepg_backup/combine_$folder-settings.json 2> /dev/null + cp combine/$folder/pre_setup.sh easyepg_backup/combine_$folder-pre_setup.sh 2> /dev/null + cp combine/$folder/setup.sh easyepg_backup/combine_$folder-setup.sh 2> /dev/null + cp xml/$folder.xml easyepg_backup/combine_$folder.xml 2> /dev/null + + if [ -e combine/$folder/run.pl ] + then + printf "\nCAUTION: IMDB Mapper will NOT be saved - please re-enable the mapper in settings after restoring $folder!\n" + fi + + if [ -e combine/$folder/ratingmapper.pl ] + then + printf "\nCAUTION: Ratingmapper will NOT be saved - please re-enable the mapper in settings after restoring $folder!\n" + fi + + cp combine/$folder/hzn_de_channels.json easyepg_backup/combine_$folder-hzn_de_channels.json 2> /dev/null + cp combine/$folder/hzn_at_channels.json easyepg_backup/combine_$folder-hzn_at_channels.json 2> /dev/null + cp combine/$folder/hzn_ch_channels.json easyepg_backup/combine_$folder-hzn_ch_channels.json 2> /dev/null + cp combine/$folder/hzn_nl_channels.json easyepg_backup/combine_$folder-hzn_nl_channels.json 2> /dev/null + cp combine/$folder/hzn_pl_channels.json easyepg_backup/combine_$folder-hzn_pl_channels.json 2> /dev/null + cp combine/$folder/hzn_ie_channels.json easyepg_backup/combine_$folder-hzn_ie_channels.json 2> /dev/null + cp combine/$folder/hzn_sk_channels.json easyepg_backup/combine_$folder-hzn_sk_channels.json 2> /dev/null + cp combine/$folder/hzn_cz_channels.json easyepg_backup/combine_$folder-hzn_cz_channels.json 2> /dev/null + cp combine/$folder/hzn_hu_channels.json easyepg_backup/combine_$folder-hzn_hu_channels.json 2> /dev/null + cp combine/$folder/hzn_ro_channels.json easyepg_backup/combine_$folder-hzn_ro_channels.json 2> /dev/null + cp combine/$folder/ztt_de_channels.json easyepg_backup/combine_$folder-ztt_de_channels.json 2> /dev/null + cp combine/$folder/ztt_ch_channels.json easyepg_backup/combine_$folder-ztt_ch_channels.json 2> /dev/null + cp combine/$folder/swc_ch_channels.json easyepg_backup/combine_$folder-swc_ch_channels.json 2> /dev/null + cp combine/$folder/tvp_uk_channels.json easyepg_backup/combine_$folder-tvp_uk_channels.json 2> /dev/null + cp combine/$folder/tkm_de_channels.json easyepg_backup/combine_$folder-tkm_de_channels.json 2> /dev/null + cp combine/$folder/rdt_uk_channels.json easyepg_backup/combine_$folder-rdt_uk_channels.json 2> /dev/null + cp combine/$folder/wpu_de_channels.json easyepg_backup/combine_$folder-wpu_de_channels.json 2> /dev/null + cp combine/$folder/tvs_de_channels.json easyepg_backup/combine_$folder-tvs_de_channels.json 2> /dev/null + cp combine/$folder/vdf_de_channels.json easyepg_backup/combine_$folder-vdf_de_channels.json 2> /dev/null + cp combine/$folder/ext_oa_channels.json easyepg_backup/combine_$folder-ext_oa_channels.json 2> /dev/null + cp combine/$folder/ext_ob_channels.json easyepg_backup/combine_$folder-ext_ob_channels.json 2> /dev/null + cp combine/$folder/ext_oc_channels.json easyepg_backup/combine_$folder-ext_oc_channels.json 2> /dev/null + + sed -i '1d' /tmp/combine_list +done + +rm /tmp/combine_list 2> /dev/null + + +# +# COMPRESS BACKUP FOLDER +# + +printf "\nCompressing backup folder...\n\n" + +zip easyepg_backup.zip easyepg_backup/* +rm -rf easyepg_backup 2> /dev/null + +printf "\nDONE!\n\n" diff --git a/epg.sh b/epg.sh index 0f48a06..a4e50f9 100755 --- a/epg.sh +++ b/epg.sh @@ -710,8 +710,11 @@ do # M1500 UPDATE echo ' 5 "UPDATE THIS SCRIPT" \' >> /tmp/menu - # M1600 ABOUT - echo ' 6 "ABOUT EASYEPG" \' >> /tmp/menu + # M1600 BACKUP/RESTORE + echo ' 6 "BACKUP / RESTORE" \' >> /tmp/menu + + # M1900 ABOUT + echo ' 9 "ABOUT EASYEPG" \' >> /tmp/menu echo "2> /tmp/value" >> /tmp/menu @@ -2808,12 +2811,98 @@ do # ########################### - # M1600 ABOUT THIS PROJECT # + # M1600 BACKUP / RESTORE # # ########################### elif grep -q "6" /tmp/value then - dialog --backtitle "[M1600] EASYEPG SIMPLE XMLTV GRABBER > ABOUT" --title "ABOUT THE EASYEPG PROJECT" --msgbox "easyEPG Grabber\n(c) 2019 Jan-Luca Neumann / sunsettrack4\nhttps://github.com/sunsettrack4\n\nLicensed under GPL v3.0 - All rights reserved.\n\n* This tool provides high-quality EPG data from different IPTV/OTT sources.\n* It allows you to combine multiple sources for XMLTV file creation.\n* Missing data can be added by using the IMDB mapper tool.\n* Furthermore, you can import XML files from external sources.\n\nSpecial thanks:\n- DeBaschdi - https://github.com/debaschdi (for collaboration)" 19 70 + # M1610 MENU OVERLAY + echo 'dialog --backtitle "[M1610] EASYEPG SIMPLE XMLTV GRABBER > BACKUP/RESTORE" --title "OPTIONS" --menu "Please select the desired action:" 9 40 10 \' > /tmp/menu + + # M1611 BACKUP + ls -l hzn/ > /tmp/providerlist + ls -l ztt/ >> /tmp/providerlist + ls -l swc/ >> /tmp/providerlist + ls -l tvp/ >> /tmp/providerlist + ls -l tkm/ >> /tmp/providerlist + ls -l rdt/ >> /tmp/providerlist + ls -l wpu/ >> /tmp/providerlist + ls -l tvs/ >> /tmp/providerlist + ls -l vdf/ >> /tmp/providerlist + ls -l ext/ >> /tmp/providerlist + if grep -q '^d' /tmp/providerlist 2> /dev/null + then + echo ' 1 "BACKUP SETUP" \' >> /tmp/menu + fi + + # M1612 RESTORE + if [ -e easyepg_backup.zip ] + then + echo ' 2 "RESTORE SETUP" \' >> /tmp/menu + fi + + echo "2> /tmp/value" >> /tmp/menu + + bash /tmp/menu + input="$(cat /tmp/value)" + + + # ######################## + # M1611 BACKUP SETUP # + # ######################## + + if grep -q "1" /tmp/value + then + clear + echo "" + echo " --------------------------------------------" + echo " BACKUP SERVICE " + echo " easyEPG Grabber $(grep 'VER=' /tmp/initrun.txt | sed 's/VER=//g')" + echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " + echo " --------------------------------------------" + echo "" + sleep 2s + bash backup.sh + read -n 1 -s -r -p "Press any key to continue..." + echo "M" > /tmp/value + + + # ######################## + # M1612 RESTORE SETUP # + # ######################## + + elif grep -q "2" /tmp/value + then + clear + echo "" + echo " --------------------------------------------" + echo " RESTORE SERVICE " + echo " easyEPG Grabber $(grep 'VER=' /tmp/initrun.txt | sed 's/VER=//g')" + echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " + echo " --------------------------------------------" + echo "" + sleep 2s + bash restore.sh + read -n 1 -s -r -p "Press any key to continue..." + echo "M" > /tmp/value + + + # ############ + # M16X0 EXIT # + # ############ + + else + echo "M" > /tmp/value + fi + + + # ########################### + # M1900 ABOUT THIS PROJECT # + # ########################### + + elif grep -q "9" /tmp/value + then + dialog --backtitle "[M1900] EASYEPG SIMPLE XMLTV GRABBER > ABOUT" --title "ABOUT THE EASYEPG PROJECT" --msgbox "easyEPG Grabber\n(c) 2019 Jan-Luca Neumann / sunsettrack4\nhttps://github.com/sunsettrack4\n\nLicensed under GPL v3.0 - All rights reserved.\n\n* This tool provides high-quality EPG data from different IPTV/OTT sources.\n* It allows you to combine multiple sources for XMLTV file creation.\n* Missing data can be added by using the IMDB mapper tool.\n* Furthermore, you can import XML files from external sources.\n\nSpecial thanks:\n- DeBaschdi - https://github.com/debaschdi (for collaboration)" 19 70 echo "M" > /tmp/value # ############ diff --git a/restore.sh b/restore.sh new file mode 100644 index 0000000..bba89c8 --- /dev/null +++ b/restore.sh @@ -0,0 +1,670 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ################ +# RESTORE SCRIPT # +# ################ + +# +# CHECK IF BACKUP ZIP ALREADY EXISTS +# + +if [ ! -e easyepg_backup.zip ] +then + printf "Backup ZIP does not exist! - STOP.\n\n" + exit 0 +fi + + +# +# DECOMPRESS ZIP +# + +printf "Decompressing ZIP file...\n\n" + +rm -rf easyepg_backup 2> /dev/null +unzip easyepg_backup.zip -d easyepg_backup + +if [ -e easyepg_backup/easyepg_backup ] +then + rm easyepg_backup/* 2> /dev/null + cp easyepg_backup/easyepg_backup/* easyepg_backup/ + rm -rf easyepg_backup/easyepg_backup +else + printf "Backup ZIP does not provide expected data files! - STOP.\n" + exit 0 +fi + + +# +# START RESTORE PROCESS: PROVIDER SETUPS + XML FILES +# + +printf "\nStarting RESTORE process...\n\n" + +mkdir xml 2> /dev/null + +# HORIZON DE + +if [ -e easyepg_backup/hzn_de_init.json ] +then + echo "Restoring: Horizon DE" + mkdir hzn/de 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/de/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/de/chlist_printer.pl + cp hzn/cid_json.pl hzn/de/cid_json.pl + cp hzn/compare_menu.pl hzn/de/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/de/epg_json2xml.pl + cp hzn/hzn.sh hzn/de/hzn.sh + cp hzn/settings.sh hzn/de/settings.sh + sed 's/XX/DE/g;s/YYY/deu/g' hzn/url_printer.pl > hzn/de/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_de_init.json hzn/de/init.json + cp easyepg_backup/hzn_de_chlist_old hzn/de/chlist_old + cp easyepg_backup/hzn_de_channels.json hzn/de/channels.json + cp easyepg_backup/hzn_de_settings.json hzn/de/settings.json + cp easyepg_backup/xml_hzn_de.xml xml/horizon_de.xml 2> /dev/null +else + echo "Skipping restore: Horizon DE - no setup found" +fi + +# HORIZON AT + +if [ -e easyepg_backup/hzn_at_init.json ] +then + echo "Restoring: Horizon AT" + mkdir hzn/at 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/at/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/at/chlist_printer.pl + cp hzn/cid_json.pl hzn/at/cid_json.pl + cp hzn/compare_menu.pl hzn/at/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/at/epg_json2xml.pl + cp hzn/hzn.sh hzn/at/hzn.sh + cp hzn/settings.sh hzn/at/settings.sh + sed 's/XX/AT/g;s/YYY/deu/g' hzn/url_printer.pl > hzn/at/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_at_init.json hzn/at/init.json + cp easyepg_backup/hzn_at_chlist_old hzn/at/chlist_old + cp easyepg_backup/hzn_at_channels.json hzn/at/channels.json + cp easyepg_backup/hzn_at_settings.json hzn/at/settings.json + cp easyepg_backup/xml_hzn_at.xml xml/horizon_at.xml 2> /dev/null +else + echo "Skipping restore: Horizon AT - no setup found" +fi + +# HORIZON CH + +if [ -e easyepg_backup/hzn_ch_init.json ] +then + echo "Restoring: Horizon CH" + mkdir hzn/ch 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/ch/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/ch/chlist_printer.pl + cp hzn/cid_json.pl hzn/ch/cid_json.pl + cp hzn/compare_menu.pl hzn/ch/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/ch/epg_json2xml.pl + cp hzn/hzn.sh hzn/ch/hzn.sh + cp hzn/settings.sh hzn/ch/settings.sh + sed 's/XX/CH/g;s/YYY/deu/g' hzn/url_printer.pl > hzn/ch/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_ch_init.json hzn/ch/init.json + cp easyepg_backup/hzn_ch_chlist_old hzn/ch/chlist_old + cp easyepg_backup/hzn_ch_channels.json hzn/ch/channels.json + cp easyepg_backup/hzn_ch_settings.json hzn/ch/settings.json + cp easyepg_backup/xml_hzn_ch.xml xml/horizon_ch.xml 2> /dev/null +else + echo "Skipping restore: Horizon CH - no setup found" +fi + +# HORIZON NL + +if [ -e easyepg_backup/hzn_nl_init.json ] +then + echo "Restoring: Horizon NL" + mkdir hzn/nl 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/nl/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/nl/chlist_printer.pl + cp hzn/cid_json.pl hzn/nl/cid_json.pl + cp hzn/compare_menu.pl hzn/nl/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/nl/epg_json2xml.pl + cp hzn/hzn.sh hzn/nl/hzn.sh + cp hzn/settings.sh hzn/nl/settings.sh + sed 's/XX/NL/g;s/YYY/nld/g' hzn/url_printer.pl > hzn/nl/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_nl_init.json hzn/nl/init.json + cp easyepg_backup/hzn_nl_chlist_old hzn/nl/chlist_old + cp easyepg_backup/hzn_nl_channels.json hzn/nl/channels.json + cp easyepg_backup/hzn_nl_settings.json hzn/nl/settings.json + cp easyepg_backup/xml_hzn_nl.xml xml/horizon_nl.xml 2> /dev/null +else + echo "Skipping restore: Horizon NL - no setup found" +fi + +# HORIZON PL + +if [ -e easyepg_backup/hzn_pl_init.json ] +then + echo "Restoring: Horizon PL" + mkdir hzn/pl 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/pl/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/pl/chlist_printer.pl + cp hzn/cid_json.pl hzn/pl/cid_json.pl + cp hzn/compare_menu.pl hzn/pl/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/pl/epg_json2xml.pl + cp hzn/hzn.sh hzn/pl/hzn.sh + cp hzn/settings.sh hzn/pl/settings.sh + sed 's/XX/PL/g;s/YYY/pol/g' hzn/url_printer.pl > hzn/pl/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_pl_init.json hzn/pl/init.json + cp easyepg_backup/hzn_pl_chlist_old hzn/pl/chlist_old + cp easyepg_backup/hzn_pl_channels.json hzn/pl/channels.json + cp easyepg_backup/hzn_pl_settings.json hzn/pl/settings.json + cp easyepg_backup/xml_hzn_pl.xml xml/horizon_pl.xml 2> /dev/null +else + echo "Skipping restore: Horizon PL - no setup found" +fi + +# HORIZON IE + +if [ -e easyepg_backup/hzn_ie_init.json ] +then + echo "Restoring: Horizon IE" + mkdir hzn/ie 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/ie/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/ie/chlist_printer.pl + cp hzn/cid_json.pl hzn/ie/cid_json.pl + cp hzn/compare_menu.pl hzn/ie/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/ie/epg_json2xml.pl + cp hzn/hzn.sh hzn/ie/hzn.sh + cp hzn/settings.sh hzn/ie/settings.sh + sed 's/XX/IE/g;s/YYY/eng/g' hzn/url_printer.pl > hzn/ie/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_ie_init.json hzn/ie/init.json + cp easyepg_backup/hzn_ie_chlist_old hzn/ie/chlist_old + cp easyepg_backup/hzn_ie_channels.json hzn/ie/channels.json + cp easyepg_backup/hzn_ie_settings.json hzn/ie/settings.json + cp easyepg_backup/xml_hzn_ie.xml xml/horizon_ie.xml 2> /dev/null +else + echo "Skipping restore: Horizon IE - no setup found" +fi + +# HORIZON SK + +if [ -e easyepg_backup/hzn_sk_init.json ] +then + echo "Restoring: Horizon SK" + mkdir hzn/sk 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/sk/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/sk/chlist_printer.pl + cp hzn/cid_json.pl hzn/sk/cid_json.pl + cp hzn/compare_menu.pl hzn/sk/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/sk/epg_json2xml.pl + cp hzn/hzn.sh hzn/sk/hzn.sh + cp hzn/settings.sh hzn/sk/settings.sh + sed 's/XX/SK/g;s/YYY/slk/g' hzn/url_printer.pl > hzn/sk/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_sk_init.json hzn/sk/init.json + cp easyepg_backup/hzn_sk_chlist_old hzn/sk/chlist_old + cp easyepg_backup/hzn_sk_channels.json hzn/sk/channels.json + cp easyepg_backup/hzn_sk_settings.json hzn/sk/settings.json + cp easyepg_backup/xml_hzn_sk.xml xml/horizon_sk.xml 2> /dev/null +else + echo "Skipping restore: Horizon SK - no setup found" +fi + +# HORIZON CZ + +if [ -e easyepg_backup/hzn_cz_init.json ] +then + echo "Restoring: Horizon CZ" + mkdir hzn/cz 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/cz/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/cz/chlist_printer.pl + cp hzn/cid_json.pl hzn/cz/cid_json.pl + cp hzn/compare_menu.pl hzn/cz/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/cz/epg_json2xml.pl + cp hzn/hzn.sh hzn/cz/hzn.sh + cp hzn/settings.sh hzn/cz/settings.sh + sed 's/XX/CZ/g;s/YYY/ces/g' hzn/url_printer.pl > hzn/cz/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_cz_init.json hzn/cz/init.json + cp easyepg_backup/hzn_cz_chlist_old hzn/cz/chlist_old + cp easyepg_backup/hzn_cz_channels.json hzn/cz/channels.json + cp easyepg_backup/hzn_cz_settings.json hzn/cz/settings.json + cp easyepg_backup/xml_hzn_cz.xml xml/horizon_cz.xml 2> /dev/null +else + echo "Skipping restore: Horizon CZ - no setup found" +fi + +# HORIZON HU + +if [ -e easyepg_backup/hzn_cz_init.json ] +then + echo "Restoring: Horizon HU" + mkdir hzn/hu 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/hu/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/hu/chlist_printer.pl + cp hzn/cid_json.pl hzn/hu/cid_json.pl + cp hzn/compare_menu.pl hzn/hu/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/hu/epg_json2xml.pl + cp hzn/hzn.sh hzn/hu/hzn.sh + cp hzn/settings.sh hzn/hu/settings.sh + sed 's/XX/HU/g;s/YYY/hun/g' hzn/url_printer.pl > hzn/hu/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_hu_init.json hzn/hu/init.json + cp easyepg_backup/hzn_hu_chlist_old hzn/hu/chlist_old + cp easyepg_backup/hzn_hu_channels.json hzn/hu/channels.json + cp easyepg_backup/hzn_hu_settings.json hzn/hu/settings.json + cp easyepg_backup/xml_hzn_hu.xml xml/horizon_hu.xml 2> /dev/null +else + echo "Skipping restore: Horizon HU - no setup found" +fi + +# HORIZON RO + +if [ -e easyepg_backup/hzn_cz_init.json ] +then + echo "Restoring: Horizon RO" + mkdir hzn/ro 2> /dev/null + + cp hzn/ch_json2xml.pl hzn/ro/ch_json2xml.pl + cp hzn/chlist_printer.pl hzn/ro/chlist_printer.pl + cp hzn/cid_json.pl hzn/ro/cid_json.pl + cp hzn/compare_menu.pl hzn/ro/compare_menu.pl + cp hzn/epg_json2xml.pl hzn/ro/epg_json2xml.pl + cp hzn/hzn.sh hzn/ro/hzn.sh + cp hzn/settings.sh hzn/ro/settings.sh + sed 's/XX/RO/g;s/YYY/ron/g' hzn/url_printer.pl > hzn/ro/url_printer.pl 2> /dev/null + + cp easyepg_backup/hzn_ro_init.json hzn/ro/init.json + cp easyepg_backup/hzn_ro_chlist_old hzn/ro/chlist_old + cp easyepg_backup/hzn_ro_channels.json hzn/ro/channels.json + cp easyepg_backup/hzn_ro_settings.json hzn/ro/settings.json + cp easyepg_backup/xml_hzn_ro.xml xml/horizon_ro.xml 2> /dev/null +else + echo "Skipping restore: Horizon RO - no setup found" +fi + +# ZATTOO DE + +if [ -e easyepg_backup/ztt_de_init.json ] +then + echo "Restoring: Zattoo DE" + mkdir ztt/de 2> /dev/null + mkdir ztt/de/user 2> /dev/null + + cp ztt/ch_json2xml.pl ztt/de/ch_json2xml.pl + cp ztt/chlist_printer.pl ztt/de/chlist_printer.pl + cp ztt/cid_json.pl ztt/de/cid_json.pl + cp ztt/compare_crid.pl ztt/de/compare_crid.pl + cp ztt/compare_menu.pl ztt/de/compare_menu.pl + cp ztt/epg_json2xml.pl ztt/de/epg_json2xml.pl + cp ztt/ztt.sh ztt/de/ztt.sh + cp ztt/save_page.js ztt/de/save_page.js + sed 's/\[XX\]/[DE]/g;s/XXXX/DE/g' ztt/settings.sh > ztt/de/settings.sh 2> /dev/null + + cp easyepg_backup/ztt_de_init.json ztt/de/init.json + cp easyepg_backup/ztt_de_chlist_old ztt/de/chlist_old + cp easyepg_backup/ztt_de_channels.json ztt/de/channels.json + cp easyepg_backup/ztt_de_settings.json ztt/de/settings.json + cp easyepg_backup/ztt_de_user_userfile ztt/de/user/userfile + cp easyepg_backup/xml_ztt_de.xml xml/zattoo_de.xml 2> /dev/null +else + echo "Skipping restore: Zattoo DE - no setup found" +fi + +# ZATTOO CH + +if [ -e easyepg_backup/ztt_ch_init.json ] +then + echo "Restoring: Zattoo CH" + mkdir ztt/ch 2> /dev/null + mkdir ztt/ch/user 2> /dev/null + + cp ztt/ch_json2xml.pl ztt/ch/ch_json2xml.pl + cp ztt/chlist_printer.pl ztt/ch/chlist_printer.pl + cp ztt/cid_json.pl ztt/ch/cid_json.pl + cp ztt/compare_crid.pl ztt/ch/compare_crid.pl + cp ztt/compare_menu.pl ztt/ch/compare_menu.pl + cp ztt/epg_json2xml.pl ztt/ch/epg_json2xml.pl + cp ztt/ztt.sh ztt/ch/ztt.sh + cp ztt/save_page.js ztt/ch/save_page.js + sed 's/\[XX\]/[CH]/g;s/XXXX/CH/g' ztt/settings.sh > ztt/ch/settings.sh 2> /dev/null + + cp easyepg_backup/ztt_ch_init.json ztt/ch/init.json + cp easyepg_backup/ztt_ch_chlist_old ztt/ch/chlist_old + cp easyepg_backup/ztt_ch_channels.json ztt/ch/channels.json + cp easyepg_backup/ztt_ch_settings.json ztt/ch/settings.json + cp easyepg_backup/ztt_ch_user_userfile ztt/ch/user/userfile + cp easyepg_backup/xml_ztt_ch.xml xml/zattoo_ch.xml 2> /dev/null +else + echo "Skipping restore: Zattoo CH - no setup found" +fi + +# SWISSCOM CH + +if [ -e easyepg_backup/swc_ch_init.json ] +then + echo "Restoring: Swisscom CH" + mkdir swc/ch 2> /dev/null + + cp swc/ch_json2xml.pl swc/ch/ch_json2xml.pl + cp swc/chlist_printer.pl swc/ch/chlist_printer.pl + cp swc/cid_json.pl swc/ch/cid_json.pl + cp swc/compare_menu.pl swc/ch/compare_menu.pl + cp swc/epg_json2xml.pl swc/ch/epg_json2xml.pl + cp swc/swc.sh swc/ch/swc.sh + cp swc/settings.sh swc/ch/settings.sh + cp swc/url_printer.pl swc/ch/url_printer.pl + + cp easyepg_backup/swc_ch_init.json swc/ch/init.json + cp easyepg_backup/swc_ch_chlist_old swc/ch/chlist_old + cp easyepg_backup/swc_ch_channels.json swc/ch/channels.json + cp easyepg_backup/swc_ch_settings.json swc/ch/settings.json + cp easyepg_backup/xml_swc_ch.xml xml/swisscom_ch.xml 2> /dev/null +else + echo "Skipping restore: Swisscom CH - no setup found" +fi + +# TVPLAYER UK + +if [ -e easyepg_backup/tvp_uk_init.json ] +then + echo "Restoring: tvPlayer UK" + mkdir tvp/uk 2> /dev/null + + cp tvp/ch_json2xml.pl tvp/uk/ch_json2xml.pl + cp tvp/chlist_printer.pl tvp/uk/chlist_printer.pl + cp tvp/cid_json.pl tvp/uk/cid_json.pl + cp tvp/compare_crid.pl tvp/uk/compare_crid.pl + cp tvp/compare_menu.pl tvp/uk/compare_menu.pl + cp tvp/epg_json2xml.pl tvp/uk/epg_json2xml.pl + cp tvp/tvp.sh tvp/uk/tvp.sh + cp tvp/settings.sh tvp/uk/settings.sh + + cp easyepg_backup/tvp_uk_init.json tvp/uk/init.json + cp easyepg_backup/tvp_uk_chlist_old tvp/uk/chlist_old + cp easyepg_backup/tvp_uk_channels.json tvp/uk/channels.json + cp easyepg_backup/tvp_uk_settings.json tvp/uk/settings.json + cp easyepg_backup/xml_tvp_uk.xml xml/tvp_uk.xml 2> /dev/null +else + echo "Skipping restore: tvPlayer UK - no setup found" +fi + +# MAGENTA TV DE + +if [ -e easyepg_backup/tkm_de_init.json ] +then + echo "Restoring: Magenta TV DE" + mkdir tkm/de 2> /dev/null + + cp tkm/ch_json2xml.pl tkm/de/ch_json2xml.pl + cp tkm/chlist_printer.pl tkm/de/chlist_printer.pl + cp tkm/cid_json.pl tkm/de/cid_json.pl + cp tkm/compare_menu.pl tkm/de/compare_menu.pl + cp tkm/epg_json2xml.pl tkm/de/epg_json2xml.pl + cp tkm/tkm.sh tkm/de/tkm.sh + cp tkm/settings.sh tkm/de/settings.sh + cp tkm/url_printer.pl tkm/de/url_printer.pl + + cp easyepg_backup/tkm_de_init.json tkm/de/init.json + cp easyepg_backup/tkm_de_chlist_old tkm/de/chlist_old + cp easyepg_backup/tkm_de_channels.json tkm/de/channels.json + cp easyepg_backup/tkm_de_settings.json tkm/de/settings.json + cp easyepg_backup/xml_tkm_de.xml xml/magentatv_de.xml 2> /dev/null +else + echo "Skipping restore: Magenta TV DE - no setup found" +fi + +# RADIOTIMES UK + +if [ -e easyepg_backup/rdt_uk_init.json ] +then + echo "Restoring: RadioTimes UK" + mkdir rdt/uk 2> /dev/null + + cp rdt/ch_json2xml.pl rdt/uk/ch_json2xml.pl + cp rdt/chlist_printer.pl rdt/uk/chlist_printer.pl + cp rdt/cid_json.pl rdt/uk/cid_json.pl + cp rdt/compare_crid.pl rdt/uk/compare_crid.pl + cp rdt/compare_menu.pl rdt/uk/compare_menu.pl + cp rdt/epg_json2xml.pl rdt/uk/epg_json2xml.pl + cp rdt/rdt.sh rdt/uk/rdt.sh + cp rdt/settings.sh rdt/uk/settings.sh + cp rdt/url_printer.pl rdt/uk/url_printer.pl + + cp easyepg_backup/rdt_uk_init.json rdt/uk/init.json + cp easyepg_backup/rdt_uk_chlist_old rdt/uk/chlist_old + cp easyepg_backup/rdt_uk_channels.json rdt/uk/channels.json + cp easyepg_backup/rdt_uk_settings.json rdt/uk/settings.json + cp easyepg_backup/xml_rdt_uk.xml xml/radiotimes_uk.xml 2> /dev/null +else + echo "Skipping restore: RadioTimes UK - no setup found" +fi + +# WAIPU.TV DE + +if [ -e easyepg_backup/wpu_de_init.json ] +then + echo "Restoring: waipu.tv DE" + mkdir wpu/de 2> /dev/null + mkdir wpu/de/user 2> /dev/null + + cp wpu/ch_json2xml.pl wpu/de/ch_json2xml.pl + cp wpu/chlist_printer.pl wpu/de/chlist_printer.pl + cp wpu/cid_json.pl wpu/de/cid_json.pl + cp wpu/compare_menu.pl wpu/de/compare_menu.pl + cp wpu/epg_json2xml.pl wpu/de/epg_json2xml.pl + cp wpu/wpu.sh wpu/de/wpu.sh + cp wpu/settings.sh wpu/de/settings.sh + + cp easyepg_backup/wpu_de_init.json wpu/de/init.json + cp easyepg_backup/wpu_de_chlist_old wpu/de/chlist_old + cp easyepg_backup/wpu_de_channels.json wpu/de/channels.json + cp easyepg_backup/wpu_de_settings.json wpu/de/settings.json + cp easyepg_backup/wpu_de_user_userfile wpu/de/user/userfile + cp easyepg_backup/xml_wpu_de.xml xml/waipu_de.xml 2> /dev/null +else + echo "Skipping restore: waipu.tv DE - no setup found" +fi + +# TV-SPIELFILM DE + +if [ -e easyepg_backup/tvs_de_init.json ] +then + echo "Restoring: TV-Spielfilm DE" + mkdir tvs/de 2> /dev/null + + cp tvs/ch_json2xml.pl tvs/de/ch_json2xml.pl + cp tvs/chlist_printer.pl tvs/de/chlist_printer.pl + cp tvs/cid_json.pl tvs/de/cid_json.pl + cp tvs/compare_menu.pl tvs/de/compare_menu.pl + cp tvs/epg_json2xml.pl tvs/de/epg_json2xml.pl + cp tvs/tvs.sh tvs/de/tvs.sh + cp tvs/settings.sh tvs/de/settings.sh + cp tvs/url_printer.pl tvs/de/url_printer.pl + + cp easyepg_backup/tvs_de_init.json tvs/de/init.json + cp easyepg_backup/tvs_de_chlist_old tvs/de/chlist_old + cp easyepg_backup/tvs_de_channels.json tvs/de/channels.json + cp easyepg_backup/tvs_de_settings.json tvs/de/settings.json + cp easyepg_backup/xml_tvs_de.xml xml/tv-spielfilm_de.xml 2> /dev/null +else + echo "Skipping restore: TV-Spielfilm DE - no setup found" +fi + +# VODAFONE DE + +if [ -e easyepg_backup/vdf_de_init.json ] +then + echo "Restoring: Vodafone DE" + mkdir vdf/de 2> /dev/null + + cp vdf/ch_json2xml.pl vdf/de/ch_json2xml.pl + cp vdf/chlist_printer.pl vdf/de/chlist_printer.pl + cp vdf/cid_json.pl vdf/de/cid_json.pl + cp vdf/compare_crid.pl vdf/de/compare_crid.pl + cp vdf/compare_menu.pl vdf/de/compare_menu.pl + cp vdf/epg_json2xml.pl vdf/de/epg_json2xml.pl + cp vdf/vdf.sh vdf/de/vdf.sh + cp vdf/settings.sh vdf/de/settings.sh + cp vdf/url_printer.pl vdf/de/url_printer.pl + + cp easyepg_backup/vdf_de_init.json vdf/de/init.json + cp easyepg_backup/vdf_de_chlist_old vdf/de/chlist_old + cp easyepg_backup/vdf_de_channels.json vdf/de/channels.json + cp easyepg_backup/vdf_de_settings.json vdf/de/settings.json + cp easyepg_backup/xml_vdf_de.xml xml/vodafone_de.xml 2> /dev/null +else + echo "Skipping restore: Vodafone DE - no setup found" +fi + +# EXTERNAL 1 + +if [ -e easyepg_backup/ext_oa_channels.json ] +then + echo "Restoring: External 1" + mkdir ext/oa 2> /dev/null + + cp ext/ch_ext.pl ext/oa/ch_ext.pl + cp ext/compare_menu.pl ext/oa/compare_menu.pl + cp ext/epg_ext.pl ext/oa/epg_ext.pl + cp ext/ext.sh ext/oa/ext.sh + cp ext/settings.sh ext/oa/settings.sh + + cp easyepg_backup/ext_oa_chlist_old ext/oa/chlist_old + cp easyepg_backup/ext_oa_channels.json ext/oa/channels.json + cp easyepg_backup/ext_oa_settings.json ext/oa/settings.json + cp easyepg_backup/xml_ext_oa.xml xml/external_oa.xml 2> /dev/null +else + echo "Skipping restore: External 1 - no setup found" +fi + +# EXTERNAL 2 + +if [ -e easyepg_backup/ext_ob_channels.json ] +then + echo "Restoring: External 2" + mkdir ext/ob 2> /dev/null + + cp ext/ch_ext.pl ext/ob/ch_ext.pl + cp ext/compare_menu.pl ext/ob/compare_menu.pl + cp ext/epg_ext.pl ext/ob/epg_ext.pl + cp ext/ext.sh ext/ob/ext.sh + cp ext/settings.sh ext/ob/settings.sh + + cp easyepg_backup/ext_ob_chlist_old ext/ob/chlist_old + cp easyepg_backup/ext_ob_channels.json ext/ob/channels.json + cp easyepg_backup/ext_ob_settings.json ext/ob/settings.json + cp easyepg_backup/xml_ext_ob.xml xml/external_ob.xml 2> /dev/null +else + echo "Skipping restore: External 2 - no setup found" +fi + +# EXTERNAL 3 + +if [ -e easyepg_backup/ext_oc_channels.json ] +then + echo "Restoring: External 3" + mkdir ext/oc 2> /dev/null + + cp ext/ch_ext.pl ext/oc/ch_ext.pl + cp ext/compare_menu.pl ext/oc/compare_menu.pl + cp ext/epg_ext.pl ext/oc/epg_ext.pl + cp ext/ext.sh ext/oc/ext.sh + cp ext/settings.sh ext/oc/settings.sh + + cp easyepg_backup/ext_oc_chlist_old ext/oc/chlist_old + cp easyepg_backup/ext_oc_channels.json ext/oc/channels.json + cp easyepg_backup/ext_oc_settings.json ext/oc/settings.json + cp easyepg_backup/xml_ext_oc.xml xml/external_oc.xml 2> /dev/null +else + echo "Skipping restore: External 3 - no setup found" +fi + + +# +# RESTORE SETUP FILES FOR COMBINED XML +# + +printf "\nRestoring combined XML setups...\n\n" + +mkdir combine 2> /dev/null + +# DEFINE FOLDERS + +ls easyepg_backup/ | grep "combine" | sed "s/\(.*combine_\)\(.*\)-.*/\2/g" | uniq > /tmp/combine_list + +if [ ! -s /tmp/combine_list ] +then + echo "Skipping restore: No combined XML setups found" +fi + +while [ -s /tmp/combine_list ] +do + folder=$(sed -n "1p" /tmp/combine_list) + echo "Restoring up files for $folder..." + + mkdir combine/$folder 2> /dev/null + + cp easyepg_backup/combine_$folder-settings.json combine/$folder/settings.json 2> /dev/null + cp easyepg_backup/combine_$folder-pre_setup.sh combine/$folder/pre_setup.sh 2> /dev/null + cp easyepg_backup/combine_$folder-setup.sh combine/$folder/setup.sh 2> /dev/null + cp easyepg_backup/combine_$folder.xml xml/$folder.xml 2> /dev/null + + cp easyepg_backup/combine_$folder-hzn_de_channels.json combine/$folder/hzn_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_at_channels.json combine/$folder/hzn_at_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_ch_channels.json combine/$folder/hzn_ch_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_nl_channels.json combine/$folder/hzn_nl_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_pl_channels.json combine/$folder/hzn_pl_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_ie_channels.json combine/$folder/hzn_ie_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_sk_channels.json combine/$folder/hzn_sk_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_cz_channels.json combine/$folder/hzn_cz_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_hu_channels.json combine/$folder/hzn_hu_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-hzn_ro_channels.json combine/$folder/hzn_ro_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-ztt_de_channels.json combine/$folder/ztt_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-ztt_ch_channels.json combine/$folder/ztt_ch_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-swc_ch_channels.json combine/$folder/swc_ch_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-tvp_uk_channels.json combine/$folder/tvp_uk_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-tkm_de_channels.json combine/$folder/tkm_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-rdt_uk_channels.json combine/$folder/rdt_uk_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-wpu_de_channels.json combine/$folder/wpu_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-tvs_de_channels.json combine/$folder/tvs_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-vdf_de_channels.json combine/$folder/vdf_de_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-ext_oa_channels.json combine/$folder/ext_oa_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-ext_ob_channels.json combine/$folder/ext_ob_channels.json 2> /dev/null + cp easyepg_backup/combine_$folder-ext_oc_channels.json combine/$folder/ext_oc_channels.json 2> /dev/null + + sed -i '1d' /tmp/combine_list +done + +rm -rf /tmp/combine_list easyepg_backup 2> /dev/null + +printf "\nDONE!\n\n" From e0d06a05f5f95d6f8bd7f8f75d456e953ff973f3 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 14:23:51 +0200 Subject: [PATCH 11/23] External: Keep channel logo references --- ext/ch_ext.pl | 14 +++++++++++--- ext/compare_menu.pl | 1 + ext/epg_ext.pl | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ext/ch_ext.pl b/ext/ch_ext.pl index 8d88e53..f5c845a 100755 --- a/ext/ch_ext.pl +++ b/ext/ch_ext.pl @@ -23,6 +23,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; # READ XML INPUT FILE @@ -50,6 +51,7 @@ # DEFINE XML RULES my @rules = ( 'display-name' => 'as is', + 'icon' => 'as is', 'channel' => 'as array no content' ); @@ -81,6 +83,7 @@ my $channel_id = $channel->{id}; my $ch_lang = $channel->{'display-name'}->{lang}; my $ch_name = $channel->{'display-name'}->{_content}; + my $ch_logo = $channel->{'icon'}->{'src'}; # ################## # PRINT XML VALUES # @@ -88,10 +91,15 @@ if( $channel_id eq $configdata ) { - # CHANNEL ID + NAME + # CHANNEL ID + NAME + LOGO (condition) print "\n"; - print " " . $ch_name . "<\/display-name>\n<\/channel>\n"; - + print " " . $ch_name . "<\/display-name>\n"; + + if( defined $ch_logo ) { + print " \n\n"; + } else { + print "\n"; + } } } } diff --git a/ext/compare_menu.pl b/ext/compare_menu.pl index ffc2114..242fe84 100755 --- a/ext/compare_menu.pl +++ b/ext/compare_menu.pl @@ -23,6 +23,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; # READ XML INPUT FILE diff --git a/ext/epg_ext.pl b/ext/epg_ext.pl index 695cea1..8ed065c 100755 --- a/ext/epg_ext.pl +++ b/ext/epg_ext.pl @@ -23,6 +23,7 @@ use warnings; binmode STDOUT, ":utf8"; +binmode STDERR, ":utf8"; use utf8; # READ XML INPUT FILE From 489fffb13eb52df05c172d3f5afad96a76ab934b Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 14:41:42 +0200 Subject: [PATCH 12/23] Bump version to 0.4.1; add permission checks --- README.md | 6 +++--- epg.sh | 49 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7f25c5c..7cb58bf 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,13 @@ sudo cpanm install utf8 mkdir ~/easyepg # Download the .zip file and extract the files into your folder: -wget https://github.com/sunsettrack4/easyepg/archive/v0.4.0.zip +wget https://github.com/sunsettrack4/easyepg/archive/v0.4.1.zip # Unzip the file: -unzip v0.4.0.zip +unzip v0.4.1.zip # Move all script files to the created folder -mv ~/easyepg-0.4.0/* ~/easyepg/ +mv ~/easyepg-0.4.1/* ~/easyepg/ # Set system-wide permissions to the folder and its related files sudo chmod 0777 ~/easyepg diff --git a/epg.sh b/epg.sh index a4e50f9..5197cf4 100755 --- a/epg.sh +++ b/epg.sh @@ -22,7 +22,7 @@ clear echo " --------------------------------------------" echo " EASYEPG SIMPLE XMLTV GRABBER " -echo " Release v0.4.0 BETA " +echo " Release v0.4.1 BETA " echo " powered by " echo " " echo " ==THE=======================================" @@ -51,7 +51,17 @@ sleep 0.5s mkdir xml 2> /dev/null && chmod 0777 xml 2> /dev/null mkdir combine 2> /dev/null && chmod 0777 combine 2> /dev/null -chmod -R 0777 . 2> /dev/null +if ! chmod -R 0777 . 2> /dev/null +then + printf "\nPermissions of script folder could not be set " + ERROR="true" +fi + +if ! ls -ld /tmp | grep -q "drwxrwxrwx" 2> /dev/null +then + printf "\nWorkfolder does not have correct permissions " + ERROR="true" +fi if [ ! -e hzn/ch_json2xml.pl ] then @@ -518,19 +528,31 @@ fi if [ ! -e combine.sh ] then - printf "\nMissing file in main folder: combine.sh " + printf "\nMissing file in Main folder: combine.sh " ERROR="true" fi if [ ! -e ch_combine.pl ] then - printf "\nMissing file in Horzon folder: ch_combine.pl " + printf "\nMissing file in Main folder: ch_combine.pl " ERROR="true" fi if [ ! -e prog_combine.pl ] then - printf "\nMissing file in Horzon folder: prog_combine.pl" + printf "\nMissing file in Main folder: prog_combine.pl" + ERROR="true" +fi + +if [ ! -e backup.sh ] +then + printf "\nMissing file in Main folder: backup.sh" + ERROR="true" +fi + +if [ ! -e restore.sh ] +then + printf "\nMissing file in Main folder: restore.sh" ERROR="true" fi @@ -581,14 +603,6 @@ then fi -# -# SET OLDPWD VALUE -# - -cd $(pwd) -echo "DIR=$(pwd)" > /tmp/initrun.txt -echo "VER=v0.4.0 2019/10/07" >> /tmp/initrun.txt - # # CHECK INTERNET CONNECTIVITY # @@ -614,6 +628,15 @@ else fi +# +# SET OLDPWD VALUE +# + +cd $(pwd) +echo "DIR=$(pwd)" > /tmp/initrun.txt +echo "VER=v0.4.1 2019/10/12" >> /tmp/initrun.txt + + # ############### # M1W00 CRONJOB # # ############### From 5f87bf18ee28261c3254f15e1f5ea276510f93d4 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 14:52:45 +0200 Subject: [PATCH 13/23] Add conditions to show backup/restore option in main menu --- epg.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/epg.sh b/epg.sh index 5197cf4..47e8129 100755 --- a/epg.sh +++ b/epg.sh @@ -734,7 +734,23 @@ do echo ' 5 "UPDATE THIS SCRIPT" \' >> /tmp/menu # M1600 BACKUP/RESTORE - echo ' 6 "BACKUP / RESTORE" \' >> /tmp/menu + ls -l hzn/ > /tmp/providerlist + ls -l ztt/ >> /tmp/providerlist + ls -l swc/ >> /tmp/providerlist + ls -l tvp/ >> /tmp/providerlist + ls -l tkm/ >> /tmp/providerlist + ls -l rdt/ >> /tmp/providerlist + ls -l wpu/ >> /tmp/providerlist + ls -l tvs/ >> /tmp/providerlist + ls -l vdf/ >> /tmp/providerlist + ls -l ext/ >> /tmp/providerlist + if grep -q '^d' /tmp/providerlist 2> /dev/null + then + echo ' 6 "BACKUP / RESTORE" \' >> /tmp/menu + elif [ -e easyepg_backup.zip ] + then + echo ' 6 "BACKUP / RESTORE" \' >> /tmp/menu + fi # M1900 ABOUT echo ' 9 "ABOUT EASYEPG" \' >> /tmp/menu From f3d0b02baf5d624c9c4e45b1778173d3499a290b Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 14:56:11 +0200 Subject: [PATCH 14/23] Insert backup/restore scripts into update.sh --- update.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/update.sh b/update.sh index c129b59..f62805f 100755 --- a/update.sh +++ b/update.sh @@ -34,6 +34,9 @@ cp easyepg/LICENSE LICENSE 2> /dev/null cp easyepg/update.sh update.sh 2> /dev/null cp easyepg/branch-debaschdi.sh branch-debaschdi.sh 2> /dev/null cp easyepg/testing.sh testing.sh 2> /dev/null +cp easyepg/testing.sh testing.sh 2> /dev/null +cp easyepg/backup.sh backup.sh 2> /dev/null +cp easyepg/restore.sh restore.sh 2> /dev/null # HORIZON echo "Updating Horizon..." From fc87c672531d5b668cba0393f89a3f3aaa15fd69 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 15:11:36 +0200 Subject: [PATCH 15/23] Reset script environment before restoring setup --- restore.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/restore.sh b/restore.sh index bba89c8..b092308 100644 --- a/restore.sh +++ b/restore.sh @@ -54,6 +54,15 @@ else fi +# +# RESET SETUP +# + +printf "\nResetting setup...\n\n" + +rm -rf hzn/de hzn/at hzn/ch hzn/nl hzn/pl hzn/ie hzn/sk hzn/cz hzn/hu hzn/ro ztt/de ztt/ch swc/ch tvp/uk tkm/de rdt/uk wpu/de tvs/de vdf/de ext/oa ext/ob ext/oc 2> /dev/null + + # # START RESTORE PROCESS: PROVIDER SETUPS + XML FILES # From 40c6e2781dbb5103639d38c934c4ad43efeac012 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 16:22:00 +0200 Subject: [PATCH 16/23] Vodafone: Fix incorrect file handling (DL process) --- vdf/vdf.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vdf/vdf.sh b/vdf/vdf.sh index 845cda3..167c9fc 100644 --- a/vdf/vdf.sh +++ b/vdf/vdf.sh @@ -92,7 +92,7 @@ if [ $(wc -l < mani/common) -ge 7 ] then number=$(echo $(( $(wc -l < mani/common) / 7))) - split -l $number --numeric-suffixes mani/common mani/day + split --lines=$(( $number + 1 )) --numeric-suffixes mani/common mani/day else cp mani/common mani/day00 @@ -133,7 +133,7 @@ function status_manifest_download { z100="[####################]" df=$(find mani/ -type f | wc -l) ; - ftd=$(wc -l < mani/common) ; + if [ -e mani/common ]; then ftd=$(wc -l < mani/common); else ftd=$(wc -l < mani/day00); fi; status=$(expr $df \* 100 / $ftd - 2) ; if [[ $status -gt 100 || $status -eq 100 ]]; then status="100"; fi if [[ $status -gt 0 && $status -lt 5 || $status -eq 0 ]]; then bar="$z0"; elif [[ $status -gt 5 && $status -lt 10 ]]; then bar="$z5"; elif [[ $status -gt 10 && $status -lt 15 ]] ; then bar="$z10"; elif [[ $status -gt 15 && $status -lt 20 ]] ; then bar="$z15"; elif [[ $status -gt 20 && $status -lt 25 ]] ; then bar="$z20"; elif [[ $status -gt 25 && $status -lt 30 ]] ; then bar="$z25"; elif [[ $status -gt 30 && $status -lt 35 ]] ; then bar="$z30"; elif [[ $status -gt 35 && $status -lt 40 ]] ; then bar="$z35"; elif [[ $status -gt 40 && $status -lt 45 ]] ; then bar="$z40"; elif [[ $status -gt 40 && $status -lt 50 ]] ; then bar="$z45"; elif [[ $status -gt 50 && $status -lt 55 ]] ; then bar="$z50"; elif [[ $status -gt 55 && $status -lt 60 ]] ; then bar="$z55"; elif [[ $status -gt 60 && $status -lt 65 ]] ; then bar="$z60"; elif [[ $status -gt 60 && $status -lt 70 ]] ; then bar="$z65"; elif [[ $status -gt 70 && $status -lt 75 ]] ; then bar="$z70"; elif [[ $status -gt 70 && $status -lt 80 ]] ; then bar="$z75"; elif [[ $status -gt 80 && $status -lt 85 ]] ; then bar="$z80"; elif [[ $status -gt 85 && $status -lt 90 ]] ; then bar="$z85"; elif [[ $status -gt 90 && $status -lt 95 ]] ; then bar="$z90"; elif [[ $status -gt 95 && $status -lt 100 ]] ; then bar="$z95"; elif [ $status -eq 100 ] ; then bar="$z100";fi @@ -234,8 +234,8 @@ if [ $(wc -l < day/common) -ge 32 ] then number=$(echo $(( $(wc -l < day/common) / 32))) - split -l $number --numeric-suffixes day/common day/day - + split --lines=$(( $number + 1 )) --numeric-suffixes day/common day/day + else cp day/common day/day00 fi @@ -274,7 +274,7 @@ function status_detail_download { z100="[####################]" df=$(find cache -type f | wc -l) ; - ftd=$(wc -l < day/common) ; + if [ -e day/common ]; then ftd=$(wc -l < day/common); else ftd=$(wc -l < day/day00); fi; status=$(expr $df \* 100 / $ftd) ; if [[ $status -gt 100 || $status -eq 100 ]]; then status="100"; fi if [[ $status -gt 0 && $status -lt 5 || $status -eq 0 ]]; then bar="$z0"; elif [[ $status -gt 5 && $status -lt 10 ]]; then bar="$z5"; elif [[ $status -gt 10 && $status -lt 15 ]] ; then bar="$z10"; elif [[ $status -gt 15 && $status -lt 20 ]] ; then bar="$z15"; elif [[ $status -gt 20 && $status -lt 25 ]] ; then bar="$z20"; elif [[ $status -gt 25 && $status -lt 30 ]] ; then bar="$z25"; elif [[ $status -gt 30 && $status -lt 35 ]] ; then bar="$z30"; elif [[ $status -gt 35 && $status -lt 40 ]] ; then bar="$z35"; elif [[ $status -gt 40 && $status -lt 45 ]] ; then bar="$z40"; elif [[ $status -gt 40 && $status -lt 50 ]] ; then bar="$z45"; elif [[ $status -gt 50 && $status -lt 55 ]] ; then bar="$z50"; elif [[ $status -gt 55 && $status -lt 60 ]] ; then bar="$z55"; elif [[ $status -gt 60 && $status -lt 65 ]] ; then bar="$z60"; elif [[ $status -gt 60 && $status -lt 70 ]] ; then bar="$z65"; elif [[ $status -gt 70 && $status -lt 75 ]] ; then bar="$z70"; elif [[ $status -gt 70 && $status -lt 80 ]] ; then bar="$z75"; elif [[ $status -gt 80 && $status -lt 85 ]] ; then bar="$z80"; elif [[ $status -gt 85 && $status -lt 90 ]] ; then bar="$z85"; elif [[ $status -gt 90 && $status -lt 95 ]] ; then bar="$z90"; elif [[ $status -gt 95 && $status -lt 100 ]] ; then bar="$z95"; elif [ $status -eq 100 ] ; then bar="$z100";fi From e72ce5773190ed261aa8b1541d5ed4d8a14aa856 Mon Sep 17 00:00:00 2001 From: Jan-Luca Neumann Date: Sat, 12 Oct 2019 16:29:19 +0200 Subject: [PATCH 17/23] TV-Spielfilm: Fix incorrect file handling (DL process) (2) * Fix progress bar --- tvs/tvs.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tvs/tvs.sh b/tvs/tvs.sh index abeacc1..7eacd89 100644 --- a/tvs/tvs.sh +++ b/tvs/tvs.sh @@ -85,7 +85,6 @@ then split --lines=$(( $number + 1 )) --numeric-suffixes mani/common mani/day - rm mani/common 2> /dev/null else cp mani/common mani/day00 fi From 2721744dbdc03d4940e514ccc9d27b5391da31d0 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sat, 12 Oct 2019 17:08:45 +0200 Subject: [PATCH 18/23] Several fixes --- epg.sh | 2 +- vdf/vdf.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epg.sh b/epg.sh index 47e8129..f82dad7 100755 --- a/epg.sh +++ b/epg.sh @@ -57,7 +57,7 @@ then ERROR="true" fi -if ! ls -ld /tmp | grep -q "drwxrwxrwx" 2> /dev/null +if ! ls -ld /tmp | grep -q "drwxrwxrw[tx]" 2> /dev/null then printf "\nWorkfolder does not have correct permissions " ERROR="true" diff --git a/vdf/vdf.sh b/vdf/vdf.sh index 167c9fc..0b18dd2 100644 --- a/vdf/vdf.sh +++ b/vdf/vdf.sh @@ -228,7 +228,7 @@ printf "\rPreparing multithreaded download... " sed "s/.*/curl --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 -s 'https:\/\/tv-manager.vodafone.de\/tv-manager\/backend\/auth-service\/proxy\/epg-data-service\/epg\/tv\/data\/item\/&' | grep 'channelId' > cache\/&/g" day/daydlnew > day/common sed -i '/^$/d' day/common -printf "\n$(echo $(wc -l < day/common)) broadasts files to be downloaded!\n\n" +printf "\n$(echo $(wc -l < day/common)) broadcast files to be downloaded!\n\n" if [ $(wc -l < day/common) -ge 32 ] then From d464e2edbc556eb9ae4a5a9aeb099d4d6056d4d3 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sun, 15 Dec 2019 13:16:52 +0100 Subject: [PATCH 19/23] Do not print category string when category_content is empty --- prog_combine.pl | 150 +++++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 60 deletions(-) diff --git a/prog_combine.pl b/prog_combine.pl index ea8793c..97e3708 100755 --- a/prog_combine.pl +++ b/prog_combine.pl @@ -237,10 +237,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -380,10 +382,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -523,10 +527,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -666,10 +672,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -809,10 +817,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -952,10 +962,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1095,10 +1107,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1238,10 +1252,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1381,10 +1397,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1524,10 +1542,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1667,10 +1687,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1810,10 +1832,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -1953,10 +1977,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -2096,10 +2122,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } @@ -2237,10 +2265,12 @@ foreach my $category_string ( @category ) { my $category_content = $category_string->{_content}; my $category_lang = $category_string->{lang}; - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; + if( defined $category_content ) { + if( defined $category_lang ) { + print " " . $category_content . "\n"; + } else { + print " " . $category_content . "\n"; + } } } } From a3964f80bdccce0c05a47569e9c5ba1e0ecedeeb Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sun, 15 Dec 2019 13:20:29 +0100 Subject: [PATCH 20/23] prog_combine.pl: Remove day 9 duplicate --- prog_combine.pl | 147 +----------------------------------------------- 1 file changed, 1 insertion(+), 146 deletions(-) diff --git a/prog_combine.pl b/prog_combine.pl index 97e3708..d5ad853 100755 --- a/prog_combine.pl +++ b/prog_combine.pl @@ -1441,152 +1441,7 @@ # END OF PROGRAMME print "\n"; } - } - - # - # DAY 9 - # - - if( $days eq "9" or $days eq "10" or $days eq "11" or $days eq "12" or $days eq "13" ) { - - if( defined $start and $start =~ m/$date9/ ) { - - # START + STOP + CHANNEL - print "\n"; - - # ICON - my $icon = $programme->{icon}->{src}; - if( defined $icon ) { - print " \n"; - } - - # TITLE - my $title = $programme->{title}->{_content}; - my $title_lang = $programme->{title}->{lang}; - if( defined $title ) { - if( defined $title_lang ) { - print " " . $title . "\n"; - } else { - print " " . $title . "\n"; - } - } else { - if( defined $title_lang ) { - print " No program information available\n"; - } else { - print " No program information available\n"; - } - } - - # SUB-TITLE - my $subtitle = $programme->{'sub-title'}->{_content}; - my $sub_lang = $programme->{'sub-title'}->{lang}; - if( defined $subtitle ) { - if( defined $sub_lang ) { - print " " . $subtitle . "\n"; - } else { - print " " . $subtitle . "\n"; - } - } - - # DESC - my $desc = $programme->{desc}->{_content}; - my $desc_lang = $programme->{desc}->{lang}; - if( defined $desc ) { - if( defined $desc_lang ) { - print " " . $desc . "\n"; - } else { - print " " . $desc . "\n"; - } - } - - # CREDITS - my $credits = $programme->{credits}; - if( defined $credits ) { - print " \n"; - - # DIRECTOR - if( exists $credits->{director}) { - my @director = @{ $credits->{director} }; - foreach my $director ( @director ) { - print " " . $director . "\n"; - } - } - - # ACTOR - if( exists $credits->{actor}) { - my @actor = @{ $credits->{actor} }; - foreach my $actor ( @actor ) { - print " " . $actor . "\n"; - } - } - - print " \n"; - } - - # DATE - my $date = $programme->{date}; - if( defined $date ) { - print " " . $date . "\n"; - } - - # COUNTRY - my $country = $programme->{country}; - if( defined $country ) { - print " " . $country . "\n"; - } - - # CATEGORY - my $category = $programme->{category}; - if( defined $category ) { - my @category = @{ $programme->{category} }; - foreach my $category_string ( @category ) { - my $category_content = $category_string->{_content}; - my $category_lang = $category_string->{lang}; - if( defined $category_content ) { - if( defined $category_lang ) { - print " " . $category_content . "\n"; - } else { - print " " . $category_content . "\n"; - } - } - } - } - - # EPISODE - my $episode = $programme->{'episode-num'}->{_content}; - my $episystem = $programme->{'episode-num'}->{system}; - if( defined $episode ) { - if( defined $episystem ) { - print " " . $episode . "\n"; - } - } - - # AGE RATING - my $agerating = $programme->{rating}->{value}; - my $agesystem = $programme->{rating}->{system}; - if( defined $agerating ) { - if( defined $agesystem ) { - print " \n " . $agerating . "\n \n"; - } else { - print " \n " . $agerating . "\n \n"; - } - } - - # STAR RATING - my $starrating = $programme->{'star-rating'}->{value}; - my $starsystem = $programme->{'star-rating'}->{system}; - if( defined $starrating ) { - if( defined $starsystem ) { - print " \n " . $starrating . "\n \n"; - } else { - print " \n " . $starrating . "\n \n"; - } - } - - # END OF PROGRAMME - print "\n"; - } - } + } # # DAY 10 From ee26e0c25ba312befeb429075674a0911d7ba894 Mon Sep 17 00:00:00 2001 From: Jan-Luca Date: Sun, 15 Dec 2019 13:29:43 +0100 Subject: [PATCH 21/23] Bump version to 0.4.2 --- README.md | 6 +++--- epg.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7cb58bf..42dd35c 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,13 @@ sudo cpanm install utf8 mkdir ~/easyepg # Download the .zip file and extract the files into your folder: -wget https://github.com/sunsettrack4/easyepg/archive/v0.4.1.zip +wget https://github.com/sunsettrack4/easyepg/archive/v0.4.2.zip # Unzip the file: -unzip v0.4.1.zip +unzip v0.4.2.zip # Move all script files to the created folder -mv ~/easyepg-0.4.1/* ~/easyepg/ +mv ~/easyepg-0.4.2/* ~/easyepg/ # Set system-wide permissions to the folder and its related files sudo chmod 0777 ~/easyepg diff --git a/epg.sh b/epg.sh index f82dad7..fafdb87 100755 --- a/epg.sh +++ b/epg.sh @@ -22,7 +22,7 @@ clear echo " --------------------------------------------" echo " EASYEPG SIMPLE XMLTV GRABBER " -echo " Release v0.4.1 BETA " +echo " Release v0.4.2 BETA " echo " powered by " echo " " echo " ==THE=======================================" @@ -634,7 +634,7 @@ fi cd $(pwd) echo "DIR=$(pwd)" > /tmp/initrun.txt -echo "VER=v0.4.1 2019/10/12" >> /tmp/initrun.txt +echo "VER=v0.4.2 2019/12/15" >> /tmp/initrun.txt # ############### From 507f7f0e2ab22d0dfa39f460beb71c15e83c76f9 Mon Sep 17 00:00:00 2001 From: DeBaschdi Date: Mon, 6 Jan 2020 13:45:10 +0100 Subject: [PATCH 22/23] delete workfile later Prevent the Workfile file from being deleted early during the conversion, happen by large files >200 Channels 14Days --- swc/swc.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swc/swc.sh b/swc/swc.sh index 0e4c976..8f7cdb5 100755 --- a/swc/swc.sh +++ b/swc/swc.sh @@ -312,7 +312,8 @@ perl cid_json.pl > swc_cid.json && rm chlist # CONVERT JSON INTO XML: EPG printf "\rConverting EPG JSON file into XML format... " -perl epg_json2xml.pl > swisscom_epg 2>epg_warnings.txt && rm /tmp/epg_workfile 2> /dev/null +#perl epg_json2xml.pl > swisscom_epg 2>epg_warnings.txt && rm /tmp/epg_workfile 2> /dev/null +perl epg_json2xml.pl > swisscom_epg 2>epg_warnings.txt 2> /dev/null # COMBINE: CHANNELS + EPG printf "\rCreating EPG XMLTV file... " @@ -320,6 +321,7 @@ cat swisscom_epg >> swisscom_channels && mv swisscom_channels swisscom && rm swi sed -i '1i\n<\!-- EPG XMLTV FILE CREATED BY THE EASYEPG PROJECT - (c) 2019 Jan-Luca Neumann -->\n' swisscom sed -i "s//<\!-- created on $(date) -->\n&\n\n\n/g" swisscom sed -i '$s/.*/&\n\n<\/tv>/g' swisscom +rm /tmp/epg_workfile 2> /dev/null mv swisscom swisscom.xml # VALIDATING XML FILE From 7b910548b2220090490f21958abefcb30af4a61f Mon Sep 17 00:00:00 2001 From: DeBaschdi Date: Wed, 8 Jan 2020 08:02:42 +0100 Subject: [PATCH 23/23] Add Provider TVTV-US --- tvtvus/ch_json2xml.pl | 143 +++++++++++ tvtvus/chlist_printer.pl | 179 ++++++++++++++ tvtvus/cid_json.pl | 72 ++++++ tvtvus/compare_crid.pl | 66 ++++++ tvtvus/compare_menu.pl | 81 +++++++ tvtvus/epg_json2xml.pl | 426 +++++++++++++++++++++++++++++++++ tvtvus/info | 1 + tvtvus/init.json | 1 + tvtvus/settings.sh | 497 +++++++++++++++++++++++++++++++++++++++ tvtvus/tvtvus.sh | 456 +++++++++++++++++++++++++++++++++++ tvtvus/url_printer.pl | 175 ++++++++++++++ 11 files changed, 2097 insertions(+) create mode 100644 tvtvus/ch_json2xml.pl create mode 100644 tvtvus/chlist_printer.pl create mode 100644 tvtvus/cid_json.pl create mode 100644 tvtvus/compare_crid.pl create mode 100644 tvtvus/compare_menu.pl create mode 100644 tvtvus/epg_json2xml.pl create mode 100644 tvtvus/info create mode 100644 tvtvus/init.json create mode 100644 tvtvus/settings.sh create mode 100644 tvtvus/tvtvus.sh create mode 100644 tvtvus/url_printer.pl diff --git a/tvtvus/ch_json2xml.pl b/tvtvus/ch_json2xml.pl new file mode 100644 index 0000000..9a5e12f --- /dev/null +++ b/tvtvus/ch_json2xml.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ############################### +# TVSPIELFILM JSON > XML CONVERTER # +# ############################### + +# CHANNELS + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: CHLIST +my $json; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "chlist" or die; + $json = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: SWC HARDCODED CHLIST +my $chlist; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "tvtvus_channels.json" or die; + $chlist = <$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; +} + +# READ INIT FILE +my $init; +{ + local $/; #Enable 'slurp' mode + open my $fh, '<', "init.json" or die; + $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); +my $chdata = decode_json($chlist); +my $configdata = decode_json($chlist_config); +my $initdata = decode_json($init); +my $setupdata = decode_json($settings); + +# DEFINE COUNTRY VERSION +my $countryVER = $initdata->{'country'}; + +my @stations = @{ $data->{'stations'} }; +foreach my $stations ( @stations ) { + + # #################### + # DEFINE JSON VALUES # + # #################### + + # DEFINE CHANNEL ID + NAME + my $cname = $stations->{'name'}; + $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE LANGUAGE VERSION + # my $languageVER = $initdata->{'language'}; + my $languageVER = $stations->{'Languages'}[0]; + + # DEFINE RYTEC CHANNEL ID (language) + my $rytec = $chdata->{'channels'}{$countryVER}; + + # DEFINE SELECTED CHANNELS + my @configdata = @{ $configdata->{'channels'} }; + + # DEFINE SETTINGS + my $setup_general = $setupdata->{'settings'}; + my $setup_cid = $setup_general->{'cid'}; + + # DEFINE SETTINGS VALUES + my $enabled = "enabled"; + my $disabled = "disabled"; + + + # ################## + # PRINT XML OUTPUT # + # ################## + + # CHANNEL ID (condition) (settings) + foreach my $selected_channel ( @configdata ) { + if( $cname eq $selected_channel ) { + if( $setup_cid eq $enabled ) { + if( defined $rytec->{$cname} ) { + print "{$cname} . "\">"; + } else { + print ""; + print STDERR "[ CHLIST WARNING ] Rytec ID not matched for: " . $cname . "\n"; + } + } else { + print ""; + } + + # CHANNEL NAME (language) + print "" . $cname . "\n"; + } + } +} diff --git a/tvtvus/chlist_printer.pl b/tvtvus/chlist_printer.pl new file mode 100644 index 0000000..d8543eb --- /dev/null +++ b/tvtvus/chlist_printer.pl @@ -0,0 +1,179 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ################################ +# TVTV-US 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->{'stations'} }; +foreach my $newchannels ( @newchannels_name2id ) { + + # + # DEFINE JSON VALUES + # + + # DEFINE NEW CHANNEL NAME + my $newcname = $newchannels->{'name'}; + $newcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE NEW CHANNEL ID + my $newcid = $newchannels->{'channelNumber'}; + + # PRINT NEW CHANNEL NAMES + print "\"$newcname\": \"$newcid\",\n"; +} + +# TOOL: ID ==> NAME + +print "\"DUMMY\": \"DUMMY\" },\n\"newid2name\": {\n"; + +my @newchannels_id2name = @{ $newdata->{'stations'} }; +foreach my $newchannels ( @newchannels_id2name ) { + + # + # DEFINE JSON VALUES + # + + # DEFINE NEW CHANNEL NAME + my $newcname = $newchannels->{'name'}; + $newcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE NEW CHANNEL ID + my $newcid = $newchannels->{'channelNumber'}; + + # 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->{'stations'} }; +foreach my $oldchannels ( @oldchannels_name2id ) { + + # + # DEFINE JSON VALUES + # + + # DEFINE OLD CHANNEL NAME + my $oldcname = $oldchannels->{'name'}; + $oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE OLD CHANNEL ID + my $oldcid = $oldchannels->{'channelNumber'}; + + # PRINT OLD CHANNEL NAMES + print "\"$oldcname\": \"$oldcid\",\n"; +} + +# TOOL: ID ==> NAME + +print "\"DUMMY\": \"DUMMY\" },\n\"oldid2name\": {\n"; + +my @oldchannels_id2name = @{ $olddata->{'stations'} }; +foreach my $oldchannels ( @oldchannels_id2name ) { + + # + # DEFINE JSON VALUES + # + + # DEFINE OLD CHANNEL NAME + my $oldcname = $oldchannels->{'name'}; + $oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE OLD CHANNEL ID + my $oldcid = $oldchannels->{'channelNumber'}; + + # 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/tvtvus/cid_json.pl b/tvtvus/cid_json.pl new file mode 100644 index 0000000..ac87ba2 --- /dev/null +++ b/tvtvus/cid_json.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ############################### +# TVSPIELFILM CHANNEL ID CREATOR # +# ############################### + +# CHANNEL IDs + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: CHLIST +my $json; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/chlist" or die; + $json = <$fh>; + close $fh; +} + +# CONVERT JSON TO PERL STRUCTURES +my $data = decode_json($json); + +print "{ \"cid\":\n {\n"; + +my @stations = @{ $data->{'stations'} }; +foreach my $stations ( @stations ) { + + # #################### + # DEFINE JSON VALUES # + # #################### + + # DEFINE CHANNEL NAME + my $cname = $stations->{'name'}; + $cname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + + # DEFINE CHANNEL ID + my $cid = $stations->{'channelNumber'}; + + # ################### + # PRINT JSON OUTPUT # + # ################### + + # CHANNEL ID (condition) + print " \"$cid\":\"$cname\",\n"; +} + +print " \"000000000000\":\"DUMMY\"\n }\n}"; diff --git a/tvtvus/compare_crid.pl b/tvtvus/compare_crid.pl new file mode 100644 index 0000000..087c287 --- /dev/null +++ b/tvtvus/compare_crid.pl @@ -0,0 +1,66 @@ +#!/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 . + +# ############################### +# TVTV CHANNEL LIST CREATOR # +# ############################### + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; + +# READ JSON INPUT FILE: MANIFEST +my $manifests; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/epg_workfile" or die; + $manifests = <$fh>; + close $fh; +} + +# CONVERT JSON TO PERL STRUCTURES +my $manifestsdata = decode_json($manifests); + +# +# DEFINE JSON VALUES +# +my @attributes = @{ $manifestsdata->{'attributes'} }; + +# DEFINE manifests STRINGS +foreach my $attributes ( @attributes ) { + + my @listings = @{ $attributes->{'listings'} }; + foreach my $listings ( @listings ) { + + # #################### + # DEFINE JSON VALUES # + # #################### + + # DEFINE TIMES AND CHANNEL ID + my $showID = $listings->{'showID'}; + + print $showID. "\n"; + } +} \ No newline at end of file diff --git a/tvtvus/compare_menu.pl b/tvtvus/compare_menu.pl new file mode 100644 index 0000000..70df543 --- /dev/null +++ b/tvtvus/compare_menu.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ################################# +# TVTV-US TV 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 ) { + + # DEFINE IDs + my $old_id = $old_name2id->{$configname}; + my $new_id = $new_name2id->{$configname}; + + # FIND MATCH - NEW + OLD CHANNEL ID VIA CONFIG NAME + if( $new_id eq $old_id ) { + print "$configname\n"; + + # IF MATCH NOT FOUND: FIND CHANNEL NAME IN NEW CHANNEL LIST + } elsif( defined $new_id ) { + print "$configname\n"; + print STDERR "[ INFO ] CHANNEL \"$configname\" received new Channel ID!\n"; + } else { + print STDERR "[ WARNING ] CHANNEL $configname not found in channel lists!\n"; + } +} diff --git a/tvtvus/epg_json2xml.pl b/tvtvus/epg_json2xml.pl new file mode 100644 index 0000000..7e470df --- /dev/null +++ b/tvtvus/epg_json2xml.pl @@ -0,0 +1,426 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ################################# +# TVTV-US JSON > XML CONVERTER # +# ################################# + +# EPG + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; + +use utf8; +use JSON; +use Data::Dumper; +use Time::Piece; +use DateTime::Format::Strptime; + +# READ JSON INPUT FILE: EPG WORKFILE +my $json; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "/tmp/epg_workfile" or die; + $json = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: MAGENTA NUMERIC CHANNEL IDs +my $chidlist; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "tvtvus_cid.json" or die; + $chidlist = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: RYTEC ID LIST +my $chlist; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "tvtvus_channels.json" or die; + $chlist = <$fh>; + close $fh; +} + +# READ JSON INPUT FILE: EIT CATEGORY LIST +my $genrelist; +{ + local $/; #Enable 'slurp' mode + open my $fh, "<", "tvtvus_genres.json" or die; + $genrelist = <$fh>; + close $fh; +} + +# READ INIT FILE +my $init; +{ + local $/; #Enable 'slurp' mode + open my $fh, '<', "init.json" or die; + $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); +my $chdata = decode_json($chlist); +my $chiddata = decode_json($chidlist); +my $genredata = decode_json($genrelist); +my $initdata = decode_json($init); +my $setupdata = decode_json($settings); + +# DEFINE COUNTRY VERSION +my $countryVER = $initdata->{'country'}; + +# DEFINE LANGUAGE VERSION +my $languageVER = $initdata->{'language'}; + +print "\n\n\n"; + +my @attributes = @{ $data->{'attributes'} }; +foreach my $attributes ( @attributes ) { + + my @listings = @{ $attributes->{'listings'} }; + foreach my $listings ( @listings ) { + + # #################### + # DEFINE JSON VALUES # + # #################### + + # DEFINE TIMES AND CHANNEL ID + my $start = $listings->{'listDateTime'}; + my $duration = $listings->{'duration'}; + my $durations = $listings->{'duration'}; + my $cid = $attributes->{'channel'}{'channelNumber'}; + $cid =~ s/\&/\&/g; + + # CONVERT FROM TIMESTAMP TO XMLTV DATE FORMAT + $start =~ s/://g; + $start =~ s/-//g; + $start =~ s/ //g; + + # CONVERT PROGRAMM DURATION IN SEC + $duration = $duration * 60; + + # CONVERT STARTTIME IN EPOCH SEC + my $parser = DateTime::Format::Strptime->new( pattern => '%Y%m%d%H%M%S' ); + my $dt = $parser->parse_datetime( $start ); + my $end = $dt->epoch; + + # CALCULATE DURATION TO STARTTIME TO GET STOPTIME + $end = $end + $duration; + + $end = gmtime($end)->strftime('%F %T'); + $end =~ s/://g; + $end =~ s/-//g; + $end =~ s/ //g; + + # DEFINE PROGRAM STRINGS + my $title = $listings->{'showName'}; + my $subtitle = $listings->{'episodeTitle'}; + my $director = $listings->{'director'}; + my $desc = $listings->{'description'}; + my $date = $listings->{'year'}; + my $country = $listings->{'country'}; + my $genre = $listings->{'showType'}; + my $age = $listings->{'rating'}; + my $star = $listings->{'starRating'}; + + # DEFINE RYTEC CHANNEL ID (language) + my $rytec = $chdata->{'channels'}{$countryVER}; + + # DEFINE CHANNEL ID + my $cidEXT = $chiddata->{'cid'}; + + # 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 # + # ################## + + # PRINT PROGRAMME STRING ONLY IF CERTAIN VALUES ARE DEFINED + if( defined $title and defined $start and defined $end and defined $cid ) { + + # BEGIN OF PROGRAMME: START / STOP / CHANNEL (condition) (settings) + if( defined $cidEXT->{$cid} ) { + 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"; + } + } else { + print "\n"; + print STDERR "[ EPG WARNING ] Channel ID unknown: " . $cid . "\n"; + } + + # IMAGE (condition) + if( defined $listings->{'artwork'}{'moviePoster'} ) { + my $image = $listings->{'artwork'}{'moviePoster'} ; + $image =~ s/^/https:\/\/www.tvtv.us\/tvm\/i\/image\/show\/960x1440\//g; + print " \n"; + }else{ + if( defined $listings->{'showPicture'} ) { + my $image = $listings->{'showPicture'} ; + $image =~ s/^/https:\/\/www.tvtv.us\/tvm\/i\/image\/show\/960x1440\//g; + print " \n"; + } + } + + # TITLE (language) + if ( $subtitle eq ''){ + undef $subtitle; + } + if ( $title eq 'Movie') { + if( defined $subtitle ) { + $subtitle =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + $title = $subtitle + } + } + $title =~ s/\&/\&/g; + print " " . $title . "\n"; + + # SUBTITLE (condition) (language) + if( defined $subtitle ) { + if ( $title eq $subtitle){ + undef $subtitle; + } + } + + if( defined $subtitle ) { + $subtitle =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + print " $subtitle\n"; + } + + # DESCRIPTION (condition) (language) + if( defined $desc ) { + $desc =~ s/<[^>]*>//g; # REMOVE XML STRINGS WITHIN JSON VALUE + $desc =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + print " $desc\n"; + } + + #CREDITS (condition) + if ( $director eq ''){ + undef $director; + } + if( defined $director ) { + $director =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + print " \n"; + print " " . $director . "\n"; + if( exists $listings->{'cast'} ) { + my $cast = $listings->{'cast'} ; + $cast =~ s/\&/\&/g; + foreach my $actors ( split /,\s*/, $cast ){ + print " " . $actors . "\n"; + } + } + print " \n"; + } else{ + my $cast = $listings->{'cast'} ; + if ($cast eq ''){ + undef $cast; + } + if( defined $cast ) { + $cast =~ s/\&/\&/g; + print " \n"; + foreach my $actors ( split /,\s*/, $cast ){ + print " " . $actors . "\n"; + } + print " \n"; + } + } + + + + # DATE (condition) + if( $date eq '' ) { + undef $date; + } + if( defined $date ) { + print " $date\n"; + } + + # COUNTRY (condition) + if( defined $country ) { + print " " . uc($country) . "\n"; + } + + # CATEGORIES (USE ONE CATEGORY ONLY) (condition) (language) (settings) + if ( defined $genre ) { + $genre =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY + $genre =~ s/Movies, //g; + $genre =~ s/, / \/ /g; + if ( $setup_genre eq $enabled ) { + if ( defined $eit->{ $genre } ) { + print " " . $eit->{ $genre } . "\n"; + } else { + print " $genre\n"; + print STDERR "[ EPG WARNING ] CATEGORY UNAVAILABLE IN EIT LIST: " . "$genre" . "\n";; + } + }elsif ( $setup_genre eq $disabled ) { + print " $genre\n"; + } + } + + + + + # SEASON/EPISODE (XMLTV_NS) (condition) (settings) + my $showID = $listings->{'showID'}; + my $cridFile = "cache/$showID"; + if( -e $cridFile ) { + my $crid; + { + local $/; #Enable 'slurp' mode + open my $fh, "<", "cache/$showID" or die; + $crid = <$fh>; + close $fh; + } + my $cridDATA = decode_json ($crid); + + my $series = $cridDATA->{'seasons'}[0]{'seasonNumber'}; + my $episode = $cridDATA->{'episodes'}[0]{'seasonSeqNo'}; + + if( defined $series ) { + if ( $series lt '1' || $series eq '' ) { + undef $series; + } + } + + if( defined $episode ) { + if ( $episode lt '1'|| $episode eq '' ) { + undef $episode; + } + } + + # USE SEASON / EPISODE PROVIDEY BY MANIFILES, ONLY IF EXIST, ELSE USE CRID INFORMATION + my $maniseason = $listings->{'episodeNumber'}; + if( defined $maniseason ) { + if ( $maniseason =~ m/-/ ) { + undef $episode; + undef $series; + $episode = $maniseason; + $episode =~ s/.*\-//g; + $episode =~ s/[^0-9#\.\-_]//g; + $series = $maniseason; + $series =~ s/\-.*//g; + $series =~ s/[^0-9#\.\-_]//g; + if ($series eq '' ) { + undef $series; + } + if ( $episode eq '' ) { + undef $episode; + } + } + } + + if( $setup_episode eq $xmltv_ns ) { + 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 " 0 . $XMLepisode . \n"; + } + } + + # SEASON/EPISODE (ONSCREEN) (condition) (settings) + if( $setup_episode eq $onscreen ) { + 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 ( $age eq '' ) { + undef $age; + } + if( defined $age) { + $age =~ s/TV14/16/g ; + $age =~ s/TVG/6/g ; + $age =~ s/TVMA/18/g ; + $age =~ s/TVPG/6/g ; + $age =~ s/TVY7/12/g ; + $age =~ s/TVY/6/g ; + $age =~ s/TV6/6/g ; + if( $age ne '-1' ) { + print " \n $age\n \n"; + } + } + + # STAR RATING (condition) + if ( $star eq '' ) { + undef $star; + } + if( defined $star) { + if( $star gt '0' ) { + $star = $star *2; + $star =~ s/$/\/10/g; + print " \n $star\n \n"; + } + } + + # END OF PROGRAMME + print "\n"; + } + } +} \ No newline at end of file diff --git a/tvtvus/info b/tvtvus/info new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/tvtvus/info @@ -0,0 +1 @@ + diff --git a/tvtvus/init.json b/tvtvus/init.json new file mode 100644 index 0000000..8d5c401 --- /dev/null +++ b/tvtvus/init.json @@ -0,0 +1 @@ +{"country":"USA","language":"en"} diff --git a/tvtvus/settings.sh b/tvtvus/settings.sh new file mode 100644 index 0000000..517f690 --- /dev/null +++ b/tvtvus/settings.sh @@ -0,0 +1,497 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + + +# ######################## +# E1000 TVTV-US SETTINGS # +# ######################## + +echo "H" > /tmp/value + +while grep -q "H" /tmp/value +do + # E1000 MENU OVERLAY + echo 'dialog --backtitle "[E1000] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS" --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 + + # E1100 CHANNEL LIST + echo ' 1 "MODIFY CHANNEL LIST" \' >> /tmp/menu + + # E1200 TIME PERIOD + + if grep -q "day=10" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 10 days)" \' >> /tmp/menu + elif grep -q "day=11" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 11 days)" \' >> /tmp/menu + elif grep -q "day=12" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 12 days)" \' >> /tmp/menu + elif grep -q "day=13" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 13 days)" \' >> /tmp/menu + elif grep -q "day=14" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 14 days)" \' >> /tmp/menu + elif 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=8" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 8 days)" \' >> /tmp/menu + elif grep -q "day=9" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: 9 days)" \' >> /tmp/menu + elif grep -q "day=0" /tmp/settings_new + then + echo ' 2 "TIME PERIOD (currently: disabled)" \' >> /tmp/menu + fi + + # E1300 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 + + # E1400 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 + + # E1600 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 + + # E1700 RUN XML SCRIPT + echo ' 7 "RUN XML SCRIPT" \' >> /tmp/menu + + # E1900 DELETE INSTANCE + echo ' 9 "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 + + + # #################### + # E1100 CHANNEL LIST # + # #################### + + if grep -q "1" /tmp/value + then + # E1100 MENU OVERLAY + echo 'dialog --backtitle "[E1100] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CHANNEL LIST" --title "CHANNELS" --checklist "Please choose the channels you want to grab:" 15 50 10 \' > /tmp/chmenu + + printf "\rFetching channel list... " + curl --compressed -s https://tvtv.us/tvm/t/tv/v4/lineups/2381D/ > /tmp/workfile + jq '.' /tmp/workfile > /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/\\\[[0-9][^]]*\] //g;s/\\(/(/g;s/\\)/)/g;s/.*/{"channels":[&]}/g;s/\\\&/\&/g;s/\\//g' /tmp/chconf > channels.json + cp /tmp/chlist chlist_old + dialog --backtitle "[E1110] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CHANNEL LIST" --title "INFO" --msgbox "New channel list added!\nPlease run the grabber to add the channels to the setup modules!" 7 50 + echo "H" > /tmp/value + else + dialog --backtitle "[E1120] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CHANNEL LIST" --title "INFO" --msgbox "Channel list creation aborted!\nPlease note that at least 1 channel must be included in channel list!" 7 50 + echo "M" > /tmp/value + exit 1 + fi + else + perl chlist_printer.pl > /tmp/compare.json + perl compare_menu.pl > /tmp/enabled_chvalues 2> /dev/null + 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 + + bash /tmp/chmenu + + if [ -s /tmp/chconf ] + then + sed 's/" "/","/g;s/\\\[[0-9][^]]*\] //g;s/\\(/(/g;s/\\)/)/g;s/.*/{"channels":[&]}/g;s/\\\&/\&/g;s/\\//g' /tmp/chconf > channels.json + dialog --backtitle "[E1130] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CHANNEL LIST" --title "INFO" --msgbox "New channel list saved!\nPlease run the grabber to add new channels to the setup modules!" 7 50 + cp /tmp/chlist chlist_old + echo "H" > /tmp/value + else + dialog --backtitle "[E1140] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CHANNEL LIST" --title "INFO" --msgbox "Channel list creation aborted!\nPlease note that at least 1 channel must be included in channel list!" 7 50 + echo "H" > /tmp/value + fi + fi + + + # ################### + # E1200 TIME PERIOD # + # ################### + + elif grep -q "2" /tmp/value + then + echo "X" > /tmp/value + + while grep -q "X" /tmp/value + do + # E1200 MENU OVERLAY + dialog --backtitle "[E1200] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "EPG GRABBER" --inputbox "Please enter the number of days you want to retrieve the EPG information. (0=disable | 1-14=enable)" 10 46 2>/tmp/value + + sed -i 's/.*/epg&-/g' /tmp/value + + # E1210 INPUT: DISABLED + if grep -q "epg0-" /tmp/value + then + sed -i '/day=/d' /tmp/settings_new + echo "day=0" >> /tmp/settings_new + dialog --backtitle "[E1210] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber disabled!" 5 26 + echo "H" > /tmp/value + + # E1220 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 "[E1220] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber is enabled for 1 day!" 5 42 + echo "H" > /tmp/value + + # E1230 INPUT: 2-9 DAYS + elif grep -q "epg[2-9]-" /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 "[E1230] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber is enabled for $( /tmp/value + + # E1240 INPUT: 10-14 DAYS + elif grep -q "epg1[0-4]-" /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 "[E1240] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "INFO" --msgbox "EPG grabber is enabled for $( /tmp/value + + # E1250 WRONG INPUT + elif [ -s /tmp/value ] + then + dialog --backtitle "[E1250] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > TIME PERIOD" --title "ERROR" --msgbox "Wrong input detected!" 5 30 + echo "X" > /tmp/value + + # E12X0 EXIT + else + echo "H" > /tmp/value + fi + done + + + # ########################### + # E1300 CONVERT CHANNEL IDs # + # ########################### + + elif grep -q "3" /tmp/value + then + # E1300 MENU OVERLAY + dialog --backtitle "[E1300] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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=$? + + # E1310 NO + if [ $response = 1 ] + then + dialog --backtitle "[E1310] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E1320 YES + elif [ $response = 0 ] + then + dialog --backtitle "[E1320] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E13X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[E13X0] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CONVERT CHANNEL IDs" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ########################### + # E1400 CONVERT CATEGORIES # + # ########################### + + elif grep -q "4" /tmp/value + then + # E1400 MENU OVERLAY + dialog --backtitle "[E1400] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CONVERT CATEGORIES" --title "CATEGORIES" --yesno "Do you want to use the EIT format for tvHeadend?" 5 55 + + response=$? + + # E1410 NO + if [ $response = 1 ] + then + dialog --backtitle "[E1410] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E1420 YES + elif [ $response = 0 ] + then + dialog --backtitle "[E1420] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E14X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[E14X0] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > CONVERT CATEGORIES" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ########################### + # E1500 MULTIPLE CATEGORIES # + # ########################### + + elif grep -q "5" /tmp/value + then + # E1500 MENU OVERLAY + dialog --backtitle "[E1500] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > MULTIPLE CATEGORIES" --title "MULTIPLE CATEGORIES" --yesno "Do you want to use multiple categories for tvHeadend?" 5 60 + + response=$? + + # E1510 NO + if [ $response = 1 ] + then + dialog --backtitle "[E1510] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E1520 YES + elif [ $response = 0 ] + then + dialog --backtitle "[E1520] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E15X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[E15X0] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > MULTIPLE CATEGORIES" --title "INFO" --msgbox "No changes applied!" 5 30 + echo "H" > /tmp/value + fi + + + # ###################### + # E1600 EPISODE FORMAT # + # ###################### + + elif grep -q "6" /tmp/value + then + # E1600 MENU OVERLAY + dialog --backtitle "[E1600] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US 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 + + # E1610 ONSCREEN + if grep -q "1" /tmp/value + then + dialog --backtitle "[E1610] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > EPISODE FORMAT" --title "INFO" --msgbox "Episode format 'onscreen' enabled!" 5 40 + sed -i '/episode=/d' /tmp/settings_new + echo "episode=onscreen" >> /tmp/settings_new + echo "H" > /tmp/value + + # E1620 XMLTV_NS + elif grep -q "2" /tmp/value + then + dialog --backtitle "[E1620] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > EPISODE FORMAT" --title "INFO" --msgbox "Episode format 'xmltv_ns' enabled!" 5 40 + sed -i '/episode=/d' /tmp/settings_new + echo "episode=xmltv_ns" >> /tmp/settings_new + echo "H" > /tmp/value + + # E16X0 EXIT + else + echo "H" > /tmp/value + fi + + + # ###################### + # E1700 RUN XML SCRIPT # + # ###################### + + elif grep -q "7" /tmp/value + then + clear + + echo "" + echo " --------------------------------------------" + echo " TVTV-US EPG SIMPLE XMLTV GRABBER " + echo " " + echo " (c) 2019 Jan-Luca Neumann / sunsettrack4 " + echo " --------------------------------------------" + echo "" + sleep 2s + + bash tvtvus.sh && cd - > /dev/null + + cp tvtvus/de/TVTV-US.xml xml/TVTV-US_de.xml 2> /dev/null + + cd - > /dev/null + + read -n 1 -s -r -p "Press any key to continue..." + echo "H" > /tmp/value + + + # ####################### + # E1900 DELETE INSTANCE # + # ####################### + + elif grep -q "9" /tmp/value + then + # E1900 MENU OVERLAY + dialog --backtitle "[E1900] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > DELETE INSTANCE" --title "WARNING" --yesno "Do you want to delete this service?" 5 50 + + response=$? + + # E1910 NO + if [ $response = 1 ] + then + dialog --backtitle "[E1910] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service not deleted!" 5 32 + echo "H" > /tmp/value + + # E1920 YES + elif [ $response = 0 ] + then + dialog --backtitle "[E1920] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service deleted!" 5 30 + rm channels.json + echo "M" > /tmp/value + + # E19X0 EXIT + elif [ $response = 255 ] + then + dialog --backtitle "[E19X0] EASYEPG SIMPLE XMLTV GRABBER > TVTV-US SETTINGS > DELETE INSTANCE" --title "INFO" --msgbox "Service not deleted!" 5 30 + echo "H" > /tmp/value + fi + + + # ############ + # E1X00 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 diff --git a/tvtvus/tvtvus.sh b/tvtvus/tvtvus.sh new file mode 100644 index 0000000..cf3bc77 --- /dev/null +++ b/tvtvus/tvtvus.sh @@ -0,0 +1,456 @@ +#!/bin/bash + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + + +# ################ +# INITIALIZATION # +# ################ + +# +# SETUP ENVIRONMENT +# + +mkdir cache 2> /dev/null # cache +mkdir day 2> /dev/null # download scripts +mkdir mani 2> /dev/null # manifest files + +if grep -q "USA" init.json 2> /dev/null +then + printf "+++ COUNTRY: USA +++\n\n" +fi + +if grep -q '"day": "0"' settings.json +then + printf "EPG Grabber disabled!\n\n" + exit 0 +fi + +if ! curl --write-out %{http_code} --silent --output /dev/null https://tvtv.us/ | grep -q "200" +then + printf "Service provider unavailable!\n\n" + exit 0 +fi + + +# ################## +# DOWNLOAD PROCESS # +# ################## + +echo "- DOWNLOAD PROCESS -" && echo "" + +# +# DELETE OLD FILES +# + +printf "\rDeleting old files... " + +rm -rf cache/ 2> /dev/null +rm -rf day/ 2> /dev/null +rm -rf mani/ 2> /dev/null +rm /tmp/epg_workfile 2> /dev/null +rm /tmp/workfile 2> /dev/null +rm /tmp/workfile2 2> /dev/null + +mkdir cache 2> /dev/null +mkdir day 2> /dev/null +mkdir mani 2> /dev/null + + +# +# LOADING MANIFEST FILES +# + +printf "\rFetching channel list... " +curl --compressed -s https://tvtv.us/tvm/t/tv/v4/lineups/2381D/ > /tmp/workfile +jq '.' /tmp/workfile > /tmp/chlist + + +printf "\rChecking manifest files... " +perl chlist_printer.pl > /tmp/compare.json +perl url_printer.pl 2>errors.txt | sed '/DUMMY/d' > mani/common + +printf "\n$(echo $(wc -l < mani/common)) manifest file(s) to be downloaded!\n\n" + +if [ $(wc -l < mani/common) -ge 7 ] +then + number=$(echo $(( $(wc -l < mani/common) / 7))) + + split -l $number --numeric-suffixes mani/common mani/day + +else + cp mani/common mani/day00 +fi + +# +# CREATE STATUS INFO FOR MANIFEST FILE DOWNLOAD +# +cp mani/common common + +function status_manifest_download { + #setup_scroll_area + sleep 2 2> /dev/null ; + thread=$(ps ax) + if [[ $thread =~ ^.*curl.*$ ]] ; + then + z0="[ ]" + z5="[# ]" + z10="[## ]" + z15="[### ]" + z20="[#### ]" + z25="[##### ]" + z30="[###### ]" + z35="[####### ]" + z40="[######## ]" + z45="[######### ]" + z50="[########## ]" + z55="[########### ]" + z60="[############ ]" + z65="[############# ]" + z70="[############## ]" + z75="[############### ]" + z80="[################ ]" + z85="[################# ]" + z90="[################## ]" + z95="[################### ]" + z100="[####################]" + + df=$(find mani/ -type f | wc -l) ; + ftd=$(wc -l < mani/common) ; + status=$(expr $df \* 100 / $ftd - 2) ; + if [[ $status -gt 100 || $status -eq 100 ]]; then status="100"; fi + if [[ $status -gt 0 && $status -lt 5 || $status -eq 0 ]]; then bar="$z0"; elif [[ $status -gt 5 && $status -lt 10 ]]; then bar="$z5"; elif [[ $status -gt 10 && $status -lt 15 ]] ; then bar="$z10"; elif [[ $status -gt 15 && $status -lt 20 ]] ; then bar="$z15"; elif [[ $status -gt 20 && $status -lt 25 ]] ; then bar="$z20"; elif [[ $status -gt 25 && $status -lt 30 ]] ; then bar="$z25"; elif [[ $status -gt 30 && $status -lt 35 ]] ; then bar="$z30"; elif [[ $status -gt 35 && $status -lt 40 ]] ; then bar="$z35"; elif [[ $status -gt 40 && $status -lt 45 ]] ; then bar="$z40"; elif [[ $status -gt 40 && $status -lt 50 ]] ; then bar="$z45"; elif [[ $status -gt 50 && $status -lt 55 ]] ; then bar="$z50"; elif [[ $status -gt 55 && $status -lt 60 ]] ; then bar="$z55"; elif [[ $status -gt 60 && $status -lt 65 ]] ; then bar="$z60"; elif [[ $status -gt 60 && $status -lt 70 ]] ; then bar="$z65"; elif [[ $status -gt 70 && $status -lt 75 ]] ; then bar="$z70"; elif [[ $status -gt 70 && $status -lt 80 ]] ; then bar="$z75"; elif [[ $status -gt 80 && $status -lt 85 ]] ; then bar="$z80"; elif [[ $status -gt 85 && $status -lt 90 ]] ; then bar="$z85"; elif [[ $status -gt 90 && $status -lt 95 ]] ; then bar="$z90"; elif [[ $status -gt 95 && $status -lt 100 ]] ; then bar="$z95"; elif [ $status -eq 100 ] ; then bar="$z100";fi + printf "\rProgress $bar $status%% "; + status_manifest_download ; + fi + } + +# +# CREATE MANIFEST DOWNLOAD SCRIPTS +# + +for time in {0..8..1} +do + sed -i '1i#\!\/bin\/bash\n' mani/day0${time} 2> /dev/null +done + + +# +# COPY/PASTE EPG DETAILS +# + +printf "\rLoading manifest files..." +echo "" +printf "\rProgress [ ] 0%% " + +status_manifest_download & + +for a in {0..8..1} +do + bash mani/day0${a} 2> /dev/null & +done +wait + +rm mani/day0* 2> /dev/null && rm mani/common 2> /dev/null + +printf "\rProgress [####################] 100%% " +echo "DONE!" && printf "\n" + + +# +# CREATE EPG BROADCAST LIST +# + +printf "\rCreating EPG manifest file... " + +rm /tmp/manifile.json 2> /dev/null +cat mani/* > /tmp/manifile.json +cp /tmp/manifile.json manifile.json +jq -s '.' /tmp/manifile.json > /tmp/epg_workfile 2>>errors.txt +sed -i '1s/\[/{ "attributes":[/g;$s/\]/&}/g' /tmp/epg_workfile + +cp /tmp/epg_workfile epg_workfile.json +rm mani/* +echo "DONE!" && printf "\n" +perl compare_crid.pl > day/daydlnew + +# +# SHOW ERROR MESSAGE + ABORT PROCESS IF CHANNEL IDs WERE CHANGED +# + +sort -u errors.txt > /tmp/errors_sorted.txt && mv /tmp/errors_sorted.txt errors.txt + +if [ -s errors.txt ] +then + echo "================= CHANNEL LIST: LOG ===================" + echo "" + + input="errors.txt" + while IFS= read -r var + do + echo "$var" + done < "$input" + + echo "" + echo "=======================================================" + echo "" + + cp /tmp/chlist chlist_old +else + rm errors.txt 2> /dev/null +fi + +# +# DOWNLOAD EPG DETAILS +# + +printf "\rPreparing multithreaded download... " + +sed "s/.*/curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https:\/\/tvtv.us\/tvm\/t\/tv\/v4\/episodes\/&' | grep 'seriesID' > cache\/&/g" day/daydlnew > day/common + +sed -i '/^$/d' day/common +sort -u day/common | uniq > /tmp/common +cp /tmp/common day/common +printf "\n$(echo $(wc -l < day/common)) broadasts files to be downloaded!\n\n" +if [ $(wc -l < day/common) -ge 32 ] +then + number=$(echo $(( $(wc -l < day/common) / 32))) + + split -l $number --numeric-suffixes day/common day/day + +else + cp day/common day/day00 +fi + + +# +# CREATE STATUS BAR FOR DOWNLOAD SCRIPT +# + +function status_detail_download { + #setup_scroll_area + sleep 2 2> /dev/null ; + thread=$(ps ax) + if [[ $thread =~ ^.*curl.*$ ]] ; + then + z0="[ ]" + z5="[# ]" + z10="[## ]" + z15="[### ]" + z20="[#### ]" + z25="[##### ]" + z30="[###### ]" + z35="[####### ]" + z40="[######## ]" + z45="[######### ]" + z50="[########## ]" + z55="[########### ]" + z60="[############ ]" + z65="[############# ]" + z70="[############## ]" + z75="[############### ]" + z80="[################ ]" + z85="[################# ]" + z90="[################## ]" + z95="[################### ]" + z100="[####################]" + + df=$(find cache -type f | wc -l) ; + ftd=$(wc -l < day/common) ; + status=$(expr $df \* 100 / $ftd) ; + if [[ $status -gt 100 || $status -eq 100 ]]; then status="100"; fi + if [[ $status -gt 0 && $status -lt 5 || $status -eq 0 ]]; then bar="$z0"; elif [[ $status -gt 5 && $status -lt 10 ]]; then bar="$z5"; elif [[ $status -gt 10 && $status -lt 15 ]] ; then bar="$z10"; elif [[ $status -gt 15 && $status -lt 20 ]] ; then bar="$z15"; elif [[ $status -gt 20 && $status -lt 25 ]] ; then bar="$z20"; elif [[ $status -gt 25 && $status -lt 30 ]] ; then bar="$z25"; elif [[ $status -gt 30 && $status -lt 35 ]] ; then bar="$z30"; elif [[ $status -gt 35 && $status -lt 40 ]] ; then bar="$z35"; elif [[ $status -gt 40 && $status -lt 45 ]] ; then bar="$z40"; elif [[ $status -gt 40 && $status -lt 50 ]] ; then bar="$z45"; elif [[ $status -gt 50 && $status -lt 55 ]] ; then bar="$z50"; elif [[ $status -gt 55 && $status -lt 60 ]] ; then bar="$z55"; elif [[ $status -gt 60 && $status -lt 65 ]] ; then bar="$z60"; elif [[ $status -gt 60 && $status -lt 70 ]] ; then bar="$z65"; elif [[ $status -gt 70 && $status -lt 75 ]] ; then bar="$z70"; elif [[ $status -gt 70 && $status -lt 80 ]] ; then bar="$z75"; elif [[ $status -gt 80 && $status -lt 85 ]] ; then bar="$z80"; elif [[ $status -gt 85 && $status -lt 90 ]] ; then bar="$z85"; elif [[ $status -gt 90 && $status -lt 95 ]] ; then bar="$z90"; elif [[ $status -gt 95 && $status -lt 100 ]] ; then bar="$z95"; elif [ $status -eq 100 ] ; then bar="$z100";fi + printf "\rProgress $bar $status%% "; + status_detail_download ; + fi + } + + +# +# CREATE DOWNLOAD SCRIPTS +# + +for time in {0..33..1} +do + sed -i '1s/.*/#\!\/bin\/bash\n&/g' day/day0${time} 2> /dev/null & sed -i '1s/.*/#\!\/bin\/bash\n&/g' day/day0${time} 2> /dev/null +done + + +# +# DOWNLOAD EPG DETAILS +# + +printf "\rDownloading EPG details... " +echo "" +printf "\rProgress [ ] 0%% " + +status_detail_download & + +for a in {0..33..1} +do + bash day/day0${a} 2> /dev/null & bash day/day${a} 2> /dev/null & +done +wait + +rm day/* + +printf "\rProgress [####################] 100%% " +echo "DONE!" && printf "\n" + +# +# EXPORT 0BYTE EPGDETAILS AND TRY TO REDOWNLOAD +# + +find cache -size 0 | sed 's/cache\///g' >missingbroadcasts +touch broadcast_warnings.txt + +if [ -s missingbroadcasts ] +then + echo "Missing Broadcastfiles Detected" && printf "\n" + printf "\rWaiting for 10 Seconds" + sleep 10 + printf "\rPreparing Broadcastdatabase (TVTV seems to hate Screen-Scrapper)... " + echo "" + find cache -size 0 | sed 's/cache\///g' >day/daydlnew + sed "s/.*/curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https:\/\/tvtv.us\/tvm\/t\/tv\/v4\/episodes\/&' | grep 'seriesID' > cache\/&/g" day/daydlnew > day/common + sed -i '1s/.*/#\!\/bin\/bash\n&/g' day/common 2> /dev/null + sed -i '/^$/d' day/common + printf "\n$(echo $(wc -l < day/common)) missing Broadastsfiles to be downloaded!\n\n" + bash day/common 2> /dev/null & wait + find cache -size 0 | sed 's/cache\///g' >missingbroadcasts + if [ -s missingbroadcasts ] + then + sed 's/.*/\[ EPG WARNING ] FAILED TO DOWNLOAD BROADCASTFILES &/g' missingbroadcasts >broadcast_warnings.txt + fi +fi + +rm missingbroadcasts +rm day/* 2> /dev/null + +echo "DONE!" && printf "\n" + +# ################### +# CREATE XMLTV FILE # +# ################### + +# WORK IN PROGRESS + +echo "- FILE CREATION PROCESS -" && echo "" + +rm workfile chlist 2> /dev/null + + +# DOWNLOAD CHANNEL LIST + RYTEC/EIT CONFIG FILES (JSON) +printf "\rRetrieving channel list and config files... " +curl --compressed -s https://tvtv.us/tvm/t/tv/v4/lineups/2381D/ > /tmp/chlist +jq '.' /tmp/chlist > chlist + +cp chlist /tmp/chlist +curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/tvtvus_channels.json > tvtvus_channels.json +curl -s https://raw.githubusercontent.com/sunsettrack4/config_files/master/tvtvus_genres.json > tvtvus_genres.json + +# CONVERT JSON INTO XML: CHANNELS +printf "\rConverting CHANNEL JSON file into XML format... " +perl ch_json2xml.pl 2>warnings.txt > tvtv-us_channels +sort -u tvtv-us_channels > /tmp/tvtv-us_channels && mv /tmp/tvtv-us_channels tvtv-us_channels +sed -i 's/>\n tvtvus_cid.json && rm chlist + +# CONVERT JSON INTO XML: EPG +printf "\rConverting EPG JSON file into XML format... " +perl epg_json2xml.pl > tvtv-us_epg 2>epg_warnings.txt && rm /tmp/epg_workfile 2> /dev/null + + +# COMBINE: CHANNELS + EPG +printf "\rCreating EPG XMLTV file... " +cat tvtv-us_epg >> tvtv-us_channels && mv tvtv-us_channels tvtv-us && rm tvtv-us_epg +sed -i '1i\n<\!-- EPG XMLTV FILE CREATED BY THE EASYEPG PROJECT - (c) 2019 Jan-Luca Neumann -->\n' tvtv-us +sed -i "s//<\!-- created on $(date) -->\n&\n\n\n/g" tvtv-us +sed -i '$s/.*/&\n\n<\/tv>/g' tvtv-us +mv tvtv-us tvtv-us.xml + +# VALIDATING XML FILE +printf "\rValidating EPG XMLTV file..." +xmllint --noout tvtv-us.xml > errorlog 2>&1 + +if grep -q "parser error" errorlog +then + printf " DONE!\n\n" + mv tvtv-us.xml tvtv-us_ERROR.xml + echo "[ EPG ERROR ] XMLTV FILE VALIDATION FAILED DUE TO THE FOLLOWING ERRORS:" >> warnings.txt + cat errorlog >> warnings.txt +else + printf " DONE!\n\n" + rm tvtv-us_ERROR.xml 2> /dev/null + rm errorlog 2> /dev/null + + if ! grep -q "> errorlog + fi + + if ! grep "> errorlog + fi + + uniq -d /tmp/id_check > /tmp/id_checked + if [ -s /tmp/id_checked ] + then + echo "[ EPG ERROR ] XMLTV FILE CONTAINS DUPLICATED CHANNEL IDs!" >> errorlog + sed -i 's/.*/[ DUPLICATE ] &/g' /tmp/id_checked && cat /tmp/id_checked >> errorlog + rm /tmp/id_check /tmp/id_checked 2> /dev/null + else + rm /tmp/id_check /tmp/id_checked 2> /dev/null + fi + + if [ -e errorlog ] + then + mv tvtv-us.xml tvtv-us_ERROR.xml + cat errorlog >> warnings.txt + else + rm errorlog 2> /dev/null + fi +fi + + +# SHOW WARNINGS +cat epg_warnings.txt >> warnings.txt && rm epg_warnings.txt +sort -u warnings.txt > sorted_warnings.txt && mv sorted_warnings.txt warnings.txt +sed -i '/^$/d' warnings.txt + +if [ -s warnings.txt ] +then + echo "========== EPG CREATION: WARNING/ERROR LOG ============" + echo "" + + input="warnings.txt" + while IFS= read -r var + do + echo "$var" + done < "$input" + + echo "" + echo "=======================================================" + echo "" +fi diff --git a/tvtvus/url_printer.pl b/tvtvus/url_printer.pl new file mode 100644 index 0000000..df69dec --- /dev/null +++ b/tvtvus/url_printer.pl @@ -0,0 +1,175 @@ +#!/usr/bin/perl + +# Copyright (C) 2019 Jan-Luca Neumann +# https://github.com/sunsettrack4/easyepg +# +# 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 . + +# ################################# +# TVTV-US TV MANIFEST URL PRINTER # +# ################################# + +use strict; +use warnings; + +binmode STDOUT, ":utf8"; +use utf8; + +use JSON; +use Time::Piece; +use Time::Seconds; + +# READ CHANNEL FILE +my $channels; +{ + local $/; #Enable 'slurp' mode + open my $fh, '<', "/tmp/compare.json" or die; + $channels = <$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 $channels_data = decode_json($channels); +my $settings_data = decode_json($settings); + +# SET DAY SETTING +my $day_setting = $settings_data->{'settings'}{'day'}; + +# SET DATE VALUES +my $time1 = Time::Piece->new; +my $time2 = $time1 + 86400; +my $time3 = $time1 + 172800; +my $time4 = $time1 + 259200; +my $time5 = $time1 + 345600; +my $time6 = $time1 + 432000; +my $time7 = $time1 + 518400; +my $time8 = $time1 + 604800; +my $time9 = $time1 + 691200; +my $time_10 = $time1 + 777600; +my $time_11 = $time1 + 864000; +my $time_12 = $time1 + 950400; +my $time_13 = $time1 + 1036800; +my $time_14 = $time1 + 1123200; +my $time_15 = $time1 + 1209600; + +my $date1 = $time1->strftime('%Y-%m-%d'); +my $date2 = $time2->strftime('%Y-%m-%d'); +my $date3 = $time3->strftime('%Y-%m-%d'); +my $date4 = $time4->strftime('%Y-%m-%d'); +my $date5 = $time5->strftime('%Y-%m-%d'); +my $date6 = $time6->strftime('%Y-%m-%d'); +my $date7 = $time7->strftime('%Y-%m-%d'); +my $date8 = $time8->strftime('%Y-%m-%d'); +my $date9 = $time9->strftime('%Y-%m-%d'); +my $date_10 = $time_10->strftime('%Y-%m-%d'); +my $date_11 = $time_11->strftime('%Y-%m-%d'); +my $date_12 = $time_12->strftime('%Y-%m-%d'); +my $date_13 = $time_13->strftime('%Y-%m-%d'); +my $date_14 = $time_14->strftime('%Y-%m-%d'); +my $date_15 = $time_15->strftime('%Y-%m-%d'); + +# DEFINE COMPARE DATA +my $new_name2id = $channels_data->{'newname2id'}; +my $new_id2name = $channels_data->{'newid2name'}; +my $old_name2id = $channels_data->{'oldname2id'}; +my $old_id2name = $channels_data->{'oldid2name'}; +my @configname = @{ $channels_data->{'config'} }; + + +# +# DOWNLOAD CHANNEL MANIFESTS +# + +foreach my $configname ( @configname ) { + + # DEFINE IDs + my $new_id = $new_name2id->{$configname}; + + # IF MATCH NOT FOUND: FIND CHANNEL NAME IN NEW CHANNEL LIST + if( defined $new_id ) { + + # DAY 1 + if( $day_setting == 1 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date2 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-2 + } elsif( $day_setting == 2 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date3 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-3 + } elsif( $day_setting == 3 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date4 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-4 + } elsif( $day_setting == 4 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date5 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-5 + } elsif( $day_setting == 5 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date6 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-6 + } elsif( $day_setting == 6 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date7 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-7 + } elsif( $day_setting == 7 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date8 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-8 + } elsif( $day_setting == 8 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date9 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-9 + } elsif( $day_setting == 9 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_10 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-10 + } elsif( $day_setting == 10 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_11 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-11 + } elsif( $day_setting == 11 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_12 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-12 + } elsif( $day_setting == 12 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_13 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-13 + } elsif( $day_setting == 13 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_14 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + # DAYS 1-14 + } elsif( $day_setting == 14 ) { + print "curl -s --compressed --connect-timeout 2 --max-time 10 --retry 8 --retry-delay 0 --retry-max-time 5 'https://tvtv.us/tvm/t/tv/v4/lineups/2381D/listings/grid?detail=%27brief%27&start=" . $date1 . "T00:00Z&end=" . $date_15 . "T23:59Z&startchan=" . $new_id . "&endchan=" . $new_id . "' | sed 's/\\[//' | sed 's/.\$//' | grep \"$new_id\" > mani/$new_id\n" ; + + } + + } else { + print STDERR "[ CHLIST WARNING ] CHANNEL \"$configname\" not found in channel list!\n"; + } +}