Difference between revisions of "User Jobs"

From MythTV Official Wiki
Jump to: navigation, search
(User Job Examples)
m
(20 intermediate revisions by 10 users not shown)
Line 1: Line 1:
'''User Jobs''' are programs which can act on MythTV recordings. A MythTV system currently supports four User Jobs.
+
'''User Jobs''' are customized tasks which can act on MythTV recordings. A MythTV system currently supports up to four User Jobs.
  
 +
{{Note box| Beginning with release 0.26, timestamps of recordings are stored in UTC. Applications that use xxxTIME parameters to directly index the database will need to either handle timezone conversion internally, or switch to the respective xxxTIMEUTC parameters. See [[UTC]]}}
 +
<br>
 +
__TOC__
 
== Adding a User Job ==
 
== Adding a User Job ==
There are three ways to add a User Job into the system:
+
There are two ways to add a User Job to the system:
  
1) In the [[mythtv-setup]] program
+
1) In the [[mythtv-setup]] program (pages 7 & 9 of the General menu page)
  
2) By using some SQL statements to insert the job directly. For example, a hypothetical job which edits bad language:
+
2) By using Mythweb Settings | MythTV settings table and editing
% mysql mythconverg
 
UPDATE settings SET data='/path/to/rm-swearing.sh %DIR%/%FILE%' WHERE value='UserJob1';
 
UPDATE settings SET data='Swearing Removal' WHERE value='UserJobDesc1';
 
UPDATE settings SET data='1' WHERE value='JobAllowUserJob1';
 
 
 
3) By using Mythweb Settings | MythTV settings table and editing
 
 
  UserJob# & UserJobDesc#
 
  UserJob# & UserJobDesc#
  
