Example #1
0
 def getHtml(self, user=False):
     #
     #listings = _check_tvlistingsqueue(self._q_tvlistings)
     #
     chan_current = self._getChan()
     #
     html_channels = html_channels_user_and_all(room_id=self._room_id,
                                                device_id=self._device_id,
                                                user=user,
                                                chan_current=chan_current,
                                                package=["virginmedia_package", self._package()])
     #
     if self.recordings_timestamp:
         recordings_datetime = self.recordings_timestamp.strftime('%d/%m/%Y %H:%M:%S')
     else:
         recordings_datetime = ''
     #
     args = {'room_id': self._room_id,
             'device_id': self._device_id,
             'html_recordings': self._getHtml_recordings(),
             'timestamp_recordings': recordings_datetime,
             'now_viewing_logo': get_channel_logo_from_devicekey(self._type, chan_current),
             'now_viewing': get_channel_name_from_devicekey(self._type, chan_current),
             'html_channels': html_channels}
     #
     return self._getHtml_generic(args)
Example #2
0
 def sendCmd(self, request):
     #
     try:
         code = False
         response = False
         #
         # if request['command'] == 'getHtml_recordings':
         #     response = self._getHtml_recordings()
         # el
         if request['command'] == 'getchannel':
             chan_no = self._getChan()
             if bool(chan_no):
                 #
                 chan_name = get_channel_name_from_devicekey(self._type, chan_no)
                 #
                 chan_logo = get_channel_logo_from_devicekey(self._type, chan_no)
                 chan_logo = chan_logo if not chan_logo=='-' else 'ic_blank.png'
                 #
                 response = '{"chan_no": ' + str(chan_no) + ', ' + \
                            '"chan_name": "' + chan_name + '", ' + \
                            '"chan_logo": "' + chan_logo + '"}'
             else:
                 response = False
         elif request['command'] == 'channel':
             response = self._send_telnet(ipaddress=self._ipaddress(),
                                          port=self._port(),
                                          data=("SETCH {}\r").format(request['chan']),
                                          response=True)
             if response.startswith('CH_FAILED'):
                 print_command('channel',
                               self.dvc_or_acc_id(),
                               self._type,
                               self._ipaddress(),
                               response)
                 return False
         elif request['command'] == 'command':
             code = self.commands[request['code']]
             try:
                 response = self._send_telnet(self._ipaddress(), self._port(), data=code)
             except:
                 response = False
         #
         x = request['code'] if code else request['command']
         print_command (x,
                        self.dvc_or_acc_id(),
                        self._type,
                        self._ipaddress(),
                        response)
         return response
     except:
         print_command(request['command'],
                       self.dvc_or_acc_id(),
                       self._type,
                       self._ipaddress(),
                       'ERROR')
         return False