mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
Revert "feat(recommend): add semaphore to limit concurrent requests"
This reverts commit 33de1c3618.
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
from typing import Any, List, Dict
|
from typing import Any, List, Dict
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
@@ -43,12 +42,8 @@ def play_item(itemid: str, _: schemas.TokenPayload = Depends(verify_token)) -> s
|
|||||||
return schemas.Response(success=False, message="未找到播放地址")
|
return schemas.Response(success=False, message="未找到播放地址")
|
||||||
|
|
||||||
|
|
||||||
# 控制最大并发数
|
|
||||||
semaphore = asyncio.Semaphore(10)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/exists", summary="查询本地是否存在(数据库)", response_model=schemas.Response)
|
@router.get("/exists", summary="查询本地是否存在(数据库)", response_model=schemas.Response)
|
||||||
async def exists_local(title: str = None,
|
def exists_local(title: str = None,
|
||||||
year: int = None,
|
year: int = None,
|
||||||
mtype: str = None,
|
mtype: str = None,
|
||||||
tmdbid: int = None,
|
tmdbid: int = None,
|
||||||
@@ -58,23 +53,22 @@ async def exists_local(title: str = None,
|
|||||||
"""
|
"""
|
||||||
判断本地是否存在
|
判断本地是否存在
|
||||||
"""
|
"""
|
||||||
async with semaphore:
|
meta = MetaInfo(title)
|
||||||
meta = MetaInfo(title)
|
if not season:
|
||||||
if not season:
|
season = meta.begin_season
|
||||||
season = meta.begin_season
|
# 返回对象
|
||||||
# 返回对象
|
ret_info = {}
|
||||||
ret_info = {}
|
# 本地数据库是否存在
|
||||||
# 本地数据库是否存在
|
exist: MediaServerItem = MediaServerOper(db).exists(
|
||||||
exist: MediaServerItem = MediaServerOper(db).exists(
|
title=meta.name, year=year, mtype=mtype, tmdbid=tmdbid, season=season
|
||||||
title=meta.name, year=year, mtype=mtype, tmdbid=tmdbid, season=season
|
)
|
||||||
)
|
if exist:
|
||||||
if exist:
|
ret_info = {
|
||||||
ret_info = {
|
"id": exist.item_id
|
||||||
"id": exist.item_id
|
}
|
||||||
}
|
return schemas.Response(success=True if exist else False, data={
|
||||||
return schemas.Response(success=True if exist else False, data={
|
"item": ret_info
|
||||||
"item": ret_info
|
})
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@router.post("/exists_remote", summary="查询已存在的剧集信息(媒体服务器)", response_model=Dict[int, list])
|
@router.post("/exists_remote", summary="查询已存在的剧集信息(媒体服务器)", response_model=Dict[int, list])
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
from typing import List, Any
|
from typing import List, Any
|
||||||
|
|
||||||
import cn2an
|
import cn2an
|
||||||
@@ -147,12 +146,8 @@ def update_subscribe_status(
|
|||||||
return schemas.Response(success=True)
|
return schemas.Response(success=True)
|
||||||
|
|
||||||
|
|
||||||
# 控制最大并发数
|
|
||||||
semaphore = asyncio.Semaphore(10)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/media/{mediaid}", summary="查询订阅", response_model=schemas.Subscribe)
|
@router.get("/media/{mediaid}", summary="查询订阅", response_model=schemas.Subscribe)
|
||||||
async def subscribe_mediaid(
|
def subscribe_mediaid(
|
||||||
mediaid: str,
|
mediaid: str,
|
||||||
season: int = None,
|
season: int = None,
|
||||||
title: str = None,
|
title: str = None,
|
||||||
@@ -161,36 +156,35 @@ async def subscribe_mediaid(
|
|||||||
"""
|
"""
|
||||||
根据 TMDBID/豆瓣ID/BangumiId 查询订阅 tmdb:/douban:
|
根据 TMDBID/豆瓣ID/BangumiId 查询订阅 tmdb:/douban:
|
||||||
"""
|
"""
|
||||||
async with semaphore:
|
result = None
|
||||||
result = None
|
title_check = False
|
||||||
title_check = False
|
if mediaid.startswith("tmdb:"):
|
||||||
if mediaid.startswith("tmdb:"):
|
tmdbid = mediaid[5:]
|
||||||
tmdbid = mediaid[5:]
|
if not tmdbid or not str(tmdbid).isdigit():
|
||||||
if not tmdbid or not str(tmdbid).isdigit():
|
return Subscribe()
|
||||||
return Subscribe()
|
result = Subscribe.exists(db, tmdbid=int(tmdbid), season=season)
|
||||||
result = Subscribe.exists(db, tmdbid=int(tmdbid), season=season)
|
elif mediaid.startswith("douban:"):
|
||||||
elif mediaid.startswith("douban:"):
|
doubanid = mediaid[7:]
|
||||||
doubanid = mediaid[7:]
|
if not doubanid:
|
||||||
if not doubanid:
|
return Subscribe()
|
||||||
return Subscribe()
|
result = Subscribe.get_by_doubanid(db, doubanid)
|
||||||
result = Subscribe.get_by_doubanid(db, doubanid)
|
if not result and title:
|
||||||
if not result and title:
|
title_check = True
|
||||||
title_check = True
|
elif mediaid.startswith("bangumi:"):
|
||||||
elif mediaid.startswith("bangumi:"):
|
bangumiid = mediaid[8:]
|
||||||
bangumiid = mediaid[8:]
|
if not bangumiid or not str(bangumiid).isdigit():
|
||||||
if not bangumiid or not str(bangumiid).isdigit():
|
return Subscribe()
|
||||||
return Subscribe()
|
result = Subscribe.get_by_bangumiid(db, int(bangumiid))
|
||||||
result = Subscribe.get_by_bangumiid(db, int(bangumiid))
|
if not result and title:
|
||||||
if not result and title:
|
title_check = True
|
||||||
title_check = True
|
# 使用名称检查订阅
|
||||||
# 使用名称检查订阅
|
if title_check and title:
|
||||||
if title_check and title:
|
meta = MetaInfo(title)
|
||||||
meta = MetaInfo(title)
|
if season:
|
||||||
if season:
|
meta.begin_season = season
|
||||||
meta.begin_season = season
|
result = Subscribe.get_by_title(db, title=meta.name, season=meta.begin_season)
|
||||||
result = Subscribe.get_by_title(db, title=meta.name, season=meta.begin_season)
|
|
||||||
|
|
||||||
return result if result else Subscribe()
|
return result if result else Subscribe()
|
||||||
|
|
||||||
|
|
||||||
@router.get("/refresh", summary="刷新订阅", response_model=schemas.Response)
|
@router.get("/refresh", summary="刷新订阅", response_model=schemas.Response)
|
||||||
|
|||||||
Reference in New Issue
Block a user