0.24 Python bindings/Data Handlers

From MythTV Official Wiki
Jump to: navigation, search

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

fromRecorded

Inputs Outputs Description
Recorded object
self
This classmethod returns a Program object from a Recorded object.

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

This class manages recording rules. Editing a rule automatically issues a reschedule. delete() and create() both take a wait keyword argument, which will cause the function to wait until the backend has completed its reschedule run.

getUpcoming

Inputs Outputs Description
deactivated=False
list of Programs
Outputs a list of shows that will be recorded according to this recording rule. Will optionally return all shows matching the rule, regardless of record status.
Example:
>>> rec
<Record Rule 'The Office', Type 3 at 0x8051d54e0>
>>> rec.getUpcoming()
[<Program 'The Office','2010-10-07 21:00:00' at 0x8052e2ee0>, <Program 'The Office','2010-10-14 21:00:00' at 0x8055fb520>]

fromGuide

Inputs Outputs Description
Guide object
type=kAllRecord
wait=False
self
Return a recording rule matching the given Guide object. Can optionally provide a recording type, and wait for the scheduler run to finish.

fromProgram

Inputs Outputs Description
Program object
type=kAllRecord
wait=False
self
Return a recording rule matching the given Program object. Can optionally provide a recording type, and wait for the scheduler run to finish. If Program object already matches an existing recording rule, the new rule will be set up as an override.

Recorded

cast

seek

markup

open

Inputs Outputs Description
type='r'
file object
Opens a recording for file access. Attempts direct file access, before falling back to Myth Protocol file transfer.

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:
>>> rec.formatPath('%T/(%oY%-%om%-%od) %S')
'Archer/(2010-01-14) .mpg'

importMetadata

Inputs Outputs Description
VideoMetadata object
overwrite=False
n/a
This method takes a VideoMetadata result, imports any new data (or optionally overwrites existing data), and downloads any necessary artwork, before committing to the database.

fromProgram

Inputs Outputs Description
Program object
self
This classmethod returns a database entry for read/write access, from an existing Program response.

RecordedProgram

This class represents additional guide information attached to a recording in the `recordedprogram` table.

fromRecorded

Inputs Outputs Description
Recorded object
self
This classmethod returns a database entry for read/write access, from an existing Recorded object.

OldRecorded

This class is used to manage old recording records. The create() method can be used, but update() and delete() have been disabled.

setDuplicate

Inputs Outputs Description
record=False
n/a
Sets old recording duplicate status, to control whether a show will be re-recorded.

Job

This class is used to manage and create new tasks to be run through the Job Queue.

setComment

Inputs Outputs Description
comment
n/a
Directly set the comment field, and store to database.

setStatus

Inputs Outputs Description
status
n/a
Directly set the status code, and store to database.

Channel

This class is used to manage channels stored in the database, and has no special functions beyond those standard defined for the DBDataWrite classes.

Video

This class is used to manage MythVideo entries.

cast

genre

country

markup

open

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced video. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

openBanner

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced banner image. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

openCoverart

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced coverart image. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

openFanart

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced fanart image. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

openScreenshot

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced screenshot image. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

openTrailer

Inputs Outputs Description
mode='r'
nooverwrite=False
file object
Opens a file-like object to access the referenced trailer video. Mode can be read or write, and nooverwrite will block a write if a file already exists on the local filesystem.

getHash

Inputs Outputs Description
n/a
hash string
Returns a 64-bit hexadecimal value to uniquely identify a video file.

parseFilename

Inputs Outputs Description
n/a
(title, season, episode, subtitle)
Parse the filename stored in the object.

importMetadata

Inputs Outputs Description
metadata
overwrite=False
n/a
Imports a metadata object returned from the VideoGrabber, and stores new data to the database. Will optionally skip overwriting data already set to something other than the default values.

fromFilename
(classmethod)

Inputs Outputs Description
filename
self
Creates a new object with initial data parsed from the filename. Object is not stored to the database.

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)