예제 #1
0
 def get_chapters(self) -> List[dict]:
     items = self.html.from_content(self.content, '.chapters-link td > a')
     result = []
     for idx, item in enumerate(items):  # type: int, ElementBase
         chapter = Chapter(self, idx)
         chapter.name = fs.remove_query(fs.basename(item))
         result.append(chapter)
     return result
예제 #2
0
 def _parse_data(self, data: Union[tuple, ElementBase]):
     if not isinstance(data, (tuple, ElementBase)):
         InvalidChapter(data)
     if isinstance(data, ElementBase):
         self._url = self._http.normalize_uri(data.get('src'))
         name = fs.basename(self._url)
         name = fs.remove_query(name)
     else:
         # ('absolute_url', 'relative_file_name')
         self._url = data[0]
         name = data[1]
     self._name = self._normalize_name(name)
예제 #3
0
 def _parse_data(self, data):
     if not isinstance(data, (dict, tuple, Element)):
         InvalidChapter(data)
     if isinstance(data, dict):
         self._url = data['url']
         name = data['name']
     elif isinstance(data, Element):
         self._url = self.provider.http.normalize_uri(data.get('src'))
         name = fs.basename(self._url)
         name = fs.remove_query(name)
     else:
         # ('absolute_url', 'archive_name/folder_name')
         self._url = data[0]
         name = data[1]
     self._name = self._normalize_name(name)
예제 #4
0
 def get_chapter_name(self, chapter) -> str:
     name = fs.basename(chapter.get('url'))
     return fs.remove_query(name)