This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Horizon: Add terminal GUI, modify channel list; add settings
- Loading branch information
1 parent
7b22cb0
commit 5ce8768
Showing
9 changed files
with
2,011 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY | ||
|
||
# DEFINE NEW CHANNEL ID | ||
my $newcid = $newitem->{'id'}; | ||
|
||
# PRINT NEW CHANNEL NAMES | ||
print "\"$newcname\": \"$newcid\",\n"; | ||
} | ||
} | ||
|
||
# TOOL: ID ==> NAME | ||
|
||
print "\"DUMMY\": \"DUMMY\" },\n\"newid2name\": {\n"; | ||
|
||
my @newchannels_id2name = @{ $newdata->{'channels'} }; | ||
foreach my $newchannels ( @newchannels_id2name ) { | ||
my @newschedule = @{ $newchannels->{'stationSchedules'} }; | ||
|
||
foreach my $newschedule ( @newschedule ) { | ||
my $newitem = $newschedule->{'station'}; | ||
|
||
# | ||
# DEFINE JSON VALUES | ||
# | ||
|
||
# DEFINE NEW CHANNEL NAME | ||
my $newcname = $newitem->{'title'}; | ||
$newcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY | ||
|
||
# DEFINE NEW CHANNEL ID | ||
my $newcid = $newitem->{'id'}; | ||
|
||
# PRINT NEW CHANNEL NAMES newcid | ||
print "\"$newcid\": \"$newcname\",\n"; | ||
} | ||
} | ||
|
||
|
||
# ################## | ||
# OLD CHANNEL LIST # | ||
# ################## | ||
|
||
# TOOL: NAME ==> ID | ||
|
||
print "\"DUMMY\": \"DUMMY\" },\n\"oldname2id\": {\n"; | ||
|
||
my @oldchannels_name2id = @{ $olddata->{'channels'} }; | ||
foreach my $oldchannels ( @oldchannels_name2id ) { | ||
my @oldschedule = @{ $oldchannels->{'stationSchedules'} }; | ||
|
||
foreach my $oldschedule ( @oldschedule ) { | ||
my $olditem = $oldschedule->{'station'}; | ||
|
||
# | ||
# DEFINE JSON VALUES | ||
# | ||
|
||
# DEFINE OLD CHANNEL NAME | ||
my $oldcname = $olditem->{'title'}; | ||
$oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY | ||
|
||
# DEFINE OLD CHANNEL ID | ||
my $oldcid = $olditem->{'id'}; | ||
|
||
# PRINT OLD CHANNEL NAMES | ||
print "\"$oldcname\": \"$oldcid\",\n"; | ||
} | ||
} | ||
|
||
# TOOL: ID ==> NAME | ||
|
||
print "\"DUMMY\": \"DUMMY\" },\n\"oldid2name\": {\n"; | ||
|
||
my @oldchannels_id2name = @{ $olddata->{'channels'} }; | ||
foreach my $oldchannels ( @oldchannels_id2name ) { | ||
my @oldschedule = @{ $oldchannels->{'stationSchedules'} }; | ||
|
||
foreach my $oldschedule ( @oldschedule ) { | ||
my $olditem = $oldschedule->{'station'}; | ||
|
||
# | ||
# DEFINE JSON VALUES | ||
# | ||
|
||
# DEFINE OLD CHANNEL NAME | ||
my $oldcname = $olditem->{'title'}; | ||
$oldcname =~ s/\&/\&/g; # REQUIRED TO READ XML FILE CORRECTLY | ||
|
||
# DEFINE OLD CHANNEL ID | ||
my $oldcid = $olditem->{'id'}; | ||
|
||
# PRINT OLD CHANNEL NAMES | ||
print "\"$oldcid\": \"$oldcname\",\n"; | ||
} | ||
} | ||
|
||
|
||
# ####################### | ||
# CHANNEL CONFIGURATION # | ||
# ####################### | ||
|
||
print "\"DUMMY\": \"DUMMY\" },\n\"config\": [\n"; | ||
|
||
my @configdata = @{ $configdata->{'channels'} }; | ||
|
||
foreach my $configname ( @configdata ) { | ||
print "\"$configname\",\n"; | ||
} | ||
|
||
print "\"DUMMY\"]\n}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.