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

Commit

Permalink
Add Provider TVTV-US
Browse files Browse the repository at this point in the history
  • Loading branch information
DeBaschdi authored Jan 8, 2020
1 parent 507f7f0 commit 7b91054
Show file tree
Hide file tree
Showing 11 changed files with 2,097 additions and 0 deletions.
143 changes: 143 additions & 0 deletions tvtvus/ch_json2xml.pl
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

# ###############################
# 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/\&/\&amp;/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 "<channel id=\"" . $rytec->{$cname} . "\">";
} else {
print "<channel id=\"" . $cname . "\">";
print STDERR "[ CHLIST WARNING ] Rytec ID not matched for: " . $cname . "\n";
}
} else {
print "<channel id=\"" . $cname . "\">";
}

# CHANNEL NAME (language)
print "<display-name lang=\"de\">" . $cname . "</display-name></channel>\n";
}
}
}
179 changes: 179 additions & 0 deletions tvtvus/chlist_printer.pl
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

# ################################
# 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/\&/\&amp;/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/\&/\&amp;/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/\&/\&amp;/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/\&/\&amp;/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}";
72 changes: 72 additions & 0 deletions tvtvus/cid_json.pl
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

# ###############################
# 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/\&/\&amp;/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}";
Loading

0 comments on commit 7b91054

Please sign in to comment.