diff --git a/backend/src/module/api/download.py b/backend/src/module/api/download.py index bfb5f194..8e4b48a2 100644 --- a/backend/src/module/api/download.py +++ b/backend/src/module/api/download.py @@ -1,7 +1,7 @@ from fastapi import APIRouter, Depends from module.manager import SeasonCollector -from module.models import Bangumi +from module.models import Bangumi, RSSItem from module.models.api import RssLink from module.rss import RSSAnalyser from module.security.api import get_current_user, UNAUTHORIZED @@ -11,10 +11,10 @@ analyser = RSSAnalyser() @router.post("/analysis") -async def analysis(link: RssLink, current_user=Depends(get_current_user)): +async def analysis(rss: RSSItem, current_user=Depends(get_current_user)): if not current_user: raise UNAUTHORIZED - data = analyser.link_to_data(link.rss_link) + data = analyser.link_to_data(rss) if data: return data else: diff --git a/backend/src/module/downloader/client/qb_downloader.py b/backend/src/module/downloader/client/qb_downloader.py index aae8d93f..fe6805f5 100644 --- a/backend/src/module/downloader/client/qb_downloader.py +++ b/backend/src/module/downloader/client/qb_downloader.py @@ -82,9 +82,10 @@ class QbDownloader: status_filter=status_filter, category=category, tag=tag ) - def torrents_add(self, torrent_files, save_path, category): + def add_torrents(self, torrent_urls, torrent_files, save_path, category): resp = self._client.torrents_add( is_paused=False, + urls=torrent_urls, torrent_files=torrent_files, save_path=save_path, category=category, diff --git a/backend/src/module/downloader/download_client.py b/backend/src/module/downloader/download_client.py index 5585cb06..0545bf6e 100644 --- a/backend/src/module/downloader/download_client.py +++ b/backend/src/module/downloader/download_client.py @@ -119,10 +119,21 @@ class DownloadClient(TorrentPath): bangumi.save_path = self._gen_save_path(bangumi) with RequestContent() as req: if isinstance(torrent, list): - torrent_file = [req.get_content(t.url) for t in torrent] + if "magnet" in torrent[0].url: + torrent_url = [t.url for t in torrent] + torrent_file = None + else: + torrent_file = [req.get_content(t.url) for t in torrent] + torrent_url = None else: - torrent_file = req.get_content(torrent.url) - if self.client.torrents_add( + if "magnet" in torrent.url: + torrent_url = torrent.url + torrent_file = None + else: + torrent_file = req.get_content(torrent.url) + torrent_url = None + if self.client.add_torrents( + torrent_urls=torrent_url, torrent_files=torrent_file, save_path=bangumi.save_path, category="Bangumi", diff --git a/backend/src/module/rss/analyser.py b/backend/src/module/rss/analyser.py index a17047e8..ca031ac1 100644 --- a/backend/src/module/rss/analyser.py +++ b/backend/src/module/rss/analyser.py @@ -55,6 +55,7 @@ class RSSAnalyser(TitleParser): bangumi = self.raw_parser(raw=torrent.name) if bangumi: self.official_title_parser(bangumi=bangumi, rss=rss, torrent=torrent) + bangumi.rss_link = rss.url return bangumi def rss_to_data(