Skip to content

Commit

Permalink
Merge pull request #2410 from jxxghp/main
Browse files Browse the repository at this point in the history
fix bugs
  • Loading branch information
jxxghp authored Jun 24, 2024
2 parents 5c3cd8c + b2efac0 commit ae36f51
Show file tree
Hide file tree
Showing 34 changed files with 875 additions and 60 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: MoviePilot Builder
on:
workflow_dispatch:
push:
branches:
- main
paths:
- version.py

jobs:
Docker-build:
Expand Down
11 changes: 6 additions & 5 deletions app/api/endpoints/aliyun.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def list_aliyun(fileitem: schemas.FileItem,
if sort == "time":
sort = "updated_at"
if fileitem.type == "file":
fileitem = AliyunHelper().detail(fileitem.fileid, path=path)
fileitem = AliyunHelper().detail(drive_id=fileitem.drive_id, file_id=fileitem.fileid, path=path)
if fileitem:
return [fileitem]
return []
Expand Down Expand Up @@ -115,13 +115,14 @@ def delete_aliyun(fileitem: schemas.FileItem,

@router.get("/download", summary="下载文件(阿里云盘)")
def download_aliyun(fileid: str,
drive_id: str = None,
_: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
"""
下载文件或目录
"""
if not fileid:
return schemas.Response(success=False)
url = AliyunHelper().download(fileid)
url = AliyunHelper().download(drive_id=drive_id, file_id=fileid)
if url:
# 重定向
return Response(status_code=302, headers={"Location": url})
Expand All @@ -138,7 +139,7 @@ def rename_aliyun(fileitem: schemas.FileItem,
"""
if not fileitem.fileid or not new_name:
return schemas.Response(success=False)
result = AliyunHelper().rename(fileitem.fileid, new_name)
result = AliyunHelper().rename(drive_id=fileitem.drive_id, file_id=fileitem.fileid, name=new_name)
if result:
if recursive:
transferchain = TransferChain()
Expand Down Expand Up @@ -184,13 +185,13 @@ def rename_aliyun(fileitem: schemas.FileItem,


@router.get("/image", summary="读取图片(阿里云盘)", response_model=schemas.Response)
def image_aliyun(fileid: str, _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
def image_aliyun(fileid: str, drive_id: str = None, _: schemas.TokenPayload = Depends(verify_uri_token)) -> Any:
"""
读取图片
"""
if not fileid:
return schemas.Response(success=False)
url = AliyunHelper().download(fileid)
url = AliyunHelper().download(drive_id=drive_id, file_id=fileid)
if url:
# 重定向
return Response(status_code=302, headers={"Location": url})
Expand Down
2 changes: 1 addition & 1 deletion app/api/endpoints/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def scrape(fileitem: schemas.FileItem,
# 识别媒体信息
scrape_path = Path(fileitem.path)
meta = MetaInfoPath(scrape_path)
mediainfo = chain.recognize_media(meta)
mediainfo = chain.recognize_by_meta(meta)
if not media_info:
return schemas.Response(success=False, message="刮削失败,无法识别媒体信息")
if storage == "local":
Expand Down
2 changes: 1 addition & 1 deletion app/chain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def recognize_media(self, meta: MetaBase = None,
bangumiid: int = None,
cache: bool = True) -> Optional[MediaInfo]:
"""
识别媒体信息
识别媒体信息,不含Fanart图片
:param meta: 识别的元数据
:param mtype: 识别的媒体类型,与tmdbid配套
:param tmdbid: tmdbid
Expand Down
7 changes: 7 additions & 0 deletions app/chain/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ def download_single(self, context: Context, torrent_file: Path = None,
_media = context.media_info
_meta = context.meta_info

# 补充完整的media数据
if not _media.genre_ids:
new_media = self.recognize_media(mtype=_media.type, tmdbid=_media.tmdb_id,
doubanid=_media.douban_id, bangumiid=_media.bangumi_id)
if new_media:
_media = new_media

# 实际下载的集数
download_episodes = StringUtils.format_ep(list(episodes)) if episodes else None
_folder_name = ""
Expand Down
7 changes: 6 additions & 1 deletion app/chain/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def get_doubaninfo_by_bangumiid(self, bangumiid: int) -> Optional[dict]:
return None

def manual_scrape(self, storage: str, fileitem: schemas.FileItem,
meta: MetaBase, mediainfo: MediaInfo, init_folder: bool = True):
meta: MetaBase = None, mediainfo: MediaInfo = None, init_folder: bool = True):
"""
手动刮削媒体信息
"""
Expand Down Expand Up @@ -399,7 +399,12 @@ def __save_image(_url: str) -> Optional[bytes]:
if fileitem.type == "file" \
and (not filepath.suffix or filepath.suffix.lower() not in settings.RMT_MEDIAEXT):
return
if not meta:
meta = MetaInfoPath(filepath)
if not mediainfo:
mediainfo = self.recognize_by_meta(meta)
if not mediainfo:
logger.warn(f"{filepath} 无法识别文件媒体信息!")
return
logger.info(f"开始刮削:{filepath} ...")
if mediainfo.type == MediaType.MOVIE:
Expand Down
3 changes: 3 additions & 0 deletions app/chain/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,9 @@ def __get_subscribe_no_exits(subscribe_name: str,
total = no_exist_season.total_episode
# 原开始集数
start = no_exist_season.start_episode
# 整季缺失
if not episode_list:
episode_list = list(range(start, total + 1))
# 更新剧集列表
episodes = list(set(episode_list).difference(set(downloaded_episodes)))
# 更新集合
Expand Down
Loading

0 comments on commit ae36f51

Please sign in to comment.