0.24 Python bindings/Connection Handlers

From MythTV Official Wiki
Revision as of 05:31, 16 August 2010 by Wagnerrp (talk | contribs)

Jump to: navigation, search

Database Connections

MythDB

tablefields

MythDB.tablefields is populated with an object providing information of database table fields. Tables can be selected as an attribute or item, and return a subclass with further information. The subclass can be converted into a list of field names, or information about each field can be accessed.

>>> db = MythDB()
>>> db.tablefields.settings
[u'value', u'data', u'hostname']
>>> db.tablefields.settings.value
{'default': u'', 'null': u'NO', 'type': u'varchar(128)', 'key': u'MUL', 'extra': u''}
>>> db.tablefields.settings.value.null
u'NO'

settings

MythDB.settings is populated with an object providing access to settings table data. Data is accessed through two levels, first the hostname, and then value. The second level supports a '.getall()' method that returns all settings set for that host. Global settings can be accessed through the 'NULL' hostname.

>>> db = MythDB()
>>> db.settings.NULL.DBSchemaVer
u'1262'
>>> db.settings.NULL.getall()
<itertools.izip object at 0x804e4ac20>

getStorageGroup

inputs
groupname=None <string>
hostname=None <string>
outputs
StorageGroup generator
description
The two optional arguments can be used to filter the available storage groups.
>>> db = MythDB()
>>> db.getStorageGroup(groupname='Videos').next()
<StorageGroup 'myth://Videos@mythbe/mnt/mythtv/videos/' at 0x804e7d560>

cursor

inputs
log=None <MythLog object>
outputs
LoggedCursor object
description
Returns a cursor for direct database access

searchRecorded

inputs
All inputs are optional, and can be mixed and matched.

title
autoexpire
watched
closecaptioned
generic

subtitle
commflagged
storagegroup
partnumber
cast

chanid
stars
category_type
parttotal
livetv

starttime
recgroup
airdate
seriesid
basename

progstart
playgroup
stereo
showtype
syndicatedepisodenumber

category
duplicate
subtitled
programid
 

hostname
transcoded
hdtv
manualid
 

outputs
Recorded generator
description
Returns multiple recordings matching the given data
>>> db.searchRecorded(title='Chuck')
>>> db.searchRecorded(category='Documentary', hdtv=True)

searchOldRecorded

inputs
All inputs are optional, and can be mixed and matched.

title
category
generic

subtitle
seriesid
recstatus

chanid
programid
 

starttime
station
 

endtime
duplicate
 

outputs
OldRecorded generator
description
Returns multiple old recordings matching the given data

searchJobs

inputs
All inputs are optional, and can be mixed and matched.

chanid
title

starttime
subtitle

type
flags

status
olderthan

hostname
newerthan

outputs
Job generator
description
Returns multiple job entries matching the given data

searchGuide

inputs
All inputs are optional, and can be mixed and matched.

chanid
category
subtitled
seriesid
syndicatedepisodenumber

starttime
airdate
hdtv
originalairdate
 

endtime
stars
closecaptioned
showtype
 

title
previouslyshown
partnumber
programid
 

subtitle
stereo
parttotal
generic
 

outputs
Guide generator
description
Returns multiple guide programs matching the given data

searchRecord

inputs
All inputs are optional, and can be mixed and matched.

type
enddate
recgroup

chanid
title
station

starttime
subtitle
seriesid

startdate
category
programid

endtime
profile
playgroup

outputs
OldRecorded generator
description
Returns multiple recording rules matching the given data

searchInternetContent

getFrontends

getFrontend

getRecorded

getChannels

MythVideo

Command Inputs Returns Description
getStorageGroup
cursor
scanStorageGroups
searchVideo
getVideo

MythMusic

MythVideo

Command Inputs Returns Description
getStorageGroup
cursor
searchMusic

MythProto Connections

MythBE

