Example #1
0
    def _get_name_from_xml(self, aid, onlyMain=True):
        if not self.allAnimeXML:
            self.allAnimeXML = aniDBfileInfo.read_anidb_xml(self.anidbMapPath)

        for anime in self.allAnimeXML.findall("anime"):
            if int(anime.get("aid", False)) == aid:
                for title in anime.getiterator():
                    currentLang = title.get("{http://www.w3.org/XML/1998/namespace}lang", False)
                    currentType = title.get("type", False)
                    if (currentLang == "en" and not onlyMain) or currentType == "main":
                        return title.text
        return ""
Example #2
0
    def _get_aid_from_xml(self, name):
        if not self.allAnimeXML:
            self.allAnimeXML = aniDBfileInfo.read_anidb_xml(self.anidbMapPath)

        regex = re.compile('( \(\d{4}\))|[%s]' % re.escape(string.punctuation)) # remove any punctuation and e.g. ' (2011)'
        #regex = re.compile('[%s]'  % re.escape(string.punctuation)) # remove any punctuation and e.g. ' (2011)'
        name = regex.sub('', name.lower())
        lastAid = 0
        for element in self.allAnimeXML.getiterator():
            if element.get("aid", False):
                lastAid = int(element.get("aid"))
            if element.text:
                testname = regex.sub('', element.text.lower())

                if testname == name:
                    return lastAid
        return 0