mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
Merge pull request #2776 from InfinityPacer/dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional, Dict, Tuple, Generator, Any
|
from typing import List, Optional, Dict, Tuple, Generator, Any, Union
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
|
|
||||||
from cachetools import TTLCache, cached
|
from cachetools import TTLCache, cached
|
||||||
@@ -9,7 +9,6 @@ from plexapi.server import PlexServer
|
|||||||
from requests import Response, Session
|
from requests import Response, Session
|
||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
from app.core.config import settings
|
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas import MediaType
|
from app.schemas import MediaType
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
@@ -238,7 +237,7 @@ class Plex:
|
|||||||
if not self._plex:
|
if not self._plex:
|
||||||
return None, {}
|
return None, {}
|
||||||
if item_id:
|
if item_id:
|
||||||
videos = self._plex.fetchItem(int(item_id))
|
videos = self.__fetch_item(item_id)
|
||||||
else:
|
else:
|
||||||
# 兼容年份为空的场景
|
# 兼容年份为空的场景
|
||||||
kwargs = {"year": year} if year else {}
|
kwargs = {"year": year} if year else {}
|
||||||
@@ -274,7 +273,7 @@ class Plex:
|
|||||||
def get_remote_image_by_id(self, item_id: str, image_type: str, depth: int = 0) -> Optional[str]:
|
def get_remote_image_by_id(self, item_id: str, image_type: str, depth: int = 0) -> Optional[str]:
|
||||||
"""
|
"""
|
||||||
根据ItemId从Plex查询图片地址
|
根据ItemId从Plex查询图片地址
|
||||||
:param item_id: 在Emby中的ID
|
:param item_id: 在Plex中的ID
|
||||||
:param image_type: 图片的类型,Poster或者Backdrop等
|
:param image_type: 图片的类型,Poster或者Backdrop等
|
||||||
:param depth: 当前递归深度,默认为0
|
:param depth: 当前递归深度,默认为0
|
||||||
:return: 图片对应在TMDB中的URL
|
:return: 图片对应在TMDB中的URL
|
||||||
@@ -392,7 +391,7 @@ class Plex:
|
|||||||
if not self._plex:
|
if not self._plex:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
item = self._plex.fetchItem(int(itemid))
|
item = self.__fetch_item(itemid)
|
||||||
ids = self.__get_ids(item.guids)
|
ids = self.__get_ids(item.guids)
|
||||||
path = None
|
path = None
|
||||||
if item.locations:
|
if item.locations:
|
||||||
@@ -446,6 +445,15 @@ class Plex:
|
|||||||
|
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
def __fetch_item(self, item_id: Union[int, str]):
|
||||||
|
"""
|
||||||
|
根据给定的item_id获取媒体项
|
||||||
|
:param item_id: 媒体项的ID,可以是整数或字符串,如果是字符串且表示为数字,将会被转换为整数
|
||||||
|
"""
|
||||||
|
if isinstance(item_id, str) and item_id.isdigit():
|
||||||
|
item_id = int(item_id)
|
||||||
|
return self._plex.fetchItem(item_id)
|
||||||
|
|
||||||
def get_items(self, parent: str, start_index: int = 0, limit: int = 100) -> Generator:
|
def get_items(self, parent: str, start_index: int = 0, limit: int = 100) -> Generator:
|
||||||
"""
|
"""
|
||||||
获取媒体服务器所有媒体库列表
|
获取媒体服务器所有媒体库列表
|
||||||
|
|||||||
Reference in New Issue
Block a user