Difference between revisions of "0.24 Python bindings/Data Handlers"
m (→Guide) |
(→Database Read-Write) |
||
(9 intermediate revisions by the same user not shown) | |||
Line 65: | Line 65: | ||
/some/job /srv/mounts/mythtv/video 2062_20101002230000.mpg Archer | /some/job /srv/mounts/mythtv/video 2062_20101002230000.mpg Archer | ||
</pre>}} | </pre>}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromRecorded | ||
+ | |inputs=[[Trunk_Python_bindings/Data_Handlers#Recorded|Recorded]] object | ||
+ | |outputs=self | ||
+ | |description=This classmethod returns a Program object from a Recorded object.}} | ||
+ | |- | ||
|} | |} | ||
Line 86: | Line 93: | ||
== Database Read-Write == | == 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. | 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 | + | These are shared methods supported by all read/write classes. |
− | = | + | {|- |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=create | |
− | + | |inputs=data=None | |
− | + | |outputs=self | |
− | + | |description=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=<pre> | |
− | ==== update | + | >>> vid = Video().create({'title':'test file', 'filename':'path/to/test/file.avi', 'hash':'00000000'}) |
− | + | >>> vid | |
− | + | <Video 'test file' at 0x8051b8ae0> | |
− | + | </pre>}} | |
− | + | |- | |
− | = | + | |{{FunctionDoc|level=h4 |
− | + | |name=update | |
− | + | |inputs=*args<br>**kwargs | |
+ | |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 been matched to an existing database entry.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=delete | ||
+ | |description=Deletes database entry matched to object.}} | ||
+ | |} | ||
+ | |||
=== Record === | === 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. |
− | ==== | + | {| |
− | + | |{{FunctionDoc|level=h4 | |
− | ==== | + | |name=getUpcoming |
− | + | |inputs=deactivated=False | |
+ | |outputs=list of [[Trunk Python bindings/Data Handlers#Program|Programs]] | ||
+ | |description=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=<pre> | ||
+ | >>> 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>] | ||
+ | </pre>}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromGuide | ||
+ | |inputs=[[Trunk Python bindings/Data Handlers#Guide|Guide]] object<br>type=kAllRecord<br>wait=False | ||
+ | |outputs=self | ||
+ | |description=Return a recording rule matching the given Guide object. Can optionally provide a recording type, and wait for the scheduler run to finish.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromProgram | ||
+ | |inputs=[[Trunk Python bindings/Data Handlers#Program|Program]] object<br>type=kAllRecord<br>wait=False | ||
+ | |outputs=self | ||
+ | |description=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 === | === Recorded === | ||
==== cast ==== | ==== cast ==== | ||
==== seek ==== | ==== seek ==== | ||
==== markup ==== | ==== markup ==== | ||
− | = | + | {| |
− | = | + | |{{FunctionDoc|level=h4 |
− | == | + | |name=open |
− | + | |inputs=type='r' | |
− | + | |outputs=file object | |
+ | |description=Opens a recording for file access. Attempts direct file access, before falling back to [[Myth Protocol]] file transfer.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=formatPath | ||
+ | |inputs=path<br>replace=None | ||
+ | |ouputs=formatted path | ||
+ | |description=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=<pre> | ||
+ | >>> rec.formatPath('%T/(%oY%-%om%-%od) %S') | ||
+ | 'Archer/(2010-01-14) .mpg' | ||
+ | </pre>}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=importMetadata | ||
+ | |inputs=VideoMetadata object<br>overwrite=False | ||
+ | |description=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.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromProgram | ||
+ | |inputs=[[Trunk_Python_bindings/Data_Handlers#Program|Program]] object | ||
+ | |outputs=self | ||
+ | |description=This classmethod returns a database entry for read/write access, from an existing Program response.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
=== RecordedProgram === | === RecordedProgram === | ||
− | = | + | This class represents additional guide information attached to a recording in the `recordedprogram` table. |
− | + | {| | |
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromRecorded | ||
+ | |inputs=[[Trunk_Python_bindings/Data_Handlers#Recorded|Recorded]] object | ||
+ | |outputs=self | ||
+ | |description=This classmethod returns a database entry for read/write access, from an existing Recorded object.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
=== OldRecorded === | === OldRecorded === | ||
− | = | + | This class is used to manage old recording records. The '''create()''' method can be used, but '''update()''' and '''delete()''' have been disabled. |
+ | |||
+ | {| | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=setDuplicate | ||
+ | |inputs=record=False | ||
+ | |description=Sets old recording duplicate status, to control whether a show will be re-recorded.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
=== Job === | === Job === | ||
− | = | + | This class is used to manage and create new tasks to be run through the [[Job Queue]]. |
− | + | {| | |
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=setComment | ||
+ | |inputs=comment | ||
+ | |description=Directly set the comment field, and store to database.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=setStatus | ||
+ | |inputs=status | ||
+ | |description=Directly set the status code, and store to database.}} | ||
+ | |- | ||
+ | |} | ||
=== Channel === | === 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 === | === Video === | ||
+ | This class is used to manage MythVideo entries. | ||
==== cast ==== | ==== cast ==== | ||
==== genre ==== | ==== genre ==== | ||
==== country ==== | ==== country ==== | ||
==== markup ==== | ==== markup ==== | ||
− | = | + | {| |
− | == | + | |{{FunctionDoc|level=h4 |
− | == | + | |name=open |
− | == | + | |inputs=mode='r'<br>nooverwrite=False |
− | == | + | |outputs=file object |
− | == | + | |description=Opens a file-like object to access the referenced video. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} |
− | == | + | |- |
− | + | |{{FunctionDoc|level=h4 | |
− | + | |name=openBanner | |
− | + | |inputs=mode='r'<br>nooverwrite=False | |
− | + | |outputs=file object | |
+ | |description=Opens a file-like object to access the referenced banner image. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=openCoverart | ||
+ | |inputs=mode='r'<br>nooverwrite=False | ||
+ | |outputs=file object | ||
+ | |description=Opens a file-like object to access the referenced coverart image. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=openFanart | ||
+ | |inputs=mode='r'<br>nooverwrite=False | ||
+ | |outputs=file object | ||
+ | |description=Opens a file-like object to access the referenced fanart image. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=openScreenshot | ||
+ | |inputs=mode='r'<br>nooverwrite=False | ||
+ | |outputs=file object | ||
+ | |description=Opens a file-like object to access the referenced screenshot image. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=openTrailer | ||
+ | |inputs=mode='r'<br>nooverwrite=False | ||
+ | |outputs=file object | ||
+ | |description=Opens a file-like object to access the referenced trailer video. Mode can be '''r'''ead or '''w'''rite, and nooverwrite will block a write if a file already exists on the local filesystem.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=getHash | ||
+ | |outputs=hash string | ||
+ | |description=Returns a 64-bit hexadecimal value to uniquely identify a video file.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=parseFilename | ||
+ | |outputs=(title, season, episode, subtitle) | ||
+ | |description=Parse the filename stored in the object.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=importMetadata | ||
+ | |inputs=metadata<br>overwrite=False | ||
+ | |description=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.}} | ||
+ | |- | ||
+ | |{{FunctionDoc|level=h4 | ||
+ | |name=fromFilename<br>(classmethod) | ||
+ | |inputs=filename | ||
+ | |outputs=self | ||
+ | |description=Creates a new object with initial data parsed from the filename. Object is not stored to the database.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
=== Song === | === Song === | ||
==== fromAlbum ==== | ==== fromAlbum ==== | ||
Line 169: | Line 310: | ||
(classmethod) | (classmethod) | ||
− | [[Category: | + | [[Category:0.24_Python_Bindings]] |
Latest revision as of 20:02, 24 June 2011
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
>>> 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
| ||||||
open
| ||||||
delete
| ||||||
formatPath
>>> prog.formatPath('%T/(%oY%-%om%-%od) %S') 'Archer/(2010-01-14) .mpg' | ||||||
formatJob
>>> prog.formatJob('/some/job %DIR% %FILE% %TITLE%') /some/job /srv/mounts/mythtv/video 2062_20101002230000.mpg Archer | ||||||
fromRecorded
|
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
|
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.
These are shared methods supported by all read/write classes.
create
>>> vid = Video().create({'title':'test file', 'filename':'path/to/test/file.avi', 'hash':'00000000'}) >>> vid <Video 'test file' at 0x8051b8ae0> | ||||||
update
| ||||||
delete
|
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
>>> 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
| ||||||
fromProgram
|
Recorded
cast
seek
markup
open
| ||||||
formatPath
>>> rec.formatPath('%T/(%oY%-%om%-%od) %S') 'Archer/(2010-01-14) .mpg' | ||||||
importMetadata
| ||||||
fromProgram
|
RecordedProgram
This class represents additional guide information attached to a recording in the `recordedprogram` table.
fromRecorded
|
OldRecorded
This class is used to manage old recording records. The create() method can be used, but update() and delete() have been disabled.
setDuplicate
|
Job
This class is used to manage and create new tasks to be run through the Job Queue.
setComment
| ||||||
setStatus
|
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
| ||||||
openBanner
| ||||||
openCoverart
| ||||||
openFanart
| ||||||
openScreenshot
| ||||||
openTrailer
| ||||||
getHash
| ||||||
parseFilename
| ||||||
importMetadata
| ||||||
fromFilename
|
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)