Exemplo n.º 1
0
def addCache(url, text):
	
	# this line should be moved to a more suitable place
	createCacheFolder()
	
	try:
		if folderSize(cacheDir) > 4.0 or freeSpace(cacheDir) < 2.0: #10mb
			for f in os.listdir(cacheDir):
				file = os.path.join(cacheDir, f)
				printl("RM: " + str(file), __name__)
				os.remove(file)
		
		cacheFile = re.sub(r'\W', "", url).strip()
		cacheFileName = cacheDir + u"/" + cacheFile + u".cache"
		if text is not None and len(text) > 0:
			f = Utf8.Utf8(cacheFileName, "w")
			f.write(text)
			f.close
			
			if os.path.getsize(Utf8.utf8ToLatin(cacheFileName)) == 0:
				os.remove(Utf8.utf8ToLatin(cacheFileName))
			
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
Exemplo n.º 2
0
 def parseNfo(self, name):
     try:
         printl("-> About to read from nfo-file: " + name + u".nfo", self,
                "I")
         f = Utf8.Utf8(name + u".nfo", "r")
         lines = f.read()
         f.close()
         if lines is not None:
             printl("Checking type of file...", self, "I")
             lines = lines.split(u"\n")
             if len(lines) > 1:
                 lines[1] = lines[1].strip()
                 if lines[1].startswith("<movie") or lines[1].startswith(
                         "<episodedetails>"):
                     printl("<- Found xbmc-style nfo...", self, "I")
                     self.isXbmcNfo = True
                     return self.parseNfoXbmc(lines)
                 else:
                     printl(
                         "<- Multiple lines, but no xbmc-style nfo - checking for IMDb-ID nfo...",
                         self, "I")
                     return self.getImdbIdFromNfo(lines)
             elif len(lines) == 1:
                 printl("<- Might be IMDb-ID nfo...", self, "I")
                 return self.getImdbIdFromNfo(lines)
             else:
                 printl("<-", self, "C")
                 return None
         return None
     except Exception, ex:
         printl("Exception (ef): " + str(ex), self, "E")
Exemplo n.º 3
0
def save():
	global blackList
	if blackList is None:
		self.load()
		
	fconf = Utf8.Utf8(config.plugins.pvmc.configfolderpath.value + "blacklist.conf", "w")
	for file in blackList:
		fconf.write(file + u"\n")
	fconf.close()
Exemplo n.º 4
0
 def getValerieInfo(self, path):
     try:
         f = Utf8.Utf8(path + u"/valerie.info", "r")
         lines = f.read()
         if lines is not None:
             lines = lines.split(u"\n")
             name = None
             if len(lines) >= 1:
                 name = lines[0]
         f.close()
     except Exception, ex:
         printl("Exception (ef): " + str(ex), self, "E")
Exemplo n.º 5
0
 def setValerieInfoLastAccessTime(self, path):
     try:
         if os.path.isfile(Utf8.utf8ToLatin(path + u"/valerie.info")):
             time = int(
                 os.path.getctime(Utf8.utf8ToLatin(path +
                                                   u"/valerie.info")))
             f = Utf8.Utf8(path + u"/.access", "w")
             time = f.write(str(time) + u"\n")
             f.close()
         elif os.path.isfile(Utf8.utf8ToLatin(path + u"/.access")):
             os.remove(Utf8.utf8ToLatin(path + u"/.access"))
     except Exception, ex:
         printl("Exception (ef): " + str(ex), self, "E")
Exemplo n.º 6
0
def load():
	global blackList
	printl("loading blackList")
	if os.path.exists(config.plugins.pvmc.configfolderpath.value + "blacklist.conf"):
		try:
			del blackList[:]
			fconf = Utf8.Utf8(config.plugins.pvmc.configfolderpath.value + "blacklist.conf", "r")
			blackList = fconf.read().split(u"\n")
			printl("blacklist loaded " + str(len(blackList))+ " entries", __name__, "I")
			fconf.close()
		except Exception, ex:
			printl("something went wrong reading blackList.conf", __name__, "E")
			blackList = []
Exemplo n.º 7
0
def checkCache(url):
	try:
		cacheFile = re.sub(r'\W', "", url).strip()
		cacheFileName = cacheDir + u"/" + cacheFile + u".cache"
		rtv = None
		if os.path.isfile(Utf8.utf8ToLatin(cacheFileName)):
			if os.path.getsize(Utf8.utf8ToLatin(cacheFileName)) == 0:
				os.remove(Utf8.utf8ToLatin(cacheFileName))
				return rtv
			f = Utf8.Utf8(cacheDir + u"/" + cacheFile + u".cache", "r")
			rtv = f.read()
			f.close()
	except Exception, ex:
		printl("Exception (ef): " + str(ex), __name__, "E")
		printl("\tURL: " + str(Utf8.utf8ToLatin(url)), __name__, "E")
Exemplo n.º 8
0
 def getValerieInfoLastAccessTime(self, path):
     time = 0
     try:
         if os.path.isfile(Utf8.utf8ToLatin(path + u"/.access")):
             f = Utf8.Utf8(path + u"/.access", "r")
             lines = f.read()
             if lines is not None:
                 lines = lines.split(u"\n")
                 if len(lines) >= 1:
                     try:
                         lines = lines[0].split(".")
                         time = int(lines[0])
                     except Exception, ex:
                         printl("Exception: " + str(ex), self)
                         printl(
                             "\t" +
                             str(Utf8.utf8ToLatin(path + u"/.access")),
                             self)
             f.close()
     except Exception, ex:
         printl("Exception (ef): " + str(ex), self, "E")
Exemplo n.º 9
0
 def getEnigma2RecordingName(self, name):
     try:
         e2info = None
         printl("Read from '" + name + u".meta" + "'", self, "I")
         f = Utf8.Utf8(name + u".meta", "r")
         lines = f.read()
         if lines is None:
             f.close()
             f = open(name + u".meta", "r")
             lines = f.read()
             lines = Utf8.stringToUtf8(lines)
         if lines is not None:
             lines = lines.split(u"\n")
             if len(lines) > 2:
                 printl(
                     "MovieName = '" + lines[1] + "' - EpisodeName = '" +
                     lines[2] + "'", self, "I")
                 e2info = self.Enimga2MetaInfo(lines[1], lines[2])
         f.close()
         return e2info
     except Exception, ex:
         printl("Exception (ef): " + str(ex), self, "E")
         return None