[mythtv] Python bindings for mythtv

Oscar Curero oscar-listas at naiandei.net
Sun Oct 22 14:41:32 UTC 2006


Hi,

Searching the mailing list archive I see that this issue has been discussed 
previously 
but no one started. Because mythtv is so big, I have splitted the bindings in 
two parts: the mythtv protocol and the bindings for libmyth. The first thing 
to do is write the mythtv protocol so python scripts can speak to the server 
(just like mythfrontend). Once we have a stable protocol, we can start with 
the bindings part.

So far, so good. The documentation is far from being complete but thanks to 
the people writting the wiki, is easier than I though. The following commands 
are working fine:

ANN
MYTH_PROTO_VERSION
DONE
ALLOW_SHUTDOWN
QUERY_SETTING       
SHUTDOWN_NOW
BLOCK_SHUTDOWN
QUERY_FREE_SPACE_LIST
QUERY_ISRECORDING
QUERY_IS_ACTIVE_BACKEND
QUERY_LOAD
QUERY_GETALLSCHEDULED
QUERY_RECORDINGS
QUERY_GETALLPENDING

Some examples:

Python 2.4.2 (#1, May  2 2006, 08:13:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import mythproto
conn=mythproto.Mythproto("192.168.0.5") # connection opened
conn.sendCommand("ANN","monitor","gardenia",0) #announce a new client
'OK' # Good :)
conn.sendCommand("QUERY_ISRECORDING")
False #Oops!, backend is idle
for program in conn.sendCommand("QUERY_RECORDINGS","play"):
     title=program.programInfo["TITLE"]
     channel=program.programInfo["CHANNAME"]
     print "Program %s (channel: %s)" % (title,channel)

Program: Prison Break (channel: La Sexta)
Program: Platicando (channel: Documanía)

All commands are documented using the __doc__ attribute:

import mythcommands
print mythcommands.QUERY_RECORDINGS.__doc__
Syntax: QUERY_RECORDINGS <type>
Returns:  A list of mythhandler.programInfo instances.
Description: Get all recordings
Exceptions: A MythCommandError will be raised if a mythhandler.programInfo 
instace is not created 

-- 
Oscar Curero - Linux user: 306877
--    GPG keyID: 0xE0EA0B24    -- 


More information about the mythtv-dev mailing list