def setParam(param, value, file): config = [] try: param = param.upper() + '=' config = sfile.readlines(file) except: pass value = str(value) copy = [] for line in config: line = line.strip() if (len(line) > 0) and (not line.startswith(param)): copy.append(line) if len(value) > 0: copy.append(param + value) f = sfile.file(file, 'w') for line in copy: f.write(line) f.write('\n') f.close()
def GetWatchedStatus(self, metaInfo): # Do nothing if we do not know where to look if not metaInfo['seriesName']: return False # Generate the file system friendly name fileName = os.path.join(self.cache_dir, 'watched_' + self.format_filename(metaInfo['episodeSeriesName']) + '.txt') fileName = fileName.strip() # If the file does not exist then we have not watched this entry yet if not sfile.isfile(fileName): return False try: # Check if we still know this file, otherwise try to open it # This way, the content will be read only once for consecutive requests on the same series if not metaInfo['episodeSeriesName'] == self.lastName: self.lastName = metaInfo['episodeSeriesName'] self.lastContent = sfile.readlines(fileName) # Generate a string for the episode epName = self._GenerateEPName(metaInfo) # Look this episode name up in the table for line in self.lastContent: line = line.split(DELIMETER) if line[0] == epName: return line[1] == '1' except Exception,e: # Reset everything self.lastContent = [] self.lastName = '' print 'WCO EXCEPTION: READING META ' + str(e) raise
def SetWatchedStatus(self, metaInfo, status): # If the seriesName is not known then we do not know where to put the information if not metaInfo['episodeSeriesName']: return try: # Generate the file system friendly name fileName = os.path.join(self.cache_dir, 'watched_' + self.format_filename(metaInfo['episodeSeriesName']) + '.txt') fileName = fileName.strip() # Generate the field name from the meta info epName = self._GenerateEPName(metaInfo) stateStr = '1' if status == True else '0' valueFound = False lines = [] # If the file exists then read the content and try to find the content if sfile.isfile(fileName): lines = sfile.readlines(fileName) for idx, line in enumerate(lines): if line.split(DELIMETER)[0] == epName: lines[idx] = '%s%s%s' % (epName, DELIMETER, stateStr) valueFound = True break # ... otherwise append the content if not valueFound: lines.append('%s%s%s' % (epName, DELIMETER, stateStr)) # Write the file back sfile.writelines(fileName, lines) except Exception, e: print 'WCO EXCEPTION: WRITING METADATA: ' + str(e)
def getParams(file): params = {} try: config = [] config = sfile.readlines(file) except Exception, e: return None
def getChannelFromFile(self, id): path = os.path.join(OTT_CHANNELS, id) if not sfile.exists(path): return None cfg = sfile.readlines(path) return Channel(cfg)
def get(param, file): try: config = sfile.readlines(file) except: return None for line in config: if line.startswith(param): return line.split(param, 1)[-1].split('=', 1)[-1].strip() return None
def getChannelFromFile(id, folder): from channel import Channel path = os.path.join(folder, id) if not sfile.exists(path): return None cfg = sfile.readlines(path) return Channel(cfg)
def getParam(param, cfg): if isinstance(cfg, dict): try: return cfg[param] except: return None try: config = [] config = sfile.readlines(cfg) except Exception, e: return None
def getChannelFromFile(id): path = os.path.join(TVP_CHANNELS, id) if not sfile.exists(path): return None # f = open(path, mode='r') cfg = sfile.readlines(path) # f.close return Channel(cfg)
def getChannelFromFile(id): path = os.path.join(OTT_CHANNELS, id) if not sfile.exists(path): return None # f = open(path, mode='r') cfg = sfile.readlines(path) # f.close return Channel(cfg)
def getChannelFromFile(self, id): path = os.path.join(channelPath, id) if not sfile.exists(path): return None cfg = sfile.readlines(path) return Channel(cfg) ch = Channel(cfg[0], cfg[1], cfg[2], cfg[3], cfg[4], cfg[5], cfg[6]) return ch
def getParam(param, file): try: config = [] param = param.upper() + '=' config = sfile.readlines(file) except: return '' for line in config: if line.startswith(param): return line.split(param, 1)[-1].strip() return ''
def getPlaylistFromLocalSrc(src): videos = [] playlist = sfile.readlines(src) root = getExternalDrive() for video in playlist: video = video.strip() if len(video) == 0: continue video = os.path.join(root, video) videos.append(video) return videos
def getAll(file): try: lines = sfile.readlines(file) except: return [] config = [] for line in lines: try: line = line.split('=', 1) if len(line) == 1: config.append([line[0].strip(), '']) else: config.append([line[0].strip(), line[1].strip()]) except: pass return config
def getParams(file): params = {} try: config = [] config = sfile.readlines(file) except Exception as e: return None for line in config: items = line.split('=', 1) try: params[items[0]] = items[1] except: pass return params
def getParam(param, cfg): if isinstance(cfg, dict): try: return cfg[param] except: return None try: config = [] config = sfile.readlines(cfg) except Exception as e: return None param += '=' for line in config: if line.startswith(param): return line.split(param, 1)[-1].strip() return None
def GetWatchedStatus(self, metaInfo): # Do nothing if we do not know where to look if not metaInfo['seriesName']: return False # Generate the file system friendly name fileName = os.path.join( self.cache_dir, 'watched_' + self.format_filename(metaInfo['seriesName']) + '.txt') fileName = fileName.strip() # If the file does not exist then we have not watched this entry yet if not sfile.isfile(fileName): return False try: # Check if we still know this file, otherwise try to open it # This way, the content will be read only once for consecutive requests on the same series if not metaInfo['seriesName'] == self.lastName: self.lastName = metaInfo['seriesName'] self.lastContent = sfile.readlines(fileName) # Generate a string for the episode epName = self._GenerateEPName(metaInfo) # Look this episode name up in the table for line in self.lastContent: line = line.split(DELIMETER) if line[0] == epName: return line[1] == '1' except Exception, e: # Reset everything self.lastContent = [] self.lastName = '' print 'WCO EXCEPTION: READING META ' + str(e) raise
def SetWatchedStatus(self, metaInfo, status): # If the seriesName is not known then we do not know where to put the information if not metaInfo['seriesName']: return try: # Generate the file system friendly name fileName = os.path.join( self.cache_dir, 'watched_' + self.format_filename(metaInfo['seriesName']) + '.txt') fileName = fileName.strip() # Generate the field name from the meta info epName = self._GenerateEPName(metaInfo) stateStr = '1' if status == True else '0' valueFound = False lines = [] # If the file exists then read the content and try to find the content if sfile.isfile(fileName): lines = sfile.readlines(fileName) for idx, line in enumerate(lines): if line.split(DELIMETER)[0] == epName: lines[idx] = '%s%s%s' % (epName, DELIMETER, stateStr) valueFound = True break # ... otherwise append the content if not valueFound: lines.append('%s%s%s' % (epName, DELIMETER, stateStr)) # Write the file back sfile.writelines(fileName, lines) except Exception, e: print 'WCO EXCEPTION: WRITING METADATA: ' + str(e)
def playFile(path): items = parse(sfile.readlines(path)) utils.playItems(items)