Difference between revisions of "User:PhilB"

From MythTV Official Wiki
Jump to: navigation, search
(Cleared page - refer to Install Mythbuntu 16.04.01)
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
This page cleared 16/12/16
  
 
+
You may be seeking [[Install Mythbuntu 16.04.01]]
 
 
  WARNING:  This page is under construction.
 
  Please Ignore for the moment.
 
 
 
 
 
 
 
==Introduction==
 
 
 
This page describes version 2 of a screen based MythTV Channel editor.
 
 
 
It is a perl script using the API interface which will allow channel data to be easily displayed, sorted and changed.  It can be run on the backend or from another computer with access to the backend.
 
 
 
A tutorial is included for user familiarisation.
 
 
 
Version 2 was developed following extensive user feedback from version one.  Not only has functionality been increased but the user interface has been improved.
 
 
 
==What does it do?==
 
 
 
It will:
 
 
 
- Extract channel data for all sources from a backend.
 
 
 
- Display channel data - ChannelId, Channel number, source, multiplex, flags, Callsign and XMLTVID.  A further parameter can be extracted, shown and modified.
 
 
 
- Allow channels to be sorted in various ways.
 
 
 
- Allow the data shown to be selected
 
 
- Allow channels to be edited, either singly or in bulk.
 
 
 
- Export the state of channels to a file for re-import so the same settings can be re-applied after your next rescan.
 
 
 
- Allow import of XMLTVID date from UK Altas or Radio Times files.
 
 
 
- Allow running in demo mode with no changes to the database.
 
 
 
- Allow 'spoofing' with alien data from a file rather than reading the backend.  This was developed as a support tool but also supports the tutorial below.
 
 
 
The script uses the MythTV API interface and has been tested with both 0.27 and 0.28-pre with UK DVB-T and DVB-S data and with US cable and 'over the air' ATSC data.  All tests have been in a Linux environment.
 
 
 
Before trying it with your own precious database you will probably wish to try it out with artificial data and a safe step by step tutorial.  This shows the features of the editor with a subset of data 'pruned' and modified from a UK system.  It will not interact with your database!
 
 
 
==Setup==
 
 
 
A suggested setup for channel editor is:
 
 
 
Create a fresh directory to hold the files:
 
  mkdir chedit
 
  cd chedit
 
 
 
you will need three files;
 
 
 
*chedit2.pl          the perl script.
 
 
 
*scan_database.pm    the API interfacing module
 
 
 
Note that the suffixes are .pl and .pm respectively.
 
 
 
*tutorial.diags      if you wish to run the tutorial below.
 
 
 
 
 
The module scan_database.pm is fully described in [[Perl_API_examples]] and can be placed anywhere in the perl 'path' which you can list with:
 
 
 
<pre>perl -e 'print join ("\n", @INC), "\n"'</pre>
 
 
 
The three files can be found on github:  https://github.com/PBrady43/Channel-Editor
 
   
 
You can either extract these using git (if familiar) or copy and paste then into your favoured editor (hint:  Use 'raw' before copy). 
 
 
 
Please check the first lines of chedit2.pl and of scan_database.pm are:
 
 
 
    #!/usr/bin/perl -w
 
 
 
Then make them executable:
 
<pre>
 
chmod 755 chedit.pl
 
chmod 755 scan_database.pm
 
</pre>
 
 
 
If not running in a Linux environment please note the comments below.
 
 
 
==Command line options==
 
 
 
chedit.pl has three command-line options.
 
 
 
--backend  specify backend address:port number (but it may well find that itself!)
 
 
 
--nodemo or --demo      Demonstration mode.  Database will NOT be updated.  --demo is default.
 
 
 
--spoof <filename>  reads data from <filename> rather than your backend.  A support option and enables the tutorial.
 
 
 
--extra  <parameter>  specifies an additional field to extract from the database for display and editing.
 
==Tutorial==
 
 
 
Start the channel editor in 'spoofing' mode with
 
<pre>./chedit2.pl -sp tutorial.diags</pre>
 
 
 
This will start the editor in demonstration mode and read the file tutorial.diags to show the tutorial data rather than looking for data on your backend.
 
 
 
