def buildItem(server, elem, initpath, bytag=False): libtype = elem.tag if bytag else elem.attrib.get('type') if libtype == 'photo' and elem.tag == 'Directory': libtype = 'photoalbum' if libtype in LIBRARY_TYPES: cls = LIBRARY_TYPES[libtype] return cls(server, elem, initpath) raise UnknownType('Unknown library type: %s' % libtype)
def build_item(server, elem, initpath): VIDEOCLS = { Movie.TYPE: Movie, Show.TYPE: Show, Season.TYPE: Season, Episode.TYPE: Episode } vtype = elem.attrib.get('type') if vtype in VIDEOCLS: cls = VIDEOCLS[vtype] return cls(server, elem, initpath) raise UnknownType('Unknown video type: %s' % vtype)
def _buildItem(self, elem, cls=None, initpath=None): """ Factory function to build objects based on registered PLEXOBJECTS. """ # cls is specified, build the object and return initpath = initpath or self._initpath if cls is not None: return cls(self._server, elem, initpath) # cls is not specified, try looking it up in PLEXOBJECTS etype = elem.attrib.get('type', elem.attrib.get('streamType')) ehash = '%s.%s' % (elem.tag, etype) if etype else elem.tag ecls = utils.PLEXOBJECTS.get(ehash, utils.PLEXOBJECTS.get(elem.tag)) # log.debug('Building %s as %s', elem.tag, ecls.__name__) if ecls is not None: return ecls(self._server, elem, initpath) raise UnknownType("Unknown library type <%s type='%s'../>" % (elem.tag, etype))
def buildItem(server, elem, initpath, bytag=False): """Build classes used by the plexapi. Args: server (Plexserver): Your connected to. elem (xml.etree.ElementTree.Element): xml from PMS initpath (str): Relative path bytag (bool, optional): Description # figure out what this do Raises: UnknownType: Unknown library type libtype """ libtype = elem.tag if bytag else elem.attrib.get('type') if libtype == 'photo' and elem.tag == 'Directory': libtype = 'photoalbum' if libtype in LIBRARY_TYPES: cls = LIBRARY_TYPES[libtype] return cls(server, elem, initpath) raise UnknownType('Unknown library type: %s' % libtype)