mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-16 14:03:44 +08:00
fix: fix magent link problem
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user