def PlexDVRAPI_AutoStart(reason, session=None, **kwargs): if reason == 0: for type in tunerTypes: discover = getdeviceinfo.deviceinfo(type) if discover[type]["TunerCount"] > 0 and discover[type][ 'NumChannels'] > 0: if path.exists('/www/%s/discover.json' % tunerfolders[type]): starthttpserver(type) if path.exists('/www/%s/device.xml' % tunerfolders[type]): startssdp(type)
def startssdp(dvbtype): discover = getdeviceinfo.deviceinfo(dvbtype) device_uuid = discover[dvbtype]['DeviceUUID'] print '[Plex DVR API] Starting SSDP for %s, device_uuid: %s' % ( dvbtype, device_uuid) local_ip_address = getIP() ssdp = SSDPServer() ssdp.register( 'local', 'uuid:{}::upnp:rootdevice'.format(device_uuid), 'upnp:rootdevice', 'http://{}:{}/device.xml'.format(local_ip_address, tunerports[dvbtype])) thread_ssdp = threading.Thread(target=ssdp.run, args=()) thread_ssdp.daemon = True # Daemonize thread thread_ssdp.start()
def populate(self, answer=None): BaseURL = {} FriendlyName = {} TunerCount = {} Source = {} NoOfChannels = {} self.label = [] for type in tunerTypes: self.discover = getdeviceinfo.deviceinfo(type) self.lineupstatus = getlineupstatus.lineupstatus(type) BaseURL[type] = 'BaseURL: %s\n' % str( self.discover[type]["BaseURL"]) FriendlyName[type] = 'FriendlyName: %s\n' % str( self.discover[type]["FriendlyName"]) TunerCount[type] = 'TunerCount: %s\n' % str( self.discover[type]["TunerCount"]) Source[type] = 'Source: %s\n' % str(tunerfolders[type]).title() NoOfChannels[type] = 'Channels: %s\n\n' % str( self.discover[type]['NumChannels']) print '[Plex DVR API] %s' % str(BaseURL[type]).replace('\n', '') print '[Plex DVR API] %s' % str(FriendlyName[type]).replace( '\n', '') print '[Plex DVR API] %s' % str(Source[type]).replace('\n', '') print '[Plex DVR API] %s' % str(TunerCount[type]).replace('\n', '') print '[Plex DVR API] %s' % str(NoOfChannels[type]).replace( '\n\n', '') if self.discover[type]["TunerCount"] > 0 and self.discover[type][ 'NumChannels'] > 0 and type != "multi": self.label.append(BaseURL[type] + FriendlyName[type] + Source[type] + TunerCount[type] + NoOfChannels[type]) else: print '[Plex DVR API] skipping tuner %s' % type continue if not path.exists( '/www/%s/discover.json' % tunerfolders[type]) or getIP( ) == '0.0.0.0' or self.discover[type]["TunerCount"] < 2: self["key_red"].hide() self["key_green"].hide() self["key_yellow"].hide() self["key_blue"].hide() if getIP() == '0.0.0.0': self["InfoScrollLabel"].setText( _('No IP address found, please make sure you are connected to your LAN via ethernet, wifi is not supported at this time.\n\nPress OK to close' )) self["closeaction"].setEnabled(True) elif self.discover[type]["TunerCount"] < 2: self["InfoScrollLabel"].setText( _('WARNING: It seems you have a single tuner box, if the box is not left in Standby your Plex recordings WILL fail.\n\nPress OK to continue' )) self["okaction"].setEnabled(True) self["key_green"].setText(_("Create")) self["key_yellow"].setText("") else: self["InfoScrollLabel"].setText( _('Please note: To use the DVR feature in Plex, you need to be a Plex Pass user.\nFor more information about Plex Pass see https://www.plex.tv/features/plex-pass\n\nPress OK to continue' )) self["okaction"].setEnabled(True) self["key_green"].setText(_("Create")) self["key_yellow"].setText("") else: self["key_green"].setText(_('Update')) self["key_yellow"].setText(_("Reset DVR")) self.ok()