예제 #1
0
 def fill_from_xml(self, xml):  # pylint: disable=too-many-branches
     if xml.find('titles') is not None:
         self.titles = [Title(self, n) for n in xml.find('titles')]
     else:
         self.titles = [Title(self, n) for n in xml.findall('title')]
         # return # returning from here will result in not loading attribute information for anime lists like hot_animes
     self.synonyms = [t for t in self.titles if t.type == 'synonym']
     if xml.find('episodes') is not None:
         self.all_episodes = sorted([Episode(self, n) for n in xml.find('episodes')])
         self.episodes = {e.number: e for e in self.all_episodes if e.type == 1}
     if xml.find('picture') is not None:
         self.picture = Picture(self, xml.find('picture'))
     if xml.find('ratings') is not None:
         if xml.find('ratings').find('permanent') is not None:
             self.rating_permanent = xml.find('ratings').find('permanent').text
             self.count_permanent = xml.find('ratings').find('permanent').get('count', '0')
         if xml.find('ratings').find('temporary') is not None:
             self.rating_temporary = xml.find('ratings').find('temporary').text
             self.count_temporary = xml.find('ratings').find('temporary').get('count', '0')
         if xml.find('ratings').find('review') is not None:
             self.rating_review = xml.find('ratings').find('review').text
     if xml.find('categories') is not None:
         self.categories = [Category(self, c) for c in xml.find('categories')]
     if xml.find('tags') is not None:
         self.tags = sorted([Tag(self, t) for t in xml.find('tags') if t.text.strip()])
     if xml.find('startdate') is not None:
         self.start_date = date_to_date(xml.find('startdate').text)
     if xml.find('enddate') is not None:
         self.end_date = date_to_date(xml.find('enddate').text)
     if xml.find('description') is not None:
         self.description = xml.find('description').text
예제 #2
0
 def fill_from_xml(self, xml):  # pylint: disable=too-many-branches
     if xml.find('titles') is not None:
         self.titles = [Title(self, n) for n in xml.find('titles')]
     else:
         self.titles = [Title(self, n) for n in xml.findall('title')]
         # return # returning from here will result in not loading attribute information for anime lists like hot_animes
     self.synonyms = [t for t in self.titles if t.type == 'synonym']
     if xml.find('episodes') is not None:
         self.all_episodes = sorted(
             [Episode(self, n) for n in xml.find('episodes')])
         self.episodes = {
             e.number: e
             for e in self.all_episodes if e.type == 1
         }
     if xml.find('picture') is not None:
         self.picture = Picture(self, xml.find('picture'))
     if xml.find('ratings') is not None:
         if xml.find('ratings').find('permanent') is not None:
             self.rating_permanent = xml.find('ratings').find(
                 'permanent').text
             self.count_permanent = xml.find('ratings').find(
                 'permanent').get('count', '0')
         if xml.find('ratings').find('temporary') is not None:
             self.rating_temporary = xml.find('ratings').find(
                 'temporary').text
             self.count_temporary = xml.find('ratings').find(
                 'temporary').get('count', '0')
         if xml.find('ratings').find('review') is not None:
             self.rating_review = xml.find('ratings').find('review').text
     if xml.find('categories') is not None:
         self.categories = [
             Category(self, c) for c in xml.find('categories')
         ]
     if xml.find('tags') is not None:
         self.tags = sorted(
             [Tag(self, t) for t in xml.find('tags') if t.text.strip()])
     if xml.find('startdate') is not None:
         try:
             self.start_date = date_to_date(xml.find('startdate').text)
         except TypeError:
             self.start_date = None
     if xml.find('enddate') is not None:
         try:
             self.end_date = date_to_date(xml.find('enddate').text)
         except TypeError:
             self.end_data = None
     if xml.find('description') is not None:
         self.description = xml.find('description').text
예제 #3
0
    def __init__(self, anime, xml_node):
        super(Tag, self).__init__(anime, xml_node)
        self._attributes('id', 'update', 'weight')
        if self.update:
            self.update = date_to_date(self.update)

        self._booleans('spoiler', 'localspoiler', 'globalspoiler', 'verified')
        self._texts('name', 'description')
        self.count = int(self.weight) if self.weight else 0
        """The importance of this tag."""
예제 #4
0
    def __init__(self, anime, xml_node):
        super(Tag, self).__init__(anime, xml_node)
        self._attributes('id', 'update', 'weight')
        if self.update:
            self.update = date_to_date(self.update)

        self._booleans('spoiler', 'localspoiler', 'globalspoiler', 'verified')
        self._texts('name', 'description')
        self.count = int(self.weight) if self.weight else 0
        """The importance of this tag."""
예제 #5
0
    def __init__(self, anime, xml_node):
        super(Episode, self).__init__(anime, xml_node)
        self._attributes('id')
        self._texts('airdate', 'length', 'epno')
        self.airdate = date_to_date(self.airdate)

        self.titles = [Title(self, n) for n in self._xml.findall('title')]
        self.type = int(self._xml.find('epno').attrib['type'])
        self.number = self.epno or 0
        if self.type == 1:
            self.number = int(self.number)
예제 #6
0
    def __init__(self, anime, xml_node):
        super(Episode, self).__init__(anime, xml_node)
        self._attributes('id')
        self._texts('airdate', 'length', 'epno')
        self.airdate = date_to_date(self.airdate)

        self.titles = [Title(self, n) for n in self._xml.findall('title')]
        self.type = int(self._xml.find('epno').attrib['type'])
        self.number = self.epno or 0
        if self.type == 1:
            self.number = int(self.number)