Beispiel #1
0
    def __init__(self, myth_prog_data):
        self.pinf = ProgInfo()
        # Set attributes of pinf from values in myth_prog_data dict:
        self.pinf.filename = myth_prog_data.pop('FileName')
        self.pinf.hostname = myth_prog_data.pop('HostName')
        self.pinf.filesize = myth_prog_data.pop('FileSize')
        self.pinf.title = myth_prog_data.pop('Title')
        self.pinf.subtitle = myth_prog_data.pop('SubTitle')
        sg = myth_prog_data['Recording']['StorageGroup']
        api = MythApi()
        self.pinf.directory = api.storage_dir_for_name(sg, self.pinf.hostname)

        # Set other attributes from items in myth_prog_data:
        for k,v in myth_prog_data.items():
            setattr(self,k.lower(),v)
        # But we want self.channel to be a Channel object,
        # so "rename" self.channel to self._Channel:
        self._Channel = self.channel
        self.channel = Channel(self._Channel['ChanId'])

        # The 'StartTs' and 'EndTs' fields are used to calculate the duration -- these represent the
        # actual start and end times of the recording; the fields 'StartTime' and 'EndTime' are the
        # scheduled times, and do not reflect the fact that the recording may have started and/or
        # ended at other than the scheduled times.
        end_time_str = myth_prog_data['Recording']['EndTs']
        start_time_str = myth_prog_data['Recording']['StartTs']
        self.duration = time_diff_from_strings(start_time_str, end_time_str) # in seconds
        # while we're at it, save the starting and ending times as datetime.datetime objects:
        self.start_at = iso_to_tz_aware(start_time_str)
        self.end_at = iso_to_tz_aware(end_time_str)
 def __fill_myth_tv_recording_list(self):
     prog_dict = self.api._call_myth_api(TvRecordingApi.__api_service_name, 'GetRecordedList')
     api_fields = prog_dict['ProgramList']['Programs']['Program']
     ret_list = []
     if api_fields and len(api_fields) > 0:
         for line in api_fields:
             sdir = self.api.storage_dir_for_name(
                 line['Recording']['StorageGroup'], hostname=line['HostName']
                 )
             line['FileSpec'] = sdir + line['FileName']
             line['Duration'] = time_diff_from_strings(
                 line['Recording']['StartTs'], line['Recording']['EndTs']
                 )
             ret_list.append(line)
     return ret_list