Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified README.md
100644 → 100755
Empty file.
129 changes: 129 additions & 0 deletions mythweb/mythweb_chan_recon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
Copyright 2021 Myers Enterprises II

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Installation:
copy this file to /var/www/html/mythweb/
sudo apt install php-sqlite3

Configuration:
In /etc/apache2/sites-available/mythweb.conf change <Files mythweb.*> to <Files mythweb*.p*>
sudo service apache2 restart
sudo chmod a+w /home/mythtv/.xmltv
sudo chmod a+w /home/mythtv/.xmltv/SchedulesDirect.DB

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MythTV Channel Reconciliation</title>
<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/table_sort.js'></script>
</head>
<body>
<h1>MythTV Channel Reconciliation</h1>
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ini_set("display_errors", 1);

$slconn = new PDO('sqlite:/home/mythtv/.xmltv/SchedulesDirect.DB');
$slconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$msconn = new PDO("mysql:host={$_SERVER['db_server']};dbname={$_SERVER['db_name']};charset=utf8", $_SERVER['db_login'], $_SERVER['db_password']);
$msconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';

if ($action == 'setXMLTV') {
$channum = $_REQUEST['channum'];
$val = $_REQUEST['val'];

$sql = "UPDATE channels SET selected = $val WHERE channum = '$channum'";
$slconn->exec($sql);
}

// Load mythtv channel table
$sql = 'SELECT * FROM channel ORDER BY chanid';
$sth = $msconn->query($sql);
$sth->setFetchMode(PDO::FETCH_NAMED);
$myth_channels = [];

while ($row = $sth->fetch()) {
$channum = $row['channum'];
if (strpos($channum, '_') === false) continue; // Analog
if ($channum[0] == '_') continue; // Borked

list($chan, $sub) = explode('_', $channum);
$channum = "$chan.$sub";
$row['XMLTV_selected'] = 'missing';
$row['channum'] = $channum;

$myth_channels[$channum] = $row;
}

// Load the XMLTV channels, stations tables
$sql = 'SELECT channum, selected FROM channels';
$sth = $slconn->query($sql);
$sth->setFetchMode(PDO::FETCH_NAMED);

while ($row = $sth->fetch()) {
$channum = $row['channum'];
if (strpos($channum, '.') === false) continue; // Analog

if (! isset($myth_channels[$channum])) continue;
$myth_channels[$channum]['XMLTV_selected'] = $row['selected'];
}

uasort($myth_channels, function ($a, $b) {
list($achan, $asub) = explode('.', $a['channum']);
list($bchan, $bsub) = explode('.', $b['channum']);

if ($achan != $bchan) return ($achan <=> $bchan);
return ($asub <=> $bsub);
});

?>
<table id="channel_list" sortable=true>
<thead><tr><th>channum</th><th>freqid</th><th>name</th><th>visible</th><th>XMLTV<br />selected</th></tr></thead><tbody>
<?php
$prev_freq = '';

foreach ($myth_channels as $channum => $chan) {
$rowcolor = '';
if ($chan['visible'] != $chan['XMLTV_selected']) $rowcolor = ' style="background-color:#eee8e0;"';

$freq = $chan['freqid'];

if ($freq != $prev_freq) $prev_freq = $freq;
else $freq = '&nbsp';

$name = $chan['name'];
if (preg_match('!^\d+\.\d+ (.*)$!', $name, $matches)) {
$name = $matches[1];
}

$XMLTV_checked = '';
if ($chan['XMLTV_selected']) $XMLTV_checked = 'checked';
$href = "\"mythweb_chan_recon.php?action=setXMLTV&amp;channum=$channum&amp;val=\" + val";

echo "<tr$rowcolor><td>$channum</td><td>$freq</td><td>$name</td><td style='text-align: center;'>{$chan['visible']}</td><td style='text-align: center;'>";
echo "<input type='checkbox' id='$channum' autocomplete='off' $XMLTV_checked onchange='var val=\"0\"; if (this.checked) val=\"1\"; location.href=$href;' />";
echo "</td></tr>\n";
}
?>
</tbody>
</table>
</body>
3 changes: 2 additions & 1 deletion pi-SDtoHD-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ echo -e "Configuring boot from $target_partition"
# rootdelay=5 is likely not necessary here, but does no harm.
cp /boot/cmdline.txt /boot/cmdline.txt.bak
sed -i "s/\( root=PARTUUID=*\)[^ ]*/\1${target_partition_partuuid} rootdelay=5 /" /boot/cmdline.txt
sed -i "s/\( root=\)\/[^ ]*/\1PARTUUID=${target_partition_partuuid} rootdelay=5 /" /boot/cmdline.txt
sync
echo "Commenting out old root partition in /etc/fstab, adding new one"
# These changes are made on the new drive after copying so that they
# don't have to be undone in order to switch back to booting from the
# SD card.
sed -i -r '/-02/s/^/#/' /mnt/etc/fstab
sed -i -r '/\/[ \t]*ext4/s/^/#/' /mnt/etc/fstab
sync
echo "/dev/disk/by-uuid/${target_partition_uuid} / ext4 defaults,noatime 0 1" >> /mnt/etc/fstab
echo "Your new root drive is currently accessible under /mnt."
Expand Down
21 changes: 8 additions & 13 deletions pi-setup_mythtv_31.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
# Globals

