Difference between revisions of "0.24 Python bindings/Data Handlers"

From MythTV Official Wiki
Jump to: navigation, search
m (Database Read-Write)
m (shared)
Line 110: Line 110:
 
|}
 
|}
  
==== update ====
 
;inputs
 
:follows standard dict.update() syntax
 
;description
 
:Updates the local object with any given changes, and then pushes the data contained in the object onto the database. This method will only work if the object has a matching database entry.
 
==== delete ====
 
;description
 
:Deletes database entry matched to object.
 
 
=== Record ===
 
=== Record ===
 
==== getUpcoming ====
 
==== getUpcoming ====

Revision as of 20:20, 3 October 2010

Backend Data

These classes are not intended to be called directly, but only returned from methods in MythBE and MythXML. The classes are similar to dictionaries, whose data can also be accessed as class attributes.

FreeSpace

Refers to one disk defined in the backend for storage group use. Computes several additional values from the original data.

>>> fs = be.getFreeSpace().next()
>>> fs
<FreeSpace '/mnt/mythtv/recordings@mythtrunk' at 0x804e7f0e0>
>>> fs.items()
[('host', u'mythtrunk'), ('path', u'/mnt/mythtv/recordings'), ... , ('us_low', 19550336)]
>>> fs.totalspace, fs.usedspace, fs.freespace
(119116800, 19550336, 99566464)

Program

Refers to a single upcoming or existing recording.

fromRecorded

Inputs Outputs Description
Recorded object
Program object
Returns a Program object from an existing Recorded object
Example:
>>> rec
<Recorded 'Archer','2010-10-02 23:00:00' at 0x8056b28a0>
>>> Program.fromRecorded(rec)
<Program 'Archer','2010-10-02 23:00:00' at 0x8056bc9a0>

toString

Inputs Outputs Description
n/a
serialized data <string>
Outputs a string with values separated by '[]:[]', for use over Myth Protocol

open

Inputs Outputs Description
type='r'
file object
Opens Program for read/write, will automatically decide between local filesystem, Myth Protocol, or MythXML for how to access file

delete

Inputs Outputs Description
force=False
rerecord=False
n/a
Deletes a recording, and optionally marks it for re-record. If force is False, the call will fail if mythbackend cannot find a file to delete matching the program. Setting force to True will cause it to be deleted anyway, possibly resulting in an orphaned file.

formatPath

Inputs Outputs Description
path
replace=None
n/a
Returns a formatted file path using the syntax of mythlink.pl. Replace is an optional character to use in place of certain characters that cause problems in Windows.
Example:
>>> prog.formatPath('%T/(%oY%-%om%-%od) %S')
'Archer/(2010-01-14) .mpg'

formatJob

Inputs Outputs Description
command
n/a
Returns a formatted command string using the jobqueue syntax.
Example:
>>> prog.formatJob('/some/job %DIR% %FILE% %TITLE%')
/some/job /srv/mounts/mythtv/video 2062_20101002230000.mpg Archer

Database Read-Only

These classes provide mapped access to a single entry in a database table. The table columns are accessible as the same name as attributes or keys. The class otherwise behaves as a dictionary.

Guide

This class maps to guide data in the `program` table. This class can be populated from the database directly, or from MythXML.

getRecStatus

Inputs Outputs Description
n/a
recstatus
Query the recordings status of pending recordings from the abckend, and determines the recording status of the guide object. Returns 0 if show does not match any Record rules.

InternetContent

This class maps to an installed grabber in the `internetcontent` table.

InternetContentArticles

This class maps to a grabbed internet video in the `internetcontentarticles` table.

Database Read-Write

These classes map to a single entry in a database table, and allow creation, alteration, and deletion in addition to just read access.

shared

These are shared methods supported by all read/write classes.

create

Inputs Outputs Description
data=None
self
Creates a new database entry using the data currently contained in the object. Accepts an optional dictionary of additional data to apply before inserting. This method will only work if the object has not already been matched to an existing database entry.
Example:
>>> vid = Video().create({'title':'test file', 'filename':'path/to/test/file.avi', 'hash':'00000000'})
>>> vid
<Video 'test file' at 0x8051b8ae0>

update

Inputs Outputs Description
*args
**kwargs
n/a
Updates the local object with any given changes, and then pushes the data contained in the object onto the database. This method will only work if the object has been matched to an existing database entry.

delete

Inputs Outputs Description
n/a
n/a
Deletes database entry matched to object.

Record

getUpcoming

fromGuide

(classmethod)

fromProgram

(classmethod)

Recorded

cast

seek

markup

open

formatPath

importMetadata

fromProgram

(classmethod)

RecordedProgram

fromRecorded

(classmethod)

OldRecorded

setDuplicate

Job

setComment

setStatus

Channel

Video

cast

genre

country

markup

open

openBanner

openCoverart

openFanart

openScreenshot

openTrailer

getHash

parseFilename

importMetadata

fromFilename

(classmethod)

Song

fromAlbum

(classmethod)

fromArtist

(classmethod)

fromPlaylist

(classmethod)

Album

fromArtist

(classmethod)

fromSong

(classmethod)

Artist

fromName

(classmethod)

fromSong

(classmethod)

fromAlbum

(classmethod)

MusicPlaylist

fromSong

(classmethod)

MusicDirectory

fromPath

(classmethod)