Difference between revisions of "0.24 Python bindings/Connection Handlers"
(→MythBE) |
m (→MythBE) |
||
(18 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{TOC limit|3}} | ||
== Database Connections == | == Database Connections == | ||
− | === | + | === shared === |
+ | All database connection objects share these common utilities. | ||
==== tablefields ==== | ==== 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. | 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. | ||
Line 21: | Line 23: | ||
<itertools.izip object at 0x804e4ac20> | <itertools.izip object at 0x804e4ac20> | ||
</pre> | </pre> | ||
− | = | + | {| |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getStorageGroup | |
− | + | |inputs=groupname=None<br>hostname=None | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#StorageGroup|StorageGroup]] iterable | |
− | + | |description=Returns an iterable of all storagegroup folders matching the optional filter settings. | |
− | + | |example=<pre> | |
− | |||
− | <pre> | ||
>>> db = MythDB() | >>> db = MythDB() | ||
>>> db.getStorageGroup(groupname='Videos').next() | >>> db.getStorageGroup(groupname='Videos').next() | ||
<StorageGroup 'myth://Videos@mythbe/mnt/mythtv/videos/' at 0x804e7d560> | <StorageGroup 'myth://Videos@mythbe/mnt/mythtv/videos/' at 0x804e7d560> | ||
− | </pre> | + | </pre>}} |
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=cursor | ||
+ | |inputs=log=None | ||
+ | |outputs=LoggedCursor object | ||
+ | |description=Returns a cursor, with an optional log object. | ||
+ | |example=<pre> | ||
+ | db = MythDB() | ||
+ | with db as cursor: | ||
+ | cursor.execute("""select ...""") | ||
− | = | + | log = MythLog('custom log') |
− | + | with db.cursor(log) as cursor: | |
− | + | cursor.execute("""insert ...""") | |
− | + | </pre>}} | |
− | + | |- | |
− | + | |} | |
− | |||
− | ==== | + | === MythDB === |
− | + | {| | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=searchRecorded | |
− | + | |inputs=**kwargs | |
− | title <br>autoexpire <br>watched <br>closecaptioned <br>generic | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Recorded|Recorded]] iterable |
− | + | |description=Returns an iterable of Recorded objects, matching the given search filters. Accepts the following keywords:<br> | |
− | subtitle <br>commflagged <br>storagegroup <br>partnumber <br>cast | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> |
− | + | <td>title <br>autoexpire <br>watched <br>closecaptioned <br>generic <br>hostname <br>category</td> | |
− | chanid <br>stars <br>category_type <br>parttotal <br>livetv | + | <td>subtitle <br>commflagged <br>storagegroup <br>partnumber <br>cast <br>transcoded <br>duplicate</td> |
− | + | <td>chanid <br>stars <br>category_type <br>parttotal <br>livetv <br>hdtv <br>subtitled</td> | |
− | starttime <br>recgroup <br>airdate <br>seriesid <br>basename | + | <td>starttime <br>recgroup <br>airdate <br>seriesid <br>basename <br>manualid <br> </td> |
− | + | <td>progstart <br>playgroup <br>stereo <br>showtype <br>syndicatedepisodenumber <br>programid <br> </td> | |
− | progstart <br>playgroup <br>stereo <br>showtype <br>syndicatedepisodenumber | + | </tr></table> |
− | + | |example=<pre> | |
− | |||
− | |||
− | |||
− | | | ||
− | |||
− | |||
− | |||
− | |||
− | <pre> | ||
>>> db.searchRecorded(title='Chuck') | >>> db.searchRecorded(title='Chuck') | ||
>>> db.searchRecorded(category='Documentary', hdtv=True) | >>> db.searchRecorded(category='Documentary', hdtv=True) | ||
− | </pre> | + | </pre>}} |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=searchOldRecorded | |
− | + | |inputs=**kwargs | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#OldRecorded|OldRecorded]] iterable | |
− | + | |description=Returns an iterable of OldRecorded objects, matching the given search filters. Accepts the following keywords:<br> | |
− | title <br>category | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> |
− | + | <td>title <br>category <br>generic</td> | |
− | subtitle <br>seriesid | + | <td>subtitle <br>seriesid <br>recstatus</td> |
− | + | <td>chanid <br>programid <br> </td> | |
− | chanid <br>programid | + | <td>starttime <br>station <br> </td> |
− | + | <td>endtime <br>duplicate <br> </td> | |
− | starttime <br>station | + | </tr></table>}} |
− | + | |- | |
− | endtime <br>duplicate | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=searchJobs |
− | + | |inputs=**kwargs | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Job|Job]] iterable | |
− | + | |description=Returns an iterable of Job objects, matching the given search filters. Accepts the following keywords:<br> | |
− | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | |
− | + | <td>chanid <br>title</td> | |
− | == | + | <td>starttime <br>subtitle</td> |
− | ; | + | <td>type <br>flags</td> |
− | + | <td>status <br>olderthan</td> | |
− | + | <td>hostname <br>newerthan</td> | |
− | + | </tr></table>}} | |
− | chanid <br>title | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | starttime <br>subtitle | + | |name=searchGuide |
− | + | |inputs=**kwargs | |
− | type <br>flags | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Guide|Guide]] iterable |
− | + | |description=Returns an iterable of Guide objects, matching the given search filters. Accepts the following keywords:<br> | |
− | status <br>olderthan | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> |
− | + | <td>chanid <br>category <br>subtitled <br>seriesid <br>syndicatedepisodenumber</td> | |
− | hostname <br>newerthan | + | <td>starttime <br>airdate <br>hdtv <br>originalairdate <br> </td> |
− | | | + | <td>endtime <br>stars <br>closecaptioned <br>showtime <br> </td> |
− | + | <td>title <br>previouslyshown <br>partnumber <br>programid <br> </td> | |
− | + | <td>subtitle <br>stereo <br>parttotal <br>generic <br> </td> | |
− | + | </tr></table>}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | == | + | |name=searchRecord |
− | ; | + | |inputs=**kwargs |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Record|Record]] iterable | |
− | + | |description=Returns an iterable of recording rules, matching the given search filters. Accepts the following keywords:<br> | |
− | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | |
− | chanid <br>category <br>subtitled <br>seriesid <br>syndicatedepisodenumber | + | <td>type <br>enddate <br>recgroup</td> |
− | + | <td>chanid <br>title <br>station</td> | |
− | starttime <br>airdate <br>hdtv <br>originalairdate <br> | + | <td>starttime <br>subtitle <br>seriesid</td> |
− | + | <td>startdate <br>category <br>programid</td> | |
− | endtime <br>stars <br>closecaptioned <br> | + | <td>endtime <br>profile <br>playgroup</td> |
− | + | </tr></table>}} | |
− | title <br>previouslyshown <br>partnumber <br>programid <br> | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | subtitle <br>stereo <br>parttotal <br>generic <br> | + | |name=searchInternetContent |
− | | | + | |inputs=**kwargs |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#InternetContentArticles|InternetContentArticles]] iterable | |
− | + | |description=Returns an iterable of internet content, matching the given search filters. Accepts the following keywords:<br> | |
− | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | |
− | + | <td>feedtitle <br>url <br>width <br>ondate <br>country</td> | |
− | + | <td>title <br>type <br>height <br>olderthan <br>description</td> | |
− | == | + | <td>subtitle <br>author <br>language <br>newerthan <br> </td> |
− | ; | + | <td>season <br>rating <br>podcast <br>longerthan <br> </td> |
− | + | <td>episode <br>player <br>downloadable <br>shorterthan <br> </td> | |
− | + | </tr></table>}} | |
− | + | |- | |
− | type <br>enddate | + | |{{FunctionDoc|level=h4 |
− | + | |name=getFrontends | |
− | chanid <br>title | + | |outputs=active [[Trunk_Python_bindings/Connection_Handlers#Frontend|Frontend]] iterable |
− | + | |description=Tests all frontends listed in the database, and returns connection objects for all those that respond properly.}} | |
− | starttime <br>subtitle | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | startdate <br>category | + | |name=getFrontend |
− | + | |inputs=host | |
− | endtime <br>profile | + | |outputs=[[Trunk_Python_bindings/Connection_Handlers#Frontend|Frontend]] object |
− | | | + | |description=Returns a Frontend object, pulling the connection port from the database.}} |
− | + | |- | |
− | |||
− | |||
− | |||
− | |||
− | == | ||
− | ; | ||
− | |||
− | |||
− | |||
− | feedtitle <br>url | ||
− | |||
− | title <br>type | ||
− | |||
− | subtitle <br>author <br>language <br>newerthan <br> | ||
− | |||
− | season <br>rating <br>podcast <br>longerthan <br> | ||
− | |||
− | episode <br>player <br>downloadable <br>shorterthan <br> | ||
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== MythVideo === | === MythVideo === | ||
− | {| | + | {| |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=scanStorageGroups |
− | | Returns | + | |inputs=deleteold=True |
− | + | |outputs=newvids<br>oldvids | |
+ | |description=Scans through all storage groups on all accessible hosts, and returns a pair of lists: new content to be added, and old content to be deleted. If `deleteold` is True, the old content has already been deleted, and is just returned for information.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=searchRecorded | ||
+ | |inputs=**kwargs | ||
+ | |outputs=[[Trunk_Python_bindings/Data_Handlers#Video|Video]] iterable | ||
+ | |description=Returns an iterable of Video objects, matching the given search filters. Accepts the following keywords:<br> | ||
+ | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | ||
+ | <td>title <br>directory <br>category</td> | ||
+ | <td>subtitle <br>year <br>insertedbefore</td> | ||
+ | <td>season <br>cast <br>insertedafter</td> | ||
+ | <td>episode <br>genre <br> </td> | ||
+ | <td>host <br>country <br> </td> | ||
+ | </tr></table>}} | ||
|- | |- | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
+ | |||
=== MythMusic === | === MythMusic === | ||
− | === | + | {| |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=searchMusic | |
− | + | |inputs=**kwargs | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Music|Music]] iterable | |
− | + | |description=Returns an iterable of Music objects, matching the given search filters. Accepts the following keywords:<br> | |
+ | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | ||
+ | <td>name <br>year <br>bitrate</td> | ||
+ | <td>track <br>genre <br> </td> | ||
+ | <td>disc_number <br>rating <br> </td> | ||
+ | <td>artist <br>format <br> </td> | ||
+ | <td>album <br>sample_rate <br> </td> | ||
+ | </tr></table>}} | ||
|- | |- | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
== [[:Category:Myth Protocol|MythProto]] Connections == | == [[:Category:Myth Protocol|MythProto]] Connections == | ||
=== MythBE === | === MythBE === | ||
− | = | + | {| |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=backendCommand | |
− | + | |inputs=command | |
− | + | |outputs=backend response | |
− | + | |description=This method is low level access to the backend socket. It can be used to send and receive raw strings with the backend. The command and response length is automatically processed and does not have to be provided in the string.}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=getRecording | |
− | + | |inputs=chanid<br>starttime | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object | |
− | + | |description=Returns information for a single recording, or None if no match is found. '''chanid''' can be a string or integer, '''starttime''' can be any format supported by the [[Trunk_Python_Bindings#datetime|datetime]] class.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=deleteRecording | |
− | + | |inputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object<br>force=False | |
− | = | + | |outputs=retcode |
− | + | |description=Deletes a single recording on the backend, optionally forcing the deletion of database information if the cannot be found. Returns '''-1''' on success, or '''-2''' on failure.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=forgetRecording | |
− | + | |inputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object<br>force=False | |
− | = | + | |description=Marks an existing recording as available for re-recording.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=deleteFile | |
− | + | |inputs=file<br>storagegroup | |
− | = | + | |outputs=retcode |
− | + | |description=Manually delete a single file on the backend. '''file''' is a path relative to the root of the storage group.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getHash | |
− | + | |inputs=file<br>storagegroup | |
− | = | + | |outputs=file hash |
− | + | |description=Calculate the [http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes hash] value for a managed file. '''file''' is a path relative to the root of the storage group.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=reschedule | |
− | + | |inputs=recordid=-1<br>wait=False | |
− | + | |description=Issues a scheduler run, optionally limiting it to a single rule. Optionally wait for the scheduler run to complete before returning.}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=fileExists | |
− | + | |inputs=file<br>sgroup='Default' | |
− | + | |outputs=absolute path | |
− | + | |description=Searches for a file on the backend, returning the full path, or None if not found.}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=download |
− | | | + | |inputs=url |
− | | Searches | + | |outputs=file object |
− | = | + | |description=Issues a download on the backend to a temporary path, and provides a file object to access it. File will be deleted automatically when the object is closed.}} |
− | | url | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=downloadTo |
− | = | + | |inputs=url<br>storagegroup<br>file path<br>openfile=False |
− | | url<br> | + | |outputs=file object |
− | | | + | |description=Issues a download on the backend to the defined storagegroup and relative path. Optionally provides a file object to the in-progress download.}} |
− | | | + | |- |
− | = | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=allocateEventLock |
− | | | + | |inputs=compiled regex |
− | | | + | |outputs=mutex object |
− | = | + | |description=Creates a new mutex which will remain locked until the specified event has been received.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getPendingRecordings | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of programs scheduled to be recorded.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getScheduledRecordings | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of programs scheduled to be recorded.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getUpcomingRecordings | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of programs scheduled to be recorded, filtered for only those that will be recorded.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getConflictedRecordings | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of programs scheduled to be recorded, filtered for only those with scheduling conflicts.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getRecorderList | |
− | + | |outputs=list of integers | |
− | = | + | |description=Returns a list of defined card IDs.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getFreeRecorderList | |
− | + | |outputs=list of integers | |
− | = | + | |description=Returns a list of defined card IDs.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=lockTuner | |
− | + | |inputs=int=None | |
− | + | |outputs=card id<br>video node<br>audio node<br>VBI node | |
− | + | |description=Attempts to lock the specified tuner, or automatically chooses one if none specified. Returns the information about the locked tuner, -1 if no tuners are available, or -2 if the optionally requested tuner is already locked. Note: All locked tuners are automatically unlocked prior to closing the connection to the backend.}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=freeTuner | |
− | + | |inputs=int=None | |
− | + | |description=Free all tuners currently locked by this connection, or one specific tuner. This is automatically run when the connection is closed.}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=getCurrentRecording | |
− | + | |inputs=recorder | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object | |
− | + | |description=Returns the program currently being recorded by the specified recorder.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | = | + | |name=isRecording |
− | + | |inputs=recorder | |
− | + | |outputs=boolean | |
− | + | |description=Returns whether the recorder is actively being used.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=isActiveBackend | |
− | = | + | |inputs=hostname |
− | + | |outputs=boolean | |
− | + | |description=Returns whether the hostname is connected as a backend.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getRecordings | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of existing recordings.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getExpiring | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] list | |
− | = | + | |description=Returns a list of existing recordings nearing expiration.}} |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getCheckfile | |
− | + | |inputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object | |
− | = | + | |outputs=absolute path |
− | + | |description=Returns the path to the recording on the backend.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getFreeSpace | |
− | + | |inputs=all=False | |
− | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#FreeSpace|FreeSpace]] object | |
− | + | |description=Returns information about the recording directories on the local or all backends.}} | |
− | = | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=getFreeSpaceSummary | |
− | + | |outputs=total space<br>used space | |
− | + | |description=Returns information about disk usage (in KB).}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | = | + | |name=getLoad |
− | + | |outputs=1,5,15 averages | |
− | + | |description=Returns the load averages.}} | |
− | + | |- | |
− | + | |{{FunctionDoc|level=h4 | |
− | = | + | |name=getUptime |
− | + | |outputs=uptime | |
− | + | |description=Returns uptime, in seconds.}} | |
− | == | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=walkSG}} | |
− | ==== | + | |- |
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getSGList }} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getSGFile }} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getLastGuideData | ||
+ | |outputs=datetime | ||
+ | |description=Pulls data of last guide data available in the database. | ||
+ | }} | ||
+ | |- | ||
+ | |} | ||
+ | === BEEventMonitor === | ||
+ | This class is intended for development use only. Its purpose is to connect to the backend, listen for any events, and print them in raw form to the terminal. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== MythSystemEvent === | === MythSystemEvent === | ||
== Other Connections == | == Other Connections == | ||
=== MythXML === | === MythXML === | ||
− | {| | + | {| |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=fromUPNP |
− | | | + | |inputs=pin=0 |
− | | | + | |outputs=credentials dict |
− | + | |description=This method is used to retrieve the database connection information from the backend. It is generally only used for UPnP auto-detection of the backend, and accepts a PIN. Database may contain:<br> | |
− | + | <table border="0" style="background-color:transparent; padding-left: 2em;"><tr> | |
− | + | <td>DBUserName <br>DBName</td> | |
− | + | <td>DBPort <br>SecurityPin</td> | |
− | + | <td>DBPassword <br> </td> | |
− | |- | + | </tr></table>}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getServDesc |
− | | | + | |outputs=generator of tuples |
− | |- | + | |description=Returns a generator of all available commands and inputs. Each item will be in the form (command, {in:(inputs), out:(outputs)})}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getHosts |
− | | | + | |outputs=hostname list |
− | |- | + | |description=List of all unique hostnames found in the settings table in the database.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getKeys |
− | | | + | |outputs=key list |
− | |- | + | |description=List of all unique settings keys found in the settings table in the database.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getSetting |
− | | | + | |inputs=key<br>hostname=None<br>default=None |
− | | | + | |outputs=setting or default |
− | | | + | |description=Returns defined setting, or '''default''' if setting does not exist.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getProgramGuide |
− | | | + | |inputs=starttime<br>endtime<br>startchan<br>numchan=None |
− | | | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Guide|Guide]] iterable |
− | | | + | |description=Returns an iterable of Guide objects spanning the time and channel range given. Response is limited to 1000 items.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | |- | + | |name=getProgramDetails |
− | | | + | |inputs=chanid<br>starttime |
− | | | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object |
− | | | + | |description=Returns a Program object for a single recording.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getChannelIcon |
− | | | + | |inputs=chanid |
− | | | + | |outputs=image binary}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | + | |name=getRecorded | |
− | | | + | |inputs=descending=True |
− | | | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] iterable |
− | | | + | |description=Returns a generator that iterates through all recorded programs.}} |
− | |- | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getExpiring |
− | | | + | |outputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] iterable |
− | | | + | |description=Returns a generator that iterates through all recorded programs in order of expiration.}} |
− | | | + | |- |
− | | | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getInternetSource |
− | | | + | |outputs=InternetSource iterable |
− | | | + | |description=Returns a generator that iterates through all internet video grabbers available over the xml interface.}} |
− | | | + | |- |
− | | getExpiring | + | |{{FunctionDoc|level=h4 |
− | | | + | |name=getPreviewImage |
− | | | + | |inputs=chanid<br>starttime<br>width=None<br>height=None<br>secsin=None |
− | | | + | |outputs=InternetSource iterable |
− | |- | + | |description=Polls the preview generator for a preview image.}} |
− | | | ||
− | | | ||
− | | | ||
− | | | ||
− | |} | ||
− | |||
− | {| | ||
− | | | ||
− | | | ||
− | | | ||
− | | | ||
|- | |- | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
+ | === Frontend === | ||
==== jump ==== | ==== 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. | 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. | ||
Line 585: | Line 481: | ||
</pre> | </pre> | ||
− | [[Category: | + | {| |
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getQuery | ||
+ | |output=list of queries | ||
+ | |description=Returns a list of queries in the form (query string, description).}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=sendQuery | ||
+ | |input=query | ||
+ | |output=response | ||
+ | |description=Sends a query to the backend, returning the unprocessed response.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getPlay | ||
+ | |output=list of play commands | ||
+ | |description=Returns a list of playback commands in the form (command, description).}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=sendPlay | ||
+ | |input=play command | ||
+ | |output=response | ||
+ | |description=Sends a command to the backend, returning success or failure.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=play | ||
+ | |input=media | ||
+ | |description=Plays the given media on the frontend. Accepts media of types Recorded, Video, or Program.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getLoad | ||
+ | |outputs=1,5,15 load avg}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getUptime | ||
+ | |outputs=timedelta}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getTime | ||
+ | |outputs=datetime}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getMemory | ||
+ | |outputs=memory usage | ||
+ | |description=Returns memory usage in the form (totalmem, freemem, totalswap, freeswap) in MB.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | [[Category:0.24_Python_Bindings]] |
Latest revision as of 17:28, 17 March 2011
Contents
- 1 Database Connections
- 2 MythProto Connections
- 2.1 MythBE
- 2.1.1 backendCommand
- 2.1.2 getRecording
- 2.1.3 deleteRecording
- 2.1.4 forgetRecording
- 2.1.5 deleteFile
- 2.1.6 getHash
- 2.1.7 reschedule
- 2.1.8 fileExists
- 2.1.9 download
- 2.1.10 downloadTo
- 2.1.11 allocateEventLock
- 2.1.12 getPendingRecordings
- 2.1.13 getScheduledRecordings
- 2.1.14 getUpcomingRecordings
- 2.1.15 getConflictedRecordings
- 2.1.16 getRecorderList
- 2.1.17 getFreeRecorderList
- 2.1.18 lockTuner
- 2.1.19 freeTuner
- 2.1.20 getCurrentRecording
- 2.1.21 isRecording
- 2.1.22 isActiveBackend
- 2.1.23 getRecordings
- 2.1.24 getExpiring
- 2.1.25 getCheckfile
- 2.1.26 getFreeSpace
- 2.1.27 getFreeSpaceSummary
- 2.1.28 getLoad
- 2.1.29 getUptime
- 2.1.30 walkSG
- 2.1.31 getSGList
- 2.1.32 getSGFile
- 2.1.33 getLastGuideData
- 2.2 BEEventMonitor
- 2.3 MythSystemEvent
- 2.1 MythBE
- 3 Other Connections
Database Connections
All database connection objects share these common utilities.
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
>>> db = MythDB() >>> db.getStorageGroup(groupname='Videos').next() <StorageGroup 'myth://Videos@mythbe/mnt/mythtv/videos/' at 0x804e7d560> | ||||||
cursor
db = MythDB() with db as cursor: cursor.execute("""select ...""") log = MythLog('custom log') with db.cursor(log) as cursor: cursor.execute("""insert ...""") |
MythDB
searchRecorded
>>> db.searchRecorded(title='Chuck') >>> db.searchRecorded(category='Documentary', hdtv=True) | |||||||||||
searchOldRecorded
| |||||||||||
searchJobs
| |||||||||||
searchGuide
| |||||||||||
searchRecord
| |||||||||||
searchInternetContent
| |||||||||||
getFrontends
| |||||||||||
getFrontend
|
MythVideo
scanStorageGroups
| |||||||||||
searchRecorded
|
MythMusic
searchMusic
|
MythProto Connections
MythBE
backendCommand
| ||||||
getRecording | ||||||
deleteRecording
| ||||||
forgetRecording
| ||||||
deleteFile
| ||||||
getHash
| ||||||
reschedule
| ||||||
fileExists
| ||||||
download
| ||||||
downloadTo
| ||||||
allocateEventLock
| ||||||
getPendingRecordings
| ||||||
getScheduledRecordings
| ||||||
getUpcomingRecordings
| ||||||
getConflictedRecordings
| ||||||
getRecorderList
| ||||||
getFreeRecorderList
| ||||||
lockTuner
| ||||||
freeTuner
| ||||||
getCurrentRecording
| ||||||
isRecording
| ||||||
isActiveBackend
| ||||||
getRecordings
| ||||||
getExpiring
| ||||||
getCheckfile
| ||||||
getFreeSpace
| ||||||
getFreeSpaceSummary
| ||||||
getLoad
| ||||||
getUptime
| ||||||
walkSG
| ||||||
getSGList
| ||||||
getSGFile
| ||||||
getLastGuideData
|
BEEventMonitor
This class is intended for development use only. Its purpose is to connect to the backend, listen for any events, and print them in raw form to the terminal.
MythSystemEvent
Other Connections
MythXML
fromUPNP
| |||||||||
getServDesc
| |||||||||
getHosts
| |||||||||
getKeys
| |||||||||
getSetting
| |||||||||
getProgramGuide
| |||||||||
getProgramDetails
| |||||||||
getChannelIcon
| |||||||||
getRecorded
| |||||||||
getExpiring
| |||||||||
getInternetSource
| |||||||||
getPreviewImage
|
Frontend
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
getQuery
| ||||||
sendQuery
| ||||||
getPlay
| ||||||
sendPlay
| ||||||
play
| ||||||
getLoad
| ||||||
getUptime
| ||||||
getTime
| ||||||
getMemory
|