#mythtv-light version
MYTHTV_LIGHT_VERSION="deb http://dl.bintray.com/bennettpeter/deb/ buster myth31"
MYTHTV_LIGHT_KEY="https://bintray.com/user/downloadSubjectPublicKey?username=bintray"
MYTITLE="MythTV Setup for Raspberry Pi"

# my pi-utils repository
PI_UTILS_REPO="https://github.com/MikeB2013/pi-utils.git"
PI_UTILS_REPO="https://github.com/Bamyers99/pi-utils.git"

# for whiptail items 0=Yes, 1=No -1=error (not currently checked)
DEFAULT_INSTALL=0
Expand Down Expand Up @@ -94,23 +92,20 @@ echo -e "A reboot is required, please type sudo reboot\n"

do_install_mythtv_from_repo()
{
#setup sources.list
ALREADY_ADDED=$(grep -ic "$MYTHTV_LIGHT_VERSION" /etc/apt/sources.list)
#don't add more than once - it generates apt warnings (harmless)
if [ $ALREADY_ADDED = 0 ] ; then
echo "$MYTHTV_LIGHT_VERSION" | sudo tee -a /etc/apt/sources.list
#setup bintray key
wget -O - $MYTHTV_LIGHT_KEY | sudo apt-key add -
fi

# install mythtv-light
# first make sure we are upto date.
sudo apt update
sudo apt upgrade -y
sudo apt install git mythtv-light -y
sudo apt install git gdebi-core -y

#wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1mG4dHUXCshehLZNr6CxC4kdhZoqxiTn4' -O 'mythtv-light_31.0-144-g563a05b7a8-0_armhf_buster.deb'
wget --no-check-certificate --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1mG4dHUXCshehLZNr6CxC4kdhZoqxiTn4' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1mG4dHUXCshehLZNr6CxC4kdhZoqxiTn4" -O "mythtv-light_31.0-144-g563a05b7a8-0_armhf_buster.deb" && rm -rf /tmp/cookies.txt
sudo gdebi 'mythtv-light_31.0-144-g563a05b7a8-0_armhf_buster.deb'

if [ $MYTHPLUGINS = 0 ] ; then
sudo apt install mythplugins-light -y
wget --no-check-certificate --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1Ds7iDgxzBc6YW9bkjDqefkgqtQrZUC4O' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1Ds7iDgxzBc6YW9bkjDqefkgqtQrZUC4O" -O "mythplugins-light_31.0-144-g563a05b7a8-0_armhf_buster.deb" && rm -rf /tmp/cookies.txt
sudo gdebi 'mythplugins-light_31.0-144-g563a05b7a8-0_armhf_buster.deb'
fi

# get all scripts from my github repository
Expand Down
3 changes: 2 additions & 1 deletion run_mythfrontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ bash -c "cat >/home/pi/pi_mythfrontend.json" <<ENDOFSCRIPTINPUT
}
ENDOFSCRIPTINPUT

export QT_QPA_EGLFS_ALWAYS_SET_MODE="1"
#for QT debug add to command line QT_QPA_EGLFS_DEBUG=1 QT_LOGGING_RULES=qt.qpa.*=true
QT_QPA_EGLFS_ALWAYS_SET_MODE="1" QT_QPA_PLATFORM=eglfs QT_QPA_EGLFS_KMS_CONFIG=/home/pi/pi_mythfrontend.json mythfrontend $ARGUMENTS
QT_QPA_PLATFORM=eglfs mythfrontend $ARGUMENTS
# fixup keyboard after exit from mythfrontend, bug in QT causes segment fault which kills keyboard input
kbd_mode -u
# restore cursor
Expand Down