Skip to content

Commit dfd7352

Browse files
authored
rebuild get_links_from_xml()
1 parent 9e53335 commit dfd7352

File tree

1 file changed

+28
-28
lines changed
  • kubespider/source_provider/ani_source_provider

1 file changed

+28
-28
lines changed

kubespider/source_provider/ani_source_provider/provider.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -158,37 +158,37 @@ def get_links(self, event: Event) -> list[Resource]:
158158

159159
def get_links_from_xml(self, tmp_xml, blacklist) -> list[Resource]:
160160
try:
161-
xml_parse = ET.parse(tmp_xml)
162-
items = xml_parse.findall('.//item')
163161
ret = []
164-
for i in items:
165-
xml_title = i.find('./title').text
162+
for item in ET.parse(tmp_xml).findall('.//item'):
163+
xml_title = item.find('./title').text
166164
item_title, item_episode = self.get_anime_info(xml_title)
167-
season, season_keyword = self.get_season(xml_title)
168-
if item_title is not None:
169-
logging.info('Found Anime "%s" Season %s Episode %s', item_title, season, item_episode)
170-
# Pass blacklist Animes
171-
if self.check_blacklist(xml_title, blacklist):
172-
continue
173-
final_url = i.find('./guid').text
174-
if 'resources.ani.rip' in final_url:
175-
final_url = final_url.replace('resources.ani.rip', 'cloud.ani-download.workers.dev')
176-
res = Resource(
177-
url=final_url,
178-
path=self.save_path + (f'/{item_title}' if self.classification_on_directory else ''),
179-
file_type=types.FILE_TYPE_VIDEO_TV,
180-
link_type=self.get_link_type(),
181-
)
182-
if self.api_type == 'torrent':
183-
if self.use_sub_category:
184-
sub_category = self.get_subcategory(item_title, season, season_keyword)
185-
logging.info("Using subcategory: %s", sub_category)
186-
res.put_extra_params({'sub_category': sub_category})
187-
elif season > 1:
188-
res.put_extra_params({'file_name': self.rename_season(xml_title, season, season_keyword, item_episode)})
189-
ret.append(res)
190-
else:
165+
166+
if item_title is None or self.check_blacklist(xml_title, blacklist):
191167
continue
168+
169+
season, season_keyword = self.get_season(xml_title)
170+
logging.info('Found Anime "%s" Season %s Episode %s', item_title, season, item_episode)
171+
172+
final_url = item.find('./guid').text
173+
if 'resources.ani.rip' in final_url:
174+
final_url = final_url.replace('resources.ani.rip', 'cloud.ani-download.workers.dev')
175+
176+
res = Resource(
177+
url=final_url,
178+
path=self.save_path + (f'/{item_title}' if self.classification_on_directory else ''),
179+
file_type=types.FILE_TYPE_VIDEO_TV,
180+
link_type=self.get_link_type(),
181+
)
182+
183+
if self.api_type == 'torrent' and self.use_sub_category:
184+
sub_category = self.get_subcategory(item_title, season, season_keyword)
185+
logging.info("Using subcategory: %s", sub_category)
186+
res.put_extra_params({'sub_category': sub_category})
187+
elif season > 1:
188+
res.put_extra_params({'file_name': self.rename_season(xml_title, season, season_keyword, item_episode)})
189+
190+
ret.append(res)
191+
192192
return ret
193193
except Exception as err:
194194
print(traceback.format_exc())

0 commit comments

Comments
 (0)