'''Important Note:''' If you use the MythWeb version or manual mysql version for setting up a user job, you have to restart mythbackend for the changes to take effect. Theoretically if you are doing it via MythTV-Setup, then mythbackend isn't running anyway.
+
'''Important Note:''' If you use the MythWeb method for setting up a user job, you have to restart mythbackend for the changes to take effect. (Theoretically if you are doing it via MythTV-Setup, then mythbackend isn't running anyway.)
  
 
== User Job arguments ==
 
== User Job arguments ==
Line 21: Line 18:
 
A user job is just a program or script which is passed some arguments to tell it what recording to perform work on. Either the channel and start time, or the directory and filename, should be sufficient to uniquely identify the recording.
 
A user job is just a program or script which is passed some arguments to tell it what recording to perform work on. Either the channel and start time, or the directory and filename, should be sufficient to uniquely identify the recording.
  
{| border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse; border-color:silver; background:whitesmoke"
+
<!-- Please make parameter updates in the following template -->
|+ '''Options for User Jobs on the Backend'''
+
{{Event_and_Job_Parameters}}
|- style="background: gainsboro"
 
! Option !! Description
 
|-
 
|%CHANID%
 
|Channel ID
 
|-
 
|%STARTTIME%
 
|Start Time of the Recording
 
|-
 
|%DIR%
 
|Path to the recording directory
 
|-
 
|%FILE%
 
|The file name
 
|-
 
|-
 
|%TITLE%
 
|-
 
|-
 
|%SUBTITLE%
 
|-
 
|-
 
|%DESCRIPTION%
 
|-
 
|-
 
|%HOSTNAME%
 
|-
 
|-
 
|%CATEGORY%
 
|-
 
|-
 
|%RECGROUP%
 
|-
 
|-
 
|%PLAYGROUP%
 
|-
 
|-
 
|%STARTTIME%
 
|In the format yyyyMMddhhmmss
 
|-
 
|%ENDTIME%
 
|-
 
|-
 
|%STARTTIMEISO%
 
|In the ISO date format YYYY-MM-DD hh:mm:ss
 
|-
 
|%ENDTIMEISO%
 
|-
 
|-
 
|%PROGSTART%
 
|-
 
|-
 
|%PROGEND%
 
|-
 
|-
 
|%PROGSTARTISO%
 
|-
 
|-
 
|%PROGENDISO%
 
|-
 
|-
 
|%VERBOSELEVEL%
 
|-
 
|-
 
|%JOBID%
 
|The id of this job in the mythconverg jobqueue table
 
|}
 
  
 
Information on completion percentage of a running job, and on results of a completed job, is stored in the comment column of the jobqueue table in the mythconverg database.
 
Information on completion percentage of a running job, and on results of a completed job, is stored in the comment column of the jobqueue table in the mythconverg database.
Line 95: Line 25:
 
== User Job Examples ==
 
== User Job Examples ==
  
 +
See example scripts at [[:Category:User_Job_Scripts]]
  
 
{| border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse; border-color:silver; background:whitesmoke"
 
{| border="1" cellspacing="0" cellpadding="5" style="border-collapse:collapse; border-color:silver; background:whitesmoke"
Line 101: Line 32:
 
! Description
 
! Description
 
|-
 
|-
| /usr/bin/mythcommflag -s %STARTTIME% -c %CHANID% --gencutlist
+
| /usr/bin/mythutil --gencutlist --chanid %CHANID% --starttime %STARTTIME%
 
| Imports the flagged commercials into the cutlist
 
| Imports the flagged commercials into the cutlist
 
|-
 
|-
| /usr/bin/mythcommflag --queue --gencutlist -f %FILE%
+
| [[Copy_and_transcode.pl]]
| Imports the flagged commercials into the cutlist
+
| Copies a recording before transcoding it, honoring the cutlist
|-
 
| [http://knoppmythwiki.org/index.php?page=CopyAndTranscode CopyAndTranscode]
 
| Copies a recording before transcoding it
 
 
|-
 
|-
 
| [[ipod_export]]
 
| [[ipod_export]]
Line 119: Line 47:
 
| Exports recordings in formats useful for PDAs, MDAs, Smartphones and Palms
 
| Exports recordings in formats useful for PDAs, MDAs, Smartphones and Palms
 
|-
 
|-
|[http://www.mythtv.org/wiki/index.php/Script_-_RemoveCommercials RemoveCommercials]
+
|[[Script_-_RemoveCommercials|Remove Commercials]]
 
|Script to remove commercials
 
|Script to remove commercials
 
|-  
 
|-  
| [[nds_export]]
+
| [[dpg_export]]
 
| Converts an mpg recording to a format that can be played in the Nintendo DS moonshell
 
| Converts an mpg recording to a format that can be played in the Nintendo DS moonshell
 +
|-
 +
| [[Cutting_Music_Videos]]
 +
| Make multiple named cuts from a single recording (the hard way ;) ).
 +
|-
 +
| [[Rockbox_Export]]
 +
| Export recordings to small mpegs with or without commercials, suitable for use with Rockbox[http://www.rockbox.org].  These examples are tailored for the screen and CPU capabilities of the SanDisk Sansa e200 series of media players.
 +
|-
 +
| [[Mythvidexport.py]]
 +
| Export recordings to MythVideo
 
|}
 
|}
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]

Revision as of 01:58, 17 September 2012

User Jobs are customized tasks which can act on MythTV recordings. A MythTV system currently supports up to four User Jobs.


Important.png Note: Beginning with release 0.26, timestamps of recordings are stored in UTC. Applications that use xxxTIME parameters to directly index the database will need to either handle timezone conversion internally, or switch to the respective xxxTIMEUTC parameters. See UTC


Adding a User Job

There are two ways to add a User Job to the system:

1) In the mythtv-setup program (pages 7 & 9 of the General menu page)

2) By using Mythweb Settings | MythTV settings table and editing

UserJob# & UserJobDesc#

Important Note: If you use the MythWeb method for setting up a user job, you have to restart mythbackend for the changes to take effect. (Theoretically if you are doing it via MythTV-Setup, then mythbackend isn't running anyway.)

User Job arguments

A user job is just a program or script which is passed some arguments to tell it what recording to perform work on. Either the channel and start time, or the directory and filename, should be sufficient to uniquely identify the recording.


} Note that not all parameters are available to all System Events User Jobs. Information on completion percentage of a running job, and on results of a completed job, is stored in the comment column of the jobqueue table in the mythconverg database.

User Job Examples

See example scripts at Category:User_Job_Scripts

Parameters for System Events and User Jobs
Parameter Description Used

By

Released

In

