Ticket #13300: 0002-Python-Bindings-Add-recordedfile-table-and-its-usage.patch

File 0002-Python-Bindings-Add-recordedfile-table-and-its-usage.patch, 3.6 KB (added by rcrdnalor, 6 years ago)

Add recordedfile to Python Bindings

  • mythtv/bindings/python/MythTV/__init__.py

    From 643ebb925b655155ce5d6420f5f6ac8a35f07116 Mon Sep 17 00:00:00 2001
    From: rcrdnalor <rcrernst@gmail.com>
    Date: Mon, 2 Jul 2018 20:50:26 +0200
    Subject: [PATCH 2/2] Python Bindings - Add recordedfile table and its usage
    
    ---
     mythtv/bindings/python/MythTV/__init__.py |  3 +-
     mythtv/bindings/python/MythTV/dataheap.py | 35 ++++++++++++++++++++++-
     2 files changed, 36 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/bindings/python/MythTV/__init__.py b/mythtv/bindings/python/MythTV/__init__.py
    index 81fda6a881..2f92d96830 100644
    a b __all_data__ = ['Record', 'Recorded', 'RecordedProgram', 'OldRecorded', \ 
    1515                       'Job', 'Channel', 'Guide', 'Video', 'VideoGrabber', \
    1616                       'InternetContent', 'InternetContentArticles', \
    1717                       'InternetSource', 'Song', 'Album', 'Artist', \
    18                        'MusicPlaylist', 'MusicDirectory', 'RecordedArtwork']
     18                       'MusicPlaylist', 'MusicDirectory', 'RecordedArtwork', \
     19                       'RecordedFile']
    1920
    2021__all_method__      = ['MythBE', 'BEEventMonitor', 'MythSystemEvent', \
    2122                       'Frontend', 'MythDB', 'MythXML', 'MythMusic', \
  • mythtv/bindings/python/MythTV/dataheap.py

    diff --git a/mythtv/bindings/python/MythTV/dataheap.py b/mythtv/bindings/python/MythTV/dataheap.py
    index 946015c412..4bf13970c8 100644
    a b class Recorded( CMPRecord, DBDataWrite ): 
    386386        """Recorded.getProgram() -> Program object"""
    387387        return Program.fromRecorded(self)
    388388
     389    def getRecordedFile(self):
     390        """Recorded.getRecordedFile() -> RecordedFile object"""
     391        return RecordedFile.fromRecorded(self)
     392
    389393    def getRecordedProgram(self):
    390394        """Recorded.getRecordedProgram() -> RecordedProgram object"""
    391395        return RecordedProgram.fromRecorded(self)
    class Recorded( CMPRecord, DBDataWrite ): 
    548552        return fe.send('play','program %d %s' % \
    549553                    (self.chanid, self.starttime.isoformat()))
    550554
    551 class RecordedProgram( CMPRecord, DBDataWrite ):
     555class RecordedFile( CMPRecord, DBDataWrite ):
     556    """
     557    RecordedFile(data=None, db=None) -> RecordedFile object
     558            'data' is a recordedid
     559    """
     560    _key   = ['recordedid']
     561    _defaults = {'filesize':0,          'width':0,        'height':0,
     562                 'fps':0.0,             'aspect':0.0,     'audio_sample_rate':0,
     563                 'audio_channels':0,    'audio_codec':'', 'video_codec':'',
     564                 'comment':u'',         'hostname':'',    'storagegroup':'',
     565                 'container':'',        'total_bitrate':0,
     566                 'video_avg_bitrate':0, 'video_max_bitrate':0,
     567                 'audio_avg_bitrate':0, 'audio_max_bitrate':0}
    552568
     569    def __str__(self):
     570        if self._wheredat is None:
     571            return u"<Uninitialized RecordedFile at %s>" % hex(id(self))
     572        return u"<RecordedFile '%s','%d' at %s>" % (self.basename,
     573                self.recordedid, hex(id(self)))
     574
     575    def __repr__(self):
     576        return str(self).encode('utf-8')
     577
     578    def __init__(self, data=None, db=None):
     579        DBDataWrite.__init__(self, data, db)
     580
     581    @classmethod
     582    def fromRecorded(cls, recorded):
     583        return cls((recorded.recordedid), recorded._db)
     584
     585class RecordedProgram( CMPRecord, DBDataWrite ):
    553586    """
    554587    RecordedProgram(data=None, db=None) -> RecordedProgram object
    555588            'data' is a tuple containing (chanid, storagegroup)