You may be told that the libwww-perl module needs loading - if using ubuntu try
 
<pre>
 
sudo apt-get install libwww-perl
 
</pre>
 
''Any other modules??''
 
 
 
Assuming that all required modules are available, it should show a full size screen with columns of channel data and a reminder that you are in demo mode.  There is also a demo reminder top right of the screen.
 
 
 
Click on 'OK' in the reminder box.
 
 
 
===Viewing data===
 
 
 
====Normal view====
 
A list of channels should be displayed.  Note the scroll bar at the right.
 
The columns of data are:
 
Row number for referencing purposes
 
Channel Id - the database reference in MythTV
 
Channel Number
 
Source and multiplex.
 
A set of flags which are:
 
  D channel will be deleted
 
  V channel visible
 
  E  UseEIT flag
 
  C  Commflag
 
  d  duplicated callsign or channel number (if visible)
 
  Q  there is a match query following an import
 
  U  last change can be undone
 
  M  this channel has been modified.
 
CallSign
 
XMLTVID
 
 
 
====Extra view====
 
If the --extra parameter is specified, an additional menu item is shown. It provides a column setup which replaces XMLTVID with the --extra parameter.
 
 
 
====Custom Columns====
 
If the items do not fit comfortably on the screen or a different set of columns is required then use of View-> Define Custom Columns will bring up a window allowing the desired columns to be selected.  Choose each in turn followed by 'ok' then finish with a final 'ok'.
 
 
 
The default view can be restored with View -> Show default columns, and the newly defined column selection again with View -> Show Custom Columns.
 
 
 
====Multiplexes====
 
View -> Multiplexes shows a listing of multiplexes.
 
 
 
===Sort menu===
 
The sort menu allows the order in which the channels are displayed to be changed.
 
If none of the 14 pre-defined orders suit then a custom rule can be generated in much the same way as with the columns.
 
 
 
Note that the channel shown on a particular row changes with the sort rule used.  This allows the power of the sort rules to be exploited in the Edit menu.
 
 
 
===Edit Menu===
 
 
 
The edit menu allows changing parameters of single channels, or changing parameters in bulk.
 
 
 
To take a few examples,
 
====Edit by Source:mpx====
 
Duplicate channels;
 
 
 
Sort by duplicate callsign.  This will show few channels duplicated between multiplexes 1 and 7.  This (artificial) data replicated a situation of a distant transmitter.  View > multiplexes and published data might show that multiplex 1 is local but multiplex 7 is distant and undesirable.
 
 
 
The channels on multiplex 7 can be hidden in one fell swoop with
 
 
 
Edit -> Bulk by Source:mpx
 
 
 
Enter 1:7
 
 
 
Then Delete, set to mark for deletion or
 
 
 
visible, clear to hide them.
 
 
 
The U and M flags will be set and the 'd' flag cleared but the order unchanged.  The action can be 'undone; with Edit -> Undo.
 
 
 
====Edit by Row====
 
 
 
Sort by duplicate callsign again.
 
This time only ITV4 is duplicated.  That's because ITV4 was moved from multiplex 5 to 2 and the one remaining in multiplex 5 (channel 792) is a 'please retune' reminder.
 
 
 
This can be cleared by Edit -> Bulk by Row Range
 
 
 
Select row 1 then delete, set.
 
 
 
 
 
====Edit by Name====
 
 
 
This allows selection of channels by content of the callsign.
 
 
 
Example:  Delete all channels with 'adult' in the name.
 
 
 
Edit -> Bulk by CallSign -> 'adult', delete, set.
 
 
 
Similar actions allow setting all BBC channels as CommFree.
 
 
 
====Channel Number Incrementing====
 
 
 
The lower section of the bulk edit box allows channel numbers to be modified, either by setting a new value or by incrementing a range by a value.  In this case, a negative value decrements.
 
 
 
The lower section also allows setting XMLTVID values (or setting to blank) with the 'set' button.
 
 
 
====Single Channel Edits====
 
 
 
The Edit > Single Channel allows other values to be changed for a single channel.
 
eg The broadcasters recently changed the callsign for BBC ONE to BBC ONE LON which invalidated many recording rules.  This option would have allowed callsign to be changed back.
 
 
 