%CARDID% Event
%CATEGORY% Program subject category, may be undefined. Both
%CHANID% Channel ID Both
%DESCRIPTION% Program title, may be undefined. Both
%DIR% Event: myth://IP:6543/file.mpg, Job: actual directory, may be undefined prior to recording start. Both
%ENDTIME% Recording end time (estimated) yyyyMMddhhmmss. Both
%ENDTIMEISO% YYYY-MM-DDThh:mm:ss Both
%ENDTIMEISOUTC% YYYY-MM-DDThh:mm:ssZ
%ENDTIMEUTC% yyyyMMddhhmmss Both
%EPISODE% Number Both 0.25?
%EVENTNAME% E.g. REC_PENDING Event
%FILE% Recording file, may be undefined prior to recording start. Both
%FINDID% Find ID, for DB lookups. Event
%HOSTNAME% Both
%INETREF% String, e.g. ttvdb.py_123456
%JOBID% The id of this job in the mythconverg jobqueue table.
%ORIGINALAIRDATE% Original Air Date of recording. Both
%PARENTID% Parent recording rule ID, for DB lookups. Event
%PARTNUMBER% Number
%PARTTOTAL% Number
%PLAYGROUP% Play group Both
%PROGEND% Program's scheduled end time. Both
%PROGENDISO% Both
%PROGENDISOUTC%
%PROGENDUTC% Both
%PROGSTART% Both
%PROGSTARTISO% Both
%PROGSTARTISOUTC%
%PROGSTARTUTC% Both
%REACTIVATE% 1 if this recording was reactivated after failing to start on time, 0 otherwise. Event
%RECGROUP% Recording group Both
%RECID% Recording rule ID, for DB lookups. Event
%RECORDEDID% Recorded rule ID, for DB lookups. Both v29.2
%RECSTATUS% Recording status as an integer for completeness, not currently useful. Event
%RECTYPE% This is the recording rule type as an integer, in the priming script example this could be used to do an extensive priming prior to some recordings and not others. These integers are listed in recordingtypes.h in the RecordingType enum. Event
%SEASON% Number Both 0.25?
%SECS% Time until upcoming recording starts. Event
%SENDER% Origin of event (hostname.) Event
%STARTTIME% Both
%STARTTIMEISO% Both
%STARTTIMEISOUTC%
%STARTTIMEUTC% Both
%SUBTITLE% Program subtitle, may be undefined. Both
%SYNDICATEDEPISODE% String
%TITLE% Program title, may be undefined. Both
%TRANSPROFILE% Profile number. Job
%TOTALEPISODES% Integer
%VBIDEVICE% E.g.: --verbose --logpath --loglevel --quiet --nodblog [--syslog (if non Windows)]. Event 30
%VERBOSELEVEL% Bit mapped decimal value. See: https://code.mythtv.org/cgit/mythtv/tree/mythtv/libs/libmythbase/verbosedefs.h Both
%VERBOSEMODE% E.g.: --verbose --logpath --loglevel --quiet --nodblog [--syslog (if non Windows)]. Job 0.25
%VIDEODEVICE% String identifying the physical video device Event 30
Command Description
/usr/bin/mythutil --gencutlist --chanid %CHANID% --starttime %STARTTIME% Imports the flagged commercials into the cutlist
Copy_and_transcode.pl Copies a recording before transcoding it, honoring the cutlist
ipod_export Exports recordings in a video iPod compatible format
nuvexport --ffmpeg --infile="%FILE%" --path=/myth/exports/PocketPC --height=240 --width=320 --mode=xvid --deinterlace --nonoise_reduction --nice=19 Exports a program to Pocket PC sized Xvid using nuvexport.
pdatranscode.pl Exports recordings in formats useful for PDAs, MDAs, Smartphones and Palms
Remove Commercials Script to remove commercials
dpg_export Converts an mpg recording to a format that can be played in the Nintendo DS moonshell
Cutting_Music_Videos Make multiple named cuts from a single recording (the hard way ;) ).
Rockbox_Export Export recordings to small mpegs with or without commercials, suitable for use with Rockbox[1]. These examples are tailored for the screen and CPU capabilities of the SanDisk Sansa e200 series of media players.
Mythvidexport.py Export recordings to MythVideo