def __init__(self, fxd, node): fxd_file = fxd.filename item.Item.__init__(self, fxd.getattr(None, "parent", None)) self.items = [] self.name = fxd.getattr(node, "title", "no title") self.type = fxd.getattr(node, "type", "") self.fxd_file = fxd_file self.image = fxd.childcontent(node, "cover-img") if self.image: self.image = vfs.join(vfs.dirname(fxd_file), self.image) parent_items = fxd.getattr(None, "items", []) display_type = fxd.getattr(None, "display_type", None) # set variables new for the subtitems fxd.setattr(None, "parent", self) fxd.setattr(None, "items", self.items) callbacks = plugin.get_callbacks("fxditem") for child in node.children: for types, tag, handler in callbacks: if (not display_type or not types or display_type in types) and child.name == tag: handler(fxd, child) break fxd.parse_info(fxd.get_children(node, "info", 1), self) # restore settings fxd.setattr(None, "parent", self.parent) fxd.setattr(None, "items", parent_items) self.display_type = display_type
def parse(self, parent, fxd_files, duplicate_check=[], display_type=None): """ return a list of items that belong to a fxd files """ if not display_type and hasattr(parent, 'display_type'): display_type = parent.display_type if display_type == 'tv': display_type = 'video' callbacks = plugin.get_callbacks('fxditem') items = [] for fxd_file in fxd_files: try: # create a basic fxd parser parser = util.fxdparser.FXD(fxd_file) # create items attr for return values parser.setattr(None, 'items', []) parser.setattr(None, 'parent', parent) parser.setattr(None, 'filename', fxd_file) parser.setattr(None, 'duplicate_check', duplicate_check) parser.setattr(None, 'display_type', display_type) for types, tag, handler in callbacks: if not display_type or not types or display_type in types: parser.set_handler(tag, handler) # start the parsing parser.parse() # return the items items += parser.getattr(None, 'items') except: print "fxd file %s corrupt" % fxd_file traceback.print_exc() return items
def parse(self, parent, fxd_files, duplicate_check=[], display_type=None): """ return a list of items that belong to a fxd files """ if not display_type and hasattr(parent, "display_type"): display_type = parent.display_type if display_type == "tv": display_type = "video" callbacks = plugin.get_callbacks("fxditem") items = [] for fxd_file in fxd_files: try: # create a basic fxd parser parser = util.fxdparser.FXD(fxd_file) # create items attr for return values parser.setattr(None, "items", []) parser.setattr(None, "parent", parent) parser.setattr(None, "filename", fxd_file) parser.setattr(None, "duplicate_check", duplicate_check) parser.setattr(None, "display_type", display_type) for types, tag, handler in callbacks: if not display_type or not types or display_type in types: parser.set_handler(tag, handler) # start the parsing parser.parse() # return the items items += parser.getattr(None, "items") except: logger.info("fxd file %r corrupt", fxd_file) traceback.print_exc() return items
def __init__(self, fxd, node): fxd_file = fxd.filename item.Item.__init__(self, fxd.getattr(None, 'parent', None)) self.items = [] self.name = fxd.getattr(node, 'title', 'no title') self.type = fxd.getattr(node, 'type', '') self.fxd_file = fxd_file self.image = fxd.childcontent(node, 'cover-img') if self.image: self.image = vfs.join(vfs.dirname(fxd_file), self.image) parent_items = fxd.getattr(None, 'items', []) display_type = fxd.getattr(None, 'display_type', None) # set variables new for the subtitems fxd.setattr(None, 'parent', self) fxd.setattr(None, 'items', self.items) callbacks = plugin.get_callbacks('fxditem') for child in node.children: for types, tag, handler in callbacks: if (not display_type or not types or display_type in types) and \ child.name == tag: handler(fxd, child) break fxd.parse_info(fxd.get_children(node, 'info', 1), self) # restore settings fxd.setattr(None, 'parent', self.parent) fxd.setattr(None, 'items', parent_items) self.display_type = display_type