def determineLength(self, filename): self.log("determineLength " + filename) try: self.File = FileAccess.open(filename, "rb") except: self.log("Unable to open the file") return if self.verifyFLV() == False: self.log("Not a valid FLV") self.File.close() return 0 tagheader = self.findLastVideoTag() if tagheader is None: self.log("Unable to find a video tag") self.File.close() return 0 dur = self.getDurFromTag(tagheader) self.File.close() self.log("Duration: " + str(dur)) return dur
def getSmartPlaylistName(self, fle): self.log("getSmartPlaylistName " + fle) fle = xbmc.translatePath(fle) try: xml = FileAccess.open(fle, "r") except: self.log('Unable to open smart playlist') return '' try: dom = parse(xml) except: xml.close() self.log("getSmartPlaylistName return unable to parse") return '' xml.close() try: plname = dom.getElementsByTagName('name') self.log("getSmartPlaylistName return " + plname[0].childNodes[0].nodeValue) return plname[0].childNodes[0].nodeValue except: self.playlisy('Unable to find element name') self.log("getSmartPlaylistName return")
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 CEDownloader(): xbmc.log('script.pseudotv.live-donordownload: CEDownloader') CEURL = (BaseURL + 'CEURL.txt') CEDEST = xbmc.translatePath(os.path.join(SETTINGS_LOC, 'PTVL_Cinema_Experience_Pack.zip')) CEPath = xbmc.translatePath(os.path.join(SETTINGS_LOC)) if dlg.yesno("PseudoTV Live", "Download Cinema Experience Pack", ""): try: os.remove(xbmc.translatePath(LinkPath)) except: pass try: urllib.urlretrieve(LinkURLPath, (xbmc.translatePath(LinkPath))) f = FileAccess.open((xbmc.translatePath(LinkPath)), "r") linesLST = f.readlines() CEURLPath = linesLST[3] download(CEURLPath, CEDEST) all(CEDEST, CEPath) if xbmcvfs.exists(CE_LOC): REAL_SETTINGS.setSetting("CinemaPack", "true") else: REAL_SETTINGS.setSetting("CinemaPack", "false") os.remove(CEDEST) except: pass REAL_SETTINGS.openSettings() else: REAL_SETTINGS.openSettings()
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 LogoDownloader(): xbmc.log('script.pseudotv.live-donordownload: LogoDownloader') LogoPath = xbmc.translatePath(os.path.join(SETTINGS_LOC)) if dlg.yesno("PseudoTV Live", "Download Color Logos or No, Download Mono Logos", ""): LogoDEST = LogoPath + '/PTVL_Color.zip' i = 1 else: LogoDEST = LogoPath + '/PTVL_Mono.zip' i = 2 if not DEFAULT_LOGO_LOC: os.makedirs(DEFAULT_LOGO_LOC) try: os.remove(xbmc.translatePath(LinkPath)) except: pass try: urllib.urlretrieve(LinkURLPath, (xbmc.translatePath(LinkPath))) f = FileAccess.open((xbmc.translatePath(LinkPath)), "r") linesLST = f.readlines() LogoURLPath = linesLST[i] download(LogoURLPath, LogoDEST) all(LogoDEST, LogoPath) REAL_SETTINGS.setSetting("ChannelLogoFolder", DEFAULT_LOGO_LOC) os.remove(LogoDEST) except: pass REAL_SETTINGS.openSettings()
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) self.pid = -1 try: self.File = FileAccess.open(filename, "rb", None) except: self.log("Unable to open the file") return self.filesize = self.getFileSize() self.packetLength = self.findPacketLength() if self.packetLength <= 0: return 0 start = self.getStartTime() self.log('Start - ' + str(start)) end = self.getEndTime() self.log('End - ' + str(end)) if end > start: dur = int((end - start) / 90000) else: dur = 0 self.File.close() self.log("Duration: " + str(dur)) return dur
def determineLength(self, filename): self.log("determineLength " + filename) try: self.File = FileAccess.open(filename, "rb", None) except: self.log("Unable to open the file") return dur = self.readHeader() self.File.close() self.log("Duration: " + str(dur)) return dur
def determineLength(self, filename): self.log("determineLength " + filename) try: self.File = FileAccess.open(filename, "rb") except: self.log("Unable to open the file") return size = self.findHeader() if size == 0: self.log('Unable to find the segment info') dur = 0 else: dur = self.parseHeader(size) self.log("Duration is " + str(dur)) return dur
def BumperDownloader(): xbmc.log('script.pseudotv.live-donordownload: BumperDownloader') BUMPERDEST = xbmc.translatePath(os.path.join(SETTINGS_LOC, 'Bumpers.zip')) BumperPath = xbmc.translatePath(os.path.join(SETTINGS_LOC)) try: os.remove(BUMPERDEST) except: pass if dlg.yesno("PseudoTV Live", "Download Bumpers?", "700Mb File"): try: os.remove(xbmc.translatePath(LinkPath)) except: pass try: urllib.urlretrieve(LinkURLPath, (xbmc.translatePath(LinkPath))) f = FileAccess.open((xbmc.translatePath(LinkPath)), "r") linesLST = f.readlines() BumperURLPath = linesLST[0] download(BumperURLPath, BUMPERDEST) all(BUMPERDEST, BumperPath) REAL_SETTINGS.setSetting("bumpers", "true") REAL_SETTINGS.setSetting("bumpersfolder", BUMPER_LOC) REAL_SETTINGS.setSetting("numbumpers", "1") os.remove(BUMPERDEST) except: pass REAL_SETTINGS.openSettings() else: REAL_SETTINGS.openSettings()
def CEDownloader(): xbmc.log('script.pseudotv.live-donordownload: CEDownloader') CEURL = (BaseURL + 'CEURL.txt') CEDEST = xbmc.translatePath( os.path.join(SETTINGS_LOC, 'PTVL_Cinema_Experience_Pack.zip')) CEPath = xbmc.translatePath(os.path.join(SETTINGS_LOC)) if dlg.yesno("PseudoTV Live", "Download Cinema Experience Pack", ""): try: os.remove(xbmc.translatePath(LinkPath)) except: pass try: urllib.urlretrieve(LinkURLPath, (xbmc.translatePath(LinkPath))) f = FileAccess.open((xbmc.translatePath(LinkPath)), "r") linesLST = f.readlines() CEURLPath = linesLST[3] download(CEURLPath, CEDEST) all(CEDEST, CEPath) if xbmcvfs.exists(CE_LOC): REAL_SETTINGS.setSetting("CinemaPack", "true") else: REAL_SETTINGS.setSetting("CinemaPack", "false") os.remove(CEDEST) except: pass REAL_SETTINGS.openSettings() else: REAL_SETTINGS.openSettings()
def main(): pass import re import os import xbmcaddon, xbmc, xbmcgui from resources.lib.Globals import * from resources.lib.Settings import * from resources.lib.FileAccess import FileAccess flename = xbmc.translatePath(os.path.join(Globals.SETTINGS_LOC, 'settings2.xml')) flenname = xbmc.translatePath(os.path.join(Globals.SETTINGS_LOC, 'new_settings2.xml')) OpnFil = FileAccess.open(flename, "rb") WrtFil = FileAccess.open(flename, "w") WrtFil.write('<settings> \n') WrtFil.write(' ' + '<setting id="Version" value="2.1.0" />\n') # Number of total lines in Settings2.xml file nr_of_lines = sum(1 for line in FileAccess.open(flename)) # def simplecount(filename): # lines = 0 # for line in FileAccess.open(flename): # lines += 1 # return nr_of_lines # Procedure to get the total number of channels for this Settings2.xml file