Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

Commit

Permalink
Horizon: Add terminal GUI, modify channel list; add settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsettrack4 committed Mar 18, 2019
1 parent 7b22cb0 commit 5ce8768
Show file tree
Hide file tree
Showing 9 changed files with 2,011 additions and 154 deletions.
949 changes: 949 additions & 0 deletions epg.sh

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hzn/ch_json2xml.pl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
print "<channel id=\"" . $rytec->{$cname} . "\">\n";
} else {
print "<channel id=\"" . $cname . "\">\n";
print STDERR "CHLIST WARNING: Channel ID unknown: " . $cname . "\n";
print STDERR "[ CHLIST WARNING ] Channel ID unknown: " . $cname . "\n";
}

# CHANNEL NAME (language)
Expand Down
199 changes: 199 additions & 0 deletions hzn/chlist_printer.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#!/usr/bin/perl

# Copyright (C) 2019 Jan-Luca Neumann
# https://github.com/sunsettrack4/easyepg/hzn
#
# Collaborators:
# - DeBaschdi ( https://github.com/DeBaschdi )
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with easyepg. If not, see <http://www.gnu.org/licenses/>.

# ##############################
# HORIZON CHANNEL LIST CREATOR #
# ##############################

# CREATE JSON FILE FOR COMPARISM

use strict;
use warnings;

binmode STDOUT, ":utf8";
use utf8;

use JSON;

# READ JSON INPUT FILE: NEW CHLIST
my $chlist_new;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "/tmp/chlist" or die;
$chlist_new = <$fh>;
close $fh;
}

# READ JSON INPUT FILE: OLD CHLIST
my $chlist_old;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "chlist_old" or die;
$chlist_old = <$fh>;
close $fh;
}

# READ JSON INPUT FILE: CHANNEL CONFIG
my $chlist_config;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "channels.json" or die;
$chlist_config = <$fh>;
close $fh;
}

# CONVERT JSON TO PERL STRUCTURES
my $newdata = decode_json($chlist_new);
my $olddata = decode_json($chlist_old);
my $configdata = decode_json($chlist_config);


# ##################
# NEW CHANNEL LIST #
# ##################

# TOOL: NAME ==> ID

print "{ \"newname2id\": {\n";

my @newchannels_name2id = @{ $newdata->{'channels'} };
foreach my $newchannels ( @newchannels_name2id ) {
my @newschedule = @{ $newchannels->{'stationSchedules'} };

foreach my $newschedule ( @newschedule ) {
my $newitem = $newschedule->{'station'};

#
# DEFINE JSON VALUES
#

# DEFINE NEW CHANNEL NAME
my $newcname = $newitem->{'title'};
$newcname =~ s/\&/\&amp;/g; # REQUIRED TO READ XML FILE CORRECTLY

# DEFINE NEW CHANNEL ID
my $newcid = $newitem->{'id'};

# PRINT NEW CHANNEL NAMES
print "\"$newcname\": \"$newcid\",\n";
}
}

# TOOL: ID ==> NAME

print "\"DUMMY\": \"DUMMY\" },\n\"newid2name\": {\n";

my @newchannels_id2name = @{ $newdata->{'channels'} };
foreach my $newchannels ( @newchannels_id2name ) {
my @newschedule = @{ $newchannels->{'stationSchedules'} };

foreach my $newschedule ( @newschedule ) {
my $newitem = $newschedule->{'station'};

#
# DEFINE JSON VALUES
#

# DEFINE NEW CHANNEL NAME
my $newcname = $newitem->{'title'};
$newcname =~ s/\&/\&amp;/g; # REQUIRED TO READ XML FILE CORRECTLY

# DEFINE NEW CHANNEL ID
my $newcid = $newitem->{'id'};

# PRINT NEW CHANNEL NAMES newcid
print "\"$newcid\": \"$newcname\",\n";
}
}


# ##################
# OLD CHANNEL LIST #
# ##################

# TOOL: NAME ==> ID

print "\"DUMMY\": \"DUMMY\" },\n\"oldname2id\": {\n";

my @oldchannels_name2id = @{ $olddata->{'channels'} };
foreach my $oldchannels ( @oldchannels_name2id ) {
my @oldschedule = @{ $oldchannels->{'stationSchedules'} };

foreach my $oldschedule ( @oldschedule ) {
my $olditem = $oldschedule->{'station'};

#
# DEFINE JSON VALUES
#

# DEFINE OLD CHANNEL NAME
my $oldcname = $olditem->{'title'};
$oldcname =~ s/\&/\&amp;/g; # REQUIRED TO READ XML FILE CORRECTLY

# DEFINE OLD CHANNEL ID
my $oldcid = $olditem->{'id'};

# PRINT OLD CHANNEL NAMES
print "\"$oldcname\": \"$oldcid\",\n";
}
}

