Skip to content

Commit df61c51

Browse files
authored
Merge pull request #90 from shinonomeow/shino_aio
fix dmhy rss link download error
2 parents 241afc8 + 7a133db commit df61c51

3 files changed

Lines changed: 28 additions & 22 deletions

File tree

backend/src/module/api/rss.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ async def get_rss():
3131
@router.post(
3232
path="/add", response_model=APIResponse, dependencies=[Depends(get_current_user)]
3333
)
34+
# 此为聚合用
3435
async def add_rss(rss: RSSItem):
3536
manager = RSSManager()
3637
res = await manager.add_rss(rss.url, rss.name, rss.aggregate, rss.parser)
38+
await RSSEngine().refresh_rss(rss)
3739
if res:
3840
result = ResponseModel(
3941
status=True,

backend/src/module/downloader/client/qbittorrent/qbittorrent.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,23 @@ async def add(self, torrent_url, save_path, category) -> str | None:
221221
logger.debug(
222222
f"[QbDownloader] Starting to get torrent content from {torrent_url}"
223223
)
224-
async with RequestContent() as req:
225-
logger.debug(f"[QbDownloader] Calling get_content for {torrent_url}")
226-
if torrent_file := await req.get_content(torrent_url):
227-
logger.debug(
228-
f"[QbDownloader] Got torrent content, getting hash for {torrent_url}"
229-
)
230-
torrent_hashes = await req.get_torrent_hash(torrent_url)
231-
# 优先使用v2 hash,如果没有则使用v1 hash
232-
torrent_link = torrent_hashes.get("v2", torrent_hashes.get("v1", ""))
233-
logger.debug(f"[QbDownloader] Got torrent hashes: {torrent_hashes}")
234-
logger.debug(f"[QbDownloader] Using hash: {torrent_link}")
235-
file = {"torrents": torrent_file}
236-
else:
237-
logger.warning(
238-
f"[QbDownloader] Failed to get torrent content from {torrent_url}"
239-
)
240-
logger.debug(
241-
"[QbDownloader] Finished getting torrent content, proceeding to add torrent"
242-
)
224+
if not torrent_url.startswith("magnet:"):
225+
async with RequestContent() as req:
226+
logger.debug(f"[QbDownloader] Calling get_content for {torrent_url}")
227+
if torrent_file := await req.get_content(torrent_url):
228+
logger.debug(
229+
f"[QbDownloader] Got torrent content, getting hash for {torrent_url}"
230+
)
231+
torrent_hashes = await req.get_torrent_hash(torrent_url)
232+
# 优先使用v2 hash,如果没有则使用v1 hash
233+
torrent_link = torrent_hashes.get("v2", torrent_hashes.get("v1", ""))
234+
logger.debug(f"[QbDownloader] Got torrent hashes: {torrent_hashes}")
235+
logger.debug(f"[QbDownloader] Using hash: {torrent_link}")
236+
file = {"torrents": torrent_file}
237+
else:
238+
logger.warning(
239+
f"[QbDownloader] Failed to get torrent content from {torrent_url}"
240+
)
243241
try:
244242
resp = await self._client.post(
245243
url=QB_API_URL["add"],

backend/src/module/rss/analyser.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,17 @@ async def test():
122122
end = time.time()
123123
return res
124124

125-
test_bangumi = Bangumi(official_title="败犬女主太多了!", season=1)
125+
test_bangumi = Bangumi(official_title="败犬女主太多了!", season=1,exclude_filter="720|\d+-\d|BIG5|繁日双语|先行版|繁體|繁体|Bilibili|繁日内嵌|简体内嵌|繁中",)
126126
test_torrent = Torrent(
127-
name="败犬女主太多了! S01E01",
127+
url = "1",
128+
name="[BangumiRefresher] Add torrent [MingY] 不良少女 / Bad Girl [01][1080p][简繁日内封](坏女孩 / 壞女孩)",
128129
homepage="https://mikanani.me/Home/Episode/33fbab8f53fe4bad12f07afa5abdb7c4afa5956c",
129130
)
131+
print("hello")
130132
rss_item = RSSItem(url="https://mikanani.me/RSS/Bangumi/100000", parser="mikan")
133+
ans = RSSAnalyser().filer_torrent(
134+
torrent=test_torrent, bangumi=test_bangumi
135+
) # Should return True
136+
print(ans)
131137

132-
res = asyncio.run(test())
138+
# res = asyncio.run(test())

0 commit comments

Comments
 (0)