Command Inputs Returns Description
backendCommand command string result string This method sends a low level string to the backend, and returns the response.
getRecording chanid
starttime
None or Program object Returns information for a single recording
deleteRecording Program object
force=False (optional)
Informs the backend to delete the recording using whatever mechanism was selected
forgetRecording Program object Informs the backend to mark a recording as re-recordable
deleteFile relative path to file
storage group name
Delete a single managed file on the backend
getHash relative path to file
storage group name
hash string Calculate the hash value for a managed file
reschedule recordid=-1 (optional)
wait=False (optional)
Issue a scheduler run on all rules, or on one specific rule if other than '-1'. Will optionally wait for the scheduler to finish before returning.
fileExists relative path to file
sgroup='Default' (optional)
None or full path to file Searches storage groups on the backend for given file
download url DownloadFileTransfer object Starts a managed download on the backend to the Temp storage group, and returns a file object. The downloaded file will be automatically deleted when the file is closed.
downloadTo url
storage group
relative path to file
openfile=False (optional)
None or DownloadFileTransfer object (if openfile is True) Starts a managed download on the backend to the specified location. Optionally opens the new file for reading.
allocateEventLock regular expression EventLock object Opens a lock object that cannot be acquired until an event matching the regular expression has been received.
getPendingRecordings list of Program objects Returns a list of programs scheduled to be recorded
getScheduledRecordings list of Program objects Returns a list of programs scheduled to be recorded
getUpcomingRecordings list of Program objects Returns a list of programs scheduled to be recorded, filtered for only those that will be recorded
getConflictedRecordings list of Program objects Returns a list of programs scheduled to be recorded, filtered for only those with scheduling conflicts
getRecorderList list of integers Returns a list of defined card IDs
getFreeRecorderList list of integers Returns a list of available card IDs
lockTuner id=None (optional) (ID, video node, audio node, VBI node) or integer error Returns the information about the locked tuner, -1 if no tuners are available, or -2 if the optionally requested tuner is already locked.
freeTuner id=None (optional) Free all tuners currently locked by this connection, or one specific tuner. This is automatically run when the connection is closed.
getCurrentRecording recorder Program object Returns the program currently being recorded by the given ID.
isRecording recorder boolean Returns True or False whether the recorder is actively being used.
isActiveBackend hostname boolean Returns True or False whether the provided host is connected as a backend.
getRecordings list of Program objects Returns a list of existing recordings.
getExpiring list of Program objects Returns a list of existing recordings nearing expiration.
getCheckfile Program object path string Returns the path to the recording on the backend.
getFreeSpace all=False (optional) list of FreeSpace objects Returns information about the recording directories on the local or all backends.
getFreeSpaceSummary total and used space (in integer KB) Returns information about disk usage.
getLoad 1, 5, and 15 minute load averages
getUptime uptime in seconds
walkSG
getSGList
getSGFile
getLastGuideData string date of last guide data

BEEventMonitor

MythSystemEvent

Other Connections

MythXML

Command Inputs Returns Description
_queryObject
_query
_queryTree
getConnectionInfo
getServDesc
getHosts
getKeys
getSetting
getProgramGuide
getProgramDetails
getChannelIcon
getRecorded
getExpiring
getInternetSources

Frontend

Command Inputs Returns Description
getQuery list of 2-tuples, [(location string, description)] returns all available data queries from the backend
sendQuery query (string) response (string) sends a query to the backend, returning the unprocessed result
getPlay list of 2-tuples, [(playback command, description)] returns all available playback commands from the backend
sendPlay command (string) boolean sends a command to the backend, returning success or failure
play media (any object with _playOnFe method) boolean plays the given media object on the frontend, currently works with Recorded, Program, or Video
getLoad tuple returns the 1/5/15 load averages
getUptime timedelta returns the system uptime
getTime datetime returns the current system time
getMemory dict returns a dictionary of memory and swap usage in megabytes

jump

Frontend.jump is populated with an object intended for use sending jumppoints to the frontend. The '.list()' and '.dict()' methods return the available jumppoints, and jumps can be sent by accessing a jumppoint as an attribute or item. Returns True on successful jump.

>>> fe = Frontend.fromUPNP().next()
>>> fe.sendQuery('location')
'mainmenu'
>>> fe.jump.mythvideo
True
>>> fe.sendQuery('location')
'mythvideo'
>>> fe.jump['playbackrecordings']
True
>>> fe.sendQuery('location')
'playbackbox'

key

Frontend.key is populated with an object intended for use sending keypresses to the frontend. The '.list()' method returns a list of special keys allowed, in addition to any alphanumeric keys. Keypresses can be sent as an attribute or item, and accept both literal strings and ordinal scancodes. Returns True on success.

>>> fe = Frontend.fromUPNP().next()
>>> fe.key
['#', '$', '%', '&', '(', ')', ..... ,'tab', 'underscore', 'up', '|']
>>> fe.key.escape
True
>>> fe.key['enter']
True
>>> fe.key[68]
True