However, this option must be used with caution!
 
 
 
====Edit Undo====
 
 
 
Edit -> Undo will reverse the most recent change. 
 
 
 
Edit -> Undo all will clear all changes.
 
 
 
Note that the 'undo' items are held in a stack which is cleared alter a database save.
 
 
 
 
 
===File Menu===
 
====Exporting and Importing====
 
 
 
Having marked all the channels as desired the database can be updated (if not in demo mode!!)
 
but before doing so it may be wise to 'export' the settings made to a file for later use.  The file is called channels.export.
 
 
 
The file can then be 'imported' after a channel re-scan to re-impose your settings on the new channel configuration though there may be a few which do not match due to new channels, or a complex setup.
 
 
 
The editor will read the channels.export file and attempt to match the channels - the rules are described in the help.
 
 
 
If any channel cannot be matched then it will leave it unchanged but put a Q (for query) state.  These can be identified by sorting by query.  Such queries will need to be resolved by hand.
 
 
 
When they are edited the 'Q' flag will clear.
 
 
 
As with all edits, you can 'undo' an import.
 
 
 
With the tutorial, a channel re-scan can be simulated by quitting the editor with  File > exit, restarting it and accepting the import.
 
 
 
The channels should now be just as they were at the start of the tutorial.  Alternatively, the File -> Import option will import the settings.
 
 
 
Notes:
 
 
 
1.  It is advisable to import on reading the database and export again before updating it.  This will keep the database and the export file in step.  This is important for two reasons:
 
 
 
a) A major matching parameter is CallSign and if this is changed, the 'old' name is retained and exported. On import the 'old' name is noted and used if necessary.
 
 
 
b).  If the --extra calling parameter is used then the --extra values are also written to the export file, and the file will support many --extra sets.  If it is necessary to alter different --extra parameters then they will keep in step with successive --extra runs provided imports and exports are coordinated.
 
 
2.  Even if you have no history of using the channel editor and are facing a channel rescan, then a run with no edits but an export BEFORE the rescan and a run with an import AFTER the rescan will recover many of the settings.
 
 
 
 
====Updating Database====
 
 
 
This option will seek confirmation that a database backup is available then modify the database with the changes made.  Database changes will only be made in nodemo mode.
 
 
 
===XMLTV Menu===
 
 
 
There is a particular problem with XMLTVID data in the UK but the issue may be prevalent elsewhere.
 
The two main XMLTVID providers (Atlas and the now deprecated Radio Times) produce files which give a correlation between callsign and XMLTVID and it has been necessary to manually insert the IDs with a channel editor or hand crafted sql statements.
 
 
 
Unfortunately, there are many regional variations and whilst a human may easy decide that BBC ONE LON is appropriate rather that BBC ONE Wales, Scotland etc, automation of this is tricky.
 
 
 
Comparing callsigns in the database with those in the file by 'folding' to lower case and dropping spaces does part of the job, but other 'hints' are useful.  eg 'BBC ONE London' in the file will match 'BBC ONE Lon' in the database with the hint: Try swapping ''london'' to  ''lon''.
 
Similarly, BBC TWO ENGLAND will match to BBC TWO with the hint: Try swapping ''england'' to [nothing].
 
 
 
The XMLTV menu thus has four options:
 
====Import====
 
This selects the source, the XMLTV file, its type and a hints file and displays the database callsigns alongside the matching file callsigns.
 
The format of the hints file (for the above examples) is
 
  london:lon
 
  england:
 
 
 
Some characters will need 'escaping' by prefixing them with \.  The characters are:
 
