def determineLength(self, filename): self.log("determineLength " + filename) fleName, fleExt = os.path.splitext(filename) fleName += '.nfo' duration = 0 durationinseconds = 0 if FileAccess.exists(fleName): file = FileAccess.open(fleName, "r") dom = parse(file) try: xmldurationinseconds = dom.getElementsByTagName('durationinseconds')[0].toxml() durationinseconds = xmldurationinseconds.replace('<durationinseconds>','').replace('</durationinseconds>','') duration = int(durationinseconds) except Exception,e: duration = 0 if duration == 0: try: xmlruntime = dom.getElementsByTagName('runtime')[0].toxml() runtime = xmlruntime.replace('<runtime>','').replace('</runtime>','').replace(' min.','') runtime = int(runtime) duration = runtime * 60 except Exception,e: duration = 0
def determineLength(self, filename): self.log("determineLength " + filename) fleName, fleExt = os.path.splitext(filename) fleName += '.nfo' runtime = 0 if FileAccess.exists(fleName): try: file = FileAccess.open(fleName, "r") dom = parse(file) xmlruntime = dom.getElementsByTagName('runtime')[0].toxml() runtime = xmlruntime.replace('<runtime>','').replace('</runtime>','') runtime = int(runtime) except: self.log("Unable to open the file, defaulting to 3600") self.log(traceback.format_exc(), xbmc.LOGERROR) dur = 3600 return dur if runtime == 0: self.log('Unable to find the runtime info, defaulting to 3600') dur = 3600 else: dur = int(runtime) * 60 self.log("Duration is " + str(dur)) return dur
def determineLength(self, filename): self.log("determineLength " + filename) fleName, fleExt = os.path.splitext(filename) fleName += '.nfo' runtime = 0 if FileAccess.exists(fleName): try: file = FileAccess.open(fleName, "r") dom = parse(file) xmlruntime = dom.getElementsByTagName('runtime')[0].toxml() runtime = xmlruntime.replace('<runtime>', '').replace('</runtime>', '') runtime = int(runtime) except: self.log("Unable to open the file, defaulting to 3600") self.log(traceback.format_exc(), xbmc.LOGERROR) dur = 3600 return dur if runtime == 0: self.log('Unable to find the runtime info, defaulting to 3600') dur = 3600 else: dur = int(runtime) * 60 self.log("Duration is " + str(dur)) return dur
def deleteSkin(self, selSkin): if selSkin == 'Default' or FileAccess.exists(self.SkinPanel.getSelectedItem().getProperty('PTVL.SKINPATH')) == 'false': return try: if yesnoDialog('%s "%s" Skin' %('Delete', selSkin)) == True: shutil.rmtree(self.SkinPanel.getSelectedItem().getProperty('PTVL.SKINPATH')) except: pass REAL_SETTINGS.setSetting("SkinSelector",'Default') self.closeManager()
def donorCHK(): xbmc.log('script.pseudotv.live-service: donorCHK') DonorPath = (os.path.join(ADDON_PATH, 'resources', 'lib', 'Donor.pyo')) DL_DonorPath = (os.path.join(ADDON_PATH, 'resources', 'lib', 'Donor.py')) if FileAccess.exists(DonorPath): REAL_SETTINGS.setSetting("AT_Donor", "true") REAL_SETTINGS.setSetting("COM_Donor", "true") REAL_SETTINGS.setSetting("TRL_Donor", "true") REAL_SETTINGS.setSetting("CAT_Donor", "true") elif FileAccess.exists(DL_DonorPath): REAL_SETTINGS.setSetting("AT_Donor", "true") REAL_SETTINGS.setSetting("COM_Donor", "true") REAL_SETTINGS.setSetting("TRL_Donor", "true") REAL_SETTINGS.setSetting("CAT_Donor", "true") else: REAL_SETTINGS.setSetting("AT_Donor", "false") REAL_SETTINGS.setSetting("COM_Donor", "false") REAL_SETTINGS.setSetting("TRL_Donor", "false") REAL_SETTINGS.setSetting("CAT_Donor", "false")
def makeXMLTV(self, data, filepath): self.log('makeXMLTV') finished = False if not FileAccess.exists(os.path.dirname(filepath)): FileAccess.mkdir(os.path.dirname(filepath)) if FileAccess.exists(filepath): FileAccess.delete(filepath) fle = open(filepath, "w") try: xml = data.toxml(encoding='UTF-8'); log('writing item: %s' % (filepath)) if FileAccess.exists(filepath): finished = True except Exception as e: xml = '<?xml version="1.0" encoding="UTF-8"?>' xml += '<error>' + str(e) + '</error>'; xmllst = xml.replace('><','>\n<') xmllst = self.cleanChanName(xmllst) fle.write("%s" % xmllst) fle.close() return finished
def deleteSkin(self, selSkin): if selSkin == 'Default' or FileAccess.exists( self.SkinPanel.getSelectedItem().getProperty( 'PTVL.SKINPATH')) == 'false': return try: if yesnoDialog('%s "%s" Skin' % ('Delete', selSkin)) == True: shutil.rmtree(self.SkinPanel.getSelectedItem().getProperty( 'PTVL.SKINPATH')) except: pass REAL_SETTINGS.setSetting("SkinSelector", 'Default') self.closeManager()
def DeleteSettings2(): log('utilities: DeleteSettings2') ClearChanFavorites(False) if FileAccess.exists(SETTINGS_FLE): if yesnoDialog("Delete Current Channel Configurations?"): try: REAL_SETTINGS.setSetting("Config", "") REAL_SETTINGS.setSetting("CurrentChannel", "1") FileAccess.delete(SETTINGS_FLE) infoDialog("Channel Configurations Cleared") except: pass # Return to PTVL Settings REAL_SETTINGS.openSettings()
def DeleteSettings2(): log('utilities: DeleteSettings2') ClearChanFavorites(False) if FileAccess.exists(SETTINGS_FLE): if yesnoDialog("Delete Current Channel Configurations?"): try: REAL_SETTINGS.setSetting("Config","") REAL_SETTINGS.setSetting("CurrentChannel","1") FileAccess.delete(SETTINGS_FLE) infoDialog("Channel Configurations Cleared") except: pass # Return to PTVL Settings REAL_SETTINGS.openSettings()
def skinMeta(self, skinname): skinBasePath = xbmc.translatePath(os.path.join(PTVL_SKIN_LOC, skinname)) skinBaseURL = 'https://raw.githubusercontent.com/PseudoTV/PseudoTV_Skins/master/' + skinname cleanSkin = skinname #Skin local (already downloaded) if FileAccess.exists(os.path.join(skinBasePath, 'skin.xml')): SkinLocal = 'true' skinBase = skinBasePath LocalLogo = 'local.png' else: SkinLocal = 'false' LocalLogo = 'NA.png' skinBase = skinBaseURL try: #Fill Skin meta if SkinLocal == 'false': xml = open_url(os.path.join(skinBaseURL + '/skin.xml')) else: xml = open(os.path.join(skinBasePath, 'skin.xml'), "r") dom = parse(xml) name = dom.getElementsByTagName('name') version = dom.getElementsByTagName('version') skinname = dom.getElementsByTagName('skinname') resolutions = dom.getElementsByTagName('defaultresolution') version = (version[0].childNodes[0].nodeValue).rstrip() sknname = (skinname[0].childNodes[0].nodeValue).rstrip() resolution = (resolutions[0].childNodes[0].nodeValue).rstrip() xml.close() except: return #Skin currently inuse CurSkin = 'false' if self.CurrentSkin.lower() == sknname.lower(): CurSkin = 'true' sknname = ' [ ' + sknname + ' ]' #Check PTVL.GUI version SkinOld = 'false' OutLogo = 'NA.png' if version != PTVL_SKINVER: SkinOld = 'true' OutLogo = os.path.join(IMAGES_LOC, 'outdated.png') # sknname += ' OUTDATED, please contact skin developer' self.SkinItems = xbmcgui.ListItem(label=sknname) self.SkinItems.setProperty('PTVL.isSKINLOCAL', SkinLocal) self.SkinItems.setProperty('PTVL.SKINLOCAL', LocalLogo) self.SkinItems.setProperty('PTVL.isSKINSEL', CurSkin) self.SkinItems.setProperty('PTVL.isSKINOUTDATED', SkinOld) self.SkinItems.setProperty('PTVL.SKINOUTDATED', OutLogo) self.SkinItems.setProperty('PTVL.SKINNAME', sknname) self.SkinItems.setProperty('PTVL.SKIN', cleanSkin) self.SkinItems.setProperty('PTVL.SKINRESOLUTION', str(resolution)) self.SkinItems.setProperty('PTVL.SKINLOGO', os.path.join(skinBase, 'logo.png')) self.SkinItems.setProperty('PTVL.SKINVERSION', 'v.' + version) self.SkinItems.setProperty( 'PTVL.SKINAUTHOR', 'Designed by: ' + name[0].childNodes[0].nodeValue) self.SkinItems.setProperty('PTVL.SKINSHOT1', os.path.join(skinBase, 'screenshot01.png')) self.SkinItems.setProperty('PTVL.SKINSHOT2', os.path.join(skinBase, 'screenshot02.png')) self.SkinItems.setProperty('PTVL.SKINSHOT3', os.path.join(skinBase, 'screenshot03.png')) self.SkinItems.setProperty('PTVL.SKINSHOT4', os.path.join(skinBase, 'screenshot04.png')) self.SkinItems.setProperty("PTVL.SKINPATH", str(skinBasePath)) self.SkinItems.setProperty("PTVL.SKINBASE", str(skinBase)) self.SkinItems.setProperty("PTVL.SKINURL", str(skinBaseURL)) self.SkinItems.setProperty("PTVL.SKINZIP", str(skinBaseURL + '/' + sknname + '.zip')) self.SkinPanel.addItem(self.SkinItems) return
def skinMeta(self, skinname): skinBasePath = xbmc.translatePath(os.path.join(PTVL_SKIN_LOC,skinname)) skinBaseURL = 'https://raw.githubusercontent.com/PseudoTV/PseudoTV_Skins/master/'+skinname cleanSkin = skinname #Skin local (already downloaded) if FileAccess.exists(os.path.join(skinBasePath,'skin.xml')): SkinLocal = 'true' skinBase = skinBasePath LocalLogo = 'local.png' else: SkinLocal = 'false' LocalLogo = 'NA.png' skinBase = skinBaseURL try: #Fill Skin meta if SkinLocal == 'false': xml = open_url(os.path.join(skinBaseURL + '/skin.xml')) else: xml = open(os.path.join(skinBasePath,'skin.xml'), "r") dom = parse(xml) name = dom.getElementsByTagName('name') version = dom.getElementsByTagName('version') skinname = dom.getElementsByTagName('skinname') resolutions = dom.getElementsByTagName('defaultresolution') version = (version[0].childNodes[0].nodeValue).rstrip() sknname = (skinname[0].childNodes[0].nodeValue).rstrip() resolution = (resolutions[0].childNodes[0].nodeValue).rstrip() xml.close() except: return #Skin currently inuse CurSkin = 'false' if self.CurrentSkin.lower() == sknname.lower(): CurSkin = 'true' sknname = ' [ ' + sknname + ' ]' #Check PTVL.GUI version SkinOld = 'false' OutLogo = 'NA.png' if version != PTVL_SKINVER: SkinOld = 'true' OutLogo = os.path.join(IMAGES_LOC,'outdated.png') # sknname += ' OUTDATED, please contact skin developer' self.SkinItems = xbmcgui.ListItem(label=sknname) self.SkinItems.setProperty('PTVL.isSKINLOCAL',SkinLocal) self.SkinItems.setProperty('PTVL.SKINLOCAL',LocalLogo) self.SkinItems.setProperty('PTVL.isSKINSEL',CurSkin) self.SkinItems.setProperty('PTVL.isSKINOUTDATED',SkinOld) self.SkinItems.setProperty('PTVL.SKINOUTDATED',OutLogo) self.SkinItems.setProperty('PTVL.SKINNAME',sknname) self.SkinItems.setProperty('PTVL.SKIN',cleanSkin) self.SkinItems.setProperty('PTVL.SKINRESOLUTION',str(resolution)) self.SkinItems.setProperty('PTVL.SKINLOGO',os.path.join(skinBase,'logo.png')) self.SkinItems.setProperty('PTVL.SKINVERSION','v.'+version) self.SkinItems.setProperty('PTVL.SKINAUTHOR','Designed by: ' + name[0].childNodes[0].nodeValue) self.SkinItems.setProperty('PTVL.SKINSHOT1',os.path.join(skinBase,'screenshot01.png')) self.SkinItems.setProperty('PTVL.SKINSHOT2',os.path.join(skinBase,'screenshot02.png')) self.SkinItems.setProperty('PTVL.SKINSHOT3',os.path.join(skinBase,'screenshot03.png')) self.SkinItems.setProperty('PTVL.SKINSHOT4',os.path.join(skinBase,'screenshot04.png')) self.SkinItems.setProperty("PTVL.SKINPATH", str(skinBasePath)) self.SkinItems.setProperty("PTVL.SKINBASE", str(skinBase)) self.SkinItems.setProperty("PTVL.SKINURL", str(skinBaseURL)) self.SkinItems.setProperty("PTVL.SKINZIP", str(skinBaseURL + '/' + sknname +'.zip')) self.SkinPanel.addItem(self.SkinItems) return