# TOOL: ID ==> NAME

print "\"DUMMY\": \"DUMMY\" },\n\"oldid2name\": {\n";

my @oldchannels_id2name = @{ $olddata->{'channels'} };
foreach my $oldchannels ( @oldchannels_id2name ) {
my @oldschedule = @{ $oldchannels->{'stationSchedules'} };

foreach my $oldschedule ( @oldschedule ) {
my $olditem = $oldschedule->{'station'};

#
# DEFINE JSON VALUES
#

# DEFINE OLD CHANNEL NAME
my $oldcname = $olditem->{'title'};
$oldcname =~ s/\&/\&amp;/g; # REQUIRED TO READ XML FILE CORRECTLY

# DEFINE OLD CHANNEL ID
my $oldcid = $olditem->{'id'};

# PRINT OLD CHANNEL NAMES
print "\"$oldcid\": \"$oldcname\",\n";
}
}


# #######################
# CHANNEL CONFIGURATION #
# #######################

print "\"DUMMY\": \"DUMMY\" },\n\"config\": [\n";

my @configdata = @{ $configdata->{'channels'} };

foreach my $configname ( @configdata ) {
print "\"$configname\",\n";
}

print "\"DUMMY\"]\n}";
2 changes: 1 addition & 1 deletion hzn/cid_json.pl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
my $json;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "chlist" or die;
open my $fh, "<", "/tmp/chlist" or die;
$json = <$fh>;
close $fh;
}
Expand Down
112 changes: 112 additions & 0 deletions hzn/compare_crid.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/perl

# Copyright (C) 2019 Jan-Luca Neumann
# https://github.com/sunsettrack4/easyepg/hzn
#
# Collaborators:
# - DeBaschdi ( https://github.com/DeBaschdi )
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with easyepg. If not, see <http://www.gnu.org/licenses/>.

# ##############################
# HORIZON CHANNEL LIST CREATOR #
# ##############################

# COMPARE STRINGS, CREATE CRID LIST

use strict;
use warnings;

binmode STDOUT, ":utf8";
use utf8;

use JSON;

# READ JSON INPUT FILE: COMPARISM LIST
my $compare;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "/tmp/compare.json" or die;
$compare = <$fh>;
close $fh;
}

# READ JSON INPUT FILE: PROGRAMME LIST
my $programme;
{
local $/; #Enable 'slurp' mode
open my $fh, "<", "day/dayNUMBER" or die;
$programme = <$fh>;
close $fh;
}

# CONVERT JSON TO PERL STRUCTURES
my $comparedata = decode_json($compare);
my $programmedata = decode_json($programme);

#
# DEFINE JSON VALUES
#

# DEFINE COMPARE DATA
my $new_name2id = $comparedata->{'newname2id'};
my $new_id2name = $comparedata->{'newid2name'};
my $old_name2id = $comparedata->{'oldname2id'};
my $old_id2name = $comparedata->{'oldid2name'};
my @configname = @{ $comparedata->{'config'} };

# DEFINE PROGRAMME STRINGS
my @entries = @{ $programmedata->{'entries'} };

my $crid = "i";
my $crid_location;

#
# COMPARE VALUES + CREATE CRID LIST
#

foreach my $entries ( @entries ) {
my @lid = @{ $entries->{'l'} };
my $oid = $entries->{'o'};

foreach my $lid ( @lid ) {
my $crid = $lid->{'i'};

foreach my $configname ( @configname ) {

my $old_id = $old_name2id->{$configname};

# FIND MATCH VIA NEW CHANNEL NAME + CONFIG NAME
if( defined $new_name2id->{$configname} ) {
my $matched_id = $new_name2id->{$configname};

if( $oid eq $matched_id ) {
print $crid . "\n";
}

# IF MATCH NOT FOUND FOR NEW CHANNEL NAME: FIND MATCH VIA OLD CHANNEL NAME + CONFIG NAME
} elsif( defined $old_id ) {
if( defined $new_id2name->{$old_id} ) {
print STDERR "[ INFO ] CHANNEL \"$configname\" received new Channel Name!\n";

if ( $oid eq $old_id ) {
print $crid . "\n";
}
}
} else {
print STDERR "[ INFO ] CHANNEL $configname not found in channel lists!\n";
}
}
}
}
Loading

0 comments on commit 5ce8768

Please sign in to comment.