From fc3875772322ddcb94e2cfadc60afa54e32dcbea Mon Sep 17 00:00:00 2001 From: Estrella Pan <33726646+EstrellaXD@users.noreply.github.com> Date: Sun, 8 Oct 2023 19:55:17 +0800 Subject: [PATCH] Update mikan.py --- backend/src/module/network/site/mikan.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/src/module/network/site/mikan.py b/backend/src/module/network/site/mikan.py index 72b7be9c..f581fdd2 100644 --- a/backend/src/module/network/site/mikan.py +++ b/backend/src/module/network/site/mikan.py @@ -2,16 +2,15 @@ def rss_parser(soup): torrent_titles = [] torrent_urls = [] torrent_homepage = [] - if not len(soup.findall("./channel/item/enclosure")): - for item in soup.findall("./channel/item"): - torrent_titles.append(item.find("title").text) - torrent_urls.append(item.find("link").text) - torrent_homepage.append(item.find("guid").text) - else: - for item in soup.findall("./channel/item"): - torrent_titles.append(item.find("title").text) - torrent_urls.append(item.find("enclosure").attrib["url"]) + for item in soup.findall("./channel/item"): + torrent_titles.append(item.find("title").text) + enclosure = item.find("enclosure") + if enclosure is not None: torrent_homepage.append(item.find("link").text) + torrent_urls.append(enclosure.attrib.get("url")) + else: + torrent_urls.append(item.find("link").text) + torrent_homepage.append("") return torrent_titles, torrent_urls, torrent_homepage