def __init__(self, service): self.__name = service and service.getName() or "" self.path = path = service and service.getPath() self.isfile = os.path.isfile(path) self.isdir = os.path.isdir(path) ext = path and os.path.splitext(path)[1].lower() meta = path and MetaList(path) eit = path and EitList(path) # Information which we need later self.__cutlist = path and CutList(path) or [] self.__size = self.isfile and os.stat(path).st_size or self.isdir and ( config.EMC.directories_info.value or config.EMC.directories_size_skin.value ) and self.getFolderSize(path) or None self.__mtime = self.isfile and hasattr(service, "date") and mktime( service.date.timetuple()) or None self.__reference = service or "" self.__rec_ref_str = meta and meta.getMetaServiceReference() or "" self.__shortdescription = meta and meta.getMetaDescription( ) or eit and eit.getEitShortDescription() or "" self.__tags = meta and meta.getMetaTags() or "" self.__eventname = meta and meta.getMetaName( ) or eit and eit.getEitName() or self.__name self.__extendeddescription = eit and eit.getEitDescription() or "" #No Description in *.eit file or no *.eit file exists #Try reading description from *.txt file if not self.__extendeddescription: exts = [".txt"] txtpath = getInfoFile(path, exts)[1] # read the playlist-entrys to show the list as overview if ext == ".e2pls": from EMCPlayList import readPlaylist plistdesc = "" plist = readPlaylist(service.getPath()) for x in plist: plistdesc += x self.__extendeddescription = plistdesc else: if os.path.exists(txtpath): txtdescarr = open(txtpath).readlines() txtdesc = "" for line in txtdescarr: txtdesc += line self.__extendeddescription = txtdesc elif config.EMC.show_path_extdescr.value: if config.EMC.movie_real_path.value: desc = os.path.realpath(path) else: desc = path # Very bad but there can be both encodings # E2 recordings are always in utf8 # User files can be in cp1252 #TODO Is there no other way? try: desc.decode('utf-8') except UnicodeDecodeError: try: desc = path.decode("cp1252").encode("utf-8") except UnicodeDecodeError: desc = path.decode("iso-8859-1").encode("utf-8") self.__extendeddescription = desc else: self.__extendeddescription = "" self.__id = 0 service.cueSheet = self.cueSheet
def __init__(self, service): self.__name = service and service.getName() or "" self.path = path = service and service.getPath() #self.isLink = os.path.islink(path) self.isfile = os.path.isfile(path) isreal = os.path.isdir(path) ext = path and os.path.splitext(path)[1].lower() self.isdir = isreal and hasattr(service, "ext") and ext == "DIR" or False #TODO dynamic or not #if config.EMC.movie_metaload.value: meta = path and MetaList(path) #else: # meta = None #TODO dynamic or not #if config.EMC.movie_eitload.value: eit = path and EitList(path) #else: # eit = None # Information which we need later self.__cutlist = path and CutList(path) or [] #TODO dynamic or not self.__size = self.isfile and os.stat(path).st_size \ or self.isdir and config.EMC.directories_info.value and self.getFolderSize(path) \ or None #TODO or isdvd self.__mtime = self.isfile and hasattr(service, "date") and mktime( service.date.timetuple( )) or None #long(os.stat(path).st_mtime) or 0 #TODO show same time as list #TODO or isdir but show only start date self.__reference = service or "" self.__rec_ref_str = meta and meta.getMetaServiceReference() or "" #TODO dynamic or not self.__shortdescription = meta and meta.getMetaDescription() \ or eit and eit.getEitShortDescription() \ or self.__name self.__tags = meta and meta.getMetaTags() or "" self.__eventname = meta and meta.getMetaName() \ or eit and eit.getEitName() \ or self.__name #TODO dynamic or not # #self.__extendeddescription = meta and meta.getMetaDescription() \ # or eit and eit.getEitDescription() \ # or "" ## meta file has no extendeddescrition # self.__extendeddescription = eit and eit.getEitDescription() \ # or meta and meta.getMetaDescription() \ # or "" #Show txt-Information in ExtendedDescription if meta but no eit self.__extendeddescription = eit and eit.getEitDescription() \ or "" #No Description in *.eit file or no *.eit file exists #Try reading description from *.txt file if not self.__extendeddescription: exts = [".txt"] txtpath = getInfoFile(path, exts)[1] if os.path.exists(txtpath): txtdescarr = open(txtpath).readlines() txtdesc = "" for line in txtdescarr: txtdesc += line self.__extendeddescription = txtdesc elif config.EMC.show_path_extdescr.value: if config.EMC.movie_real_path.value: desc = os.path.realpath(path) else: desc = path # Very bad but there can be both encodings # E2 recordings are always in utf8 # User files can be in cp1252 #TODO Is there no other way? try: desc.decode('utf-8') except UnicodeDecodeError: try: desc = path.decode("cp1252").encode("utf-8") except UnicodeDecodeError: desc = path.decode("iso-8859-1").encode("utf-8") self.__extendeddescription = desc else: # self.__extendeddescription = "No eit or txt file found" self.__extendeddescription = "" self.__id = 0 #TODO move upto ServiceInfo service.cueSheet = self.cueSheet
def getMetaInfos(self, path): eventtitle = "" meta = MetaList(path) if meta: eventtitle = meta.getMetaTitle() return eventtitle