fix: fix magent link problem

This commit is contained in:
EstrellaXD
2023-08-12 18:55:38 +08:00
parent 03a4077182
commit 6c43a2d694
4 changed files with 20 additions and 7 deletions

View File

@@ -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:

View File

@@ -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,

View File

@@ -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",

View File

@@ -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(