\ | ( ) [{ ^ $ * + and .   eg
 
 
 
  \[Freeview]:
 
 
 
tries dropping [Freeview] from the callsign in the file to matchthat in the database.
 
 
 
====Show Matches====
 
This option shows the database callsigns with the callsigns and XMLTVIDs form the file.  Matching ones are shown on the same row.  eg
 
 
 
<pre>
 
 
 
</pre>
 
 
 
====Merge====
 
If matching is incomplete, items can be manually matched with this option.
 
eg to match ''ITV'' in the database on row 28 with ''ITV Midlands'' on row 31 then entering 28:31 will do this and alter the display.
 
 
 
====Commit====
 
Once the matching is completed, the commit option will copy the XMLTVIDs to the main image of the database.  The main datrabase in the backend will not be changed at this stage though, and the commit can be undone.
 
 
 
 
 
   
 
===Help===
 
 
 
The help menus are self explanatory but note that when finished with a help item it is terminated by selecting a different item from the view or sort menu.
 
 
 
====Diagnostics====
 
 
 
Help > diagnostics generates a file with a name of the form channels<datestamp>.diags holding diagnostic information.  If not in 'spoof' mode it also includes a copy of API data from the backend.  The user will be prompted to write this file on error.
 
 
 
==Real World Use==
 
 
 
In order to run the editor against your own database in safe demo mode:
 
<pre>./chedit2.pl</pre>
 
 
 
 
 
To run it in 'live' mode
 
<pre>./chedit2.pl --nodemo</pre> 
 
Note that this WILL update the database if you choose the 'update database' option.
 
 
 
If the script cannot find the backend address (it searches for a config.xml file in all the likely places), then it will ask for the address or hostname to be specified with the --backend parameter eg:
 
 
 
<pre>./chedit2.pl --backend 192.168.1.65</pre>
 
 
 
If a port number other than 6544 is required then it can be added with:
 
<pre>./chedit2.pl --backend 192.168.1.65:1234</pre>
 
 
 
Please DO ensure that you have a robust backup strategy or are prepared to re-scan
 
channels before using the --nodemo option.
 
 
 
 
 
==Other platforms==
 
 
 
===OS X with MacPorts===
 
 
 
From Apple, OS X is lacking several of the software packages that this script depends on.  The [https://www.macports.org MacPorts] project can provide the necessary dependencies:
 
 
 
sudo port install xorg-server p5.22-tk
 
 
 
Edit the first line of the script so that it uses the MacPorts version of Perl.  Make it look so:
 
 
 
#!/opt/local/bin/perl5.22 -w
 
# was #!/usr/bin/perl -w
 
 
 
From Applications > MacPorts, start X11.app and then start the channel editor from Terminal, as described above.
 
 
 
==Problems==
 
 
 
Developing and testing this application with two sets of UK data and two sets of USA data (thank you all!!) has shown that TV cultures are both very rich and very diverse.  If the code does not behave sanely the help>diagnostics facility has been included to assist investigation.
 
 
 
This should generate a file 'channels.diags' which hopefully contains all the information necessary for the author to 'spoof' your
 
system and reproduce the fault.
 
 
 
The file should also be produced if the code throws an error.  Please submit the file with any reports of problems.
 
 
 
===Known Issues===
 
 
 
There are two known error messages, both thrown by the underlying Tk module.  It may be that these are errors induced by the way that Tk is called.
 
 
 
====Pane.pm line 301====
 
 
 
"Use of uninitialized value in string eq at /usr/lib/perl5/Tk/Pane.pm line 301"
 
 
 
This is triggered by single clicking on the right scroll bar and results in spurious messages to the terminal.  It may be a bug in the way Pane is called, but can be eliminated by a change to Pane.pm. 
 
 
 
Find the module with:
 
<pre>locate Pane.pm</pre>
 
 
Line 301 reads:-
 
 
 
<pre>if(defined($ch) && $ch->manager eq 'grid') {</pre>
 
 
 
Change it to:-
 
 
 
<pre>
 
my $fix=$ch->manager if defined($ch);
 
if(defined($fix) && $fix eq 'grid') {
 
</pre>
 
====focusPtr out of sync====
 
 
 
"TkFocusKeyEvent found dispPtr->focusPtr out of sync: expected ??, got .dialogbox2.bottom.button"
 
 
 
This error message to the termainal is not fully understood, but is believed to be caused by keyboard input whilst no input box has focus.  All screens expecting keyboard input set a suitable focus to minimise this, but any further insight would be appreciated!
 
 
 
 
 
 
 
[[Category:Services_API]]
 
[[Category:Perl Scripts]]
 
[[Category:Scripts]]
 

Latest revision as of 14:04, 16 December 2016

This page cleared 16/12/16

You may be seeking Install Mythbuntu 16.04.01