mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 00:46:57 +08:00
fix some warnings
This commit is contained in:
@@ -73,7 +73,7 @@ class TrimeMediaModule(_ModuleBase, _MediaServerBase[TrimeMedia]):
|
|||||||
for name, server in self.get_instances().items():
|
for name, server in self.get_instances().items():
|
||||||
if not server.is_configured():
|
if not server.is_configured():
|
||||||
return False, f"飞牛影视配置不完整:{name}"
|
return False, f"飞牛影视配置不完整:{name}"
|
||||||
if server.is_inactive() and server.reconnect() != True:
|
if server.is_inactive() and not server.reconnect():
|
||||||
return False, f"无法连接飞牛影视:{name}"
|
return False, f"无法连接飞牛影视:{name}"
|
||||||
return True, ""
|
return True, ""
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import random
|
|||||||
import time
|
import time
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Optional, Union, List
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
@@ -19,27 +19,27 @@ class User:
|
|||||||
|
|
||||||
|
|
||||||
class Category(Enum):
|
class Category(Enum):
|
||||||
Movie = "Movie"
|
MOVIE = "Movie"
|
||||||
TV = "TV"
|
TV = "TV"
|
||||||
Mix = "Mix"
|
MIX = "Mix"
|
||||||
Others = "Others"
|
OTHERS = "Others"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _missing_(cls, value):
|
def _missing_(cls, value):
|
||||||
return cls.Others
|
return cls.OTHERS
|
||||||
|
|
||||||
|
|
||||||
class Type(Enum):
|
class Type(Enum):
|
||||||
Movie = "Movie"
|
MOVIE = "Movie"
|
||||||
TV = "TV"
|
TV = "TV"
|
||||||
Season = "Season"
|
SEASON = "Season"
|
||||||
Episode = "Episode"
|
EPISODE = "Episode"
|
||||||
Video = "Video"
|
VIDEO = "Video"
|
||||||
Directory = "Directory"
|
DIRECTORY = "Directory"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _missing_(cls, value):
|
def _missing_(cls, value):
|
||||||
return cls.Video
|
return cls.VIDEO
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -274,7 +274,7 @@ class Api:
|
|||||||
def item_list(
|
def item_list(
|
||||||
self,
|
self,
|
||||||
guid: Optional[str] = None,
|
guid: Optional[str] = None,
|
||||||
type=None,
|
types=None,
|
||||||
exclude_grouped_video=True,
|
exclude_grouped_video=True,
|
||||||
page=1,
|
page=1,
|
||||||
page_size=22,
|
page_size=22,
|
||||||
@@ -284,10 +284,10 @@ class Api:
|
|||||||
"""
|
"""
|
||||||
媒体列表
|
媒体列表
|
||||||
"""
|
"""
|
||||||
if type is None:
|
if types is None:
|
||||||
type = [Type.Movie, Type.TV, Type.Directory, Type.Video]
|
types = [Type.MOVIE, Type.TV, Type.DIRECTORY, Type.VIDEO]
|
||||||
post = {
|
post = {
|
||||||
"tags": {"type": type} if type else {},
|
"tags": {"type": types} if types else {},
|
||||||
"sort_type": sort,
|
"sort_type": sort,
|
||||||
"sort_column": sort_by,
|
"sort_column": sort_by,
|
||||||
"page": page,
|
"page": page,
|
||||||
@@ -313,19 +313,25 @@ class Api:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def item(self, guid: str) -> Optional[Item]:
|
def item(self, guid: str) -> Optional[Item]:
|
||||||
""" """
|
"""
|
||||||
|
查询媒体详情
|
||||||
|
"""
|
||||||
if (res := self.__request_api(f"/item/{guid}")) and res.success:
|
if (res := self.__request_api(f"/item/{guid}")) and res.success:
|
||||||
return self.__build_item(res.data)
|
return self.__build_item(res.data)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def season_list(self, tv_guid: str) -> Optional[list[Item]]:
|
def season_list(self, tv_guid: str) -> Optional[list[Item]]:
|
||||||
""" """
|
"""
|
||||||
|
查询季列表
|
||||||
|
"""
|
||||||
if (res := self.__request_api(f"/season/list/{tv_guid}")) and res.success:
|
if (res := self.__request_api(f"/season/list/{tv_guid}")) and res.success:
|
||||||
return [self.__build_item(info) for info in res.data]
|
return [self.__build_item(info) for info in res.data]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def episode_list(self, season_guid: str) -> Optional[list[Item]]:
|
def episode_list(self, season_guid: str) -> Optional[list[Item]]:
|
||||||
""" """
|
"""
|
||||||
|
查询剧集列表
|
||||||
|
"""
|
||||||
if (res := self.__request_api(f"/episode/list/{season_guid}")) and res.success:
|
if (res := self.__request_api(f"/episode/list/{season_guid}")) and res.success:
|
||||||
return [self.__build_item(info) for info in res.data]
|
return [self.__build_item(info) for info in res.data]
|
||||||
return None
|
return None
|
||||||
@@ -366,7 +372,11 @@ class Api:
|
|||||||
return f"nonce={nonce}×tamp={ts}&sign={sign}"
|
return f"nonce={nonce}×tamp={ts}&sign={sign}"
|
||||||
|
|
||||||
def __request_api(
|
def __request_api(
|
||||||
self, api: str, method: str = None, params: dict = None, data: dict = None
|
self,
|
||||||
|
api: str,
|
||||||
|
method: Optional[str] = None,
|
||||||
|
params: Optional[dict] = None,
|
||||||
|
data: Optional[dict] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
请求飞牛影视API
|
请求飞牛影视API
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class TrimeMedia:
|
|||||||
username: Optional[str] = None,
|
username: Optional[str] = None,
|
||||||
password: Optional[str] = None,
|
password: Optional[str] = None,
|
||||||
play_host: Optional[str] = None,
|
play_host: Optional[str] = None,
|
||||||
sync_libraries: list = None,
|
sync_libraries: Optional[list] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
if not host or not username or not password:
|
if not host or not username or not password:
|
||||||
@@ -87,11 +87,11 @@ class TrimeMedia:
|
|||||||
for library in self._libraries.values():
|
for library in self._libraries.values():
|
||||||
if hidden and self.__is_library_blocked(library.guid):
|
if hidden and self.__is_library_blocked(library.guid):
|
||||||
continue
|
continue
|
||||||
if library.category == fnapi.Category.Movie:
|
if library.category == fnapi.Category.MOVIE:
|
||||||
library_type = MediaType.MOVIE.value
|
library_type = MediaType.MOVIE.value
|
||||||
elif library.category == fnapi.Category.TV:
|
elif library.category == fnapi.Category.TV:
|
||||||
library_type = MediaType.TV.value
|
library_type = MediaType.TV.value
|
||||||
elif library.category == fnapi.Category.Others:
|
elif library.category == fnapi.Category.OTHERS:
|
||||||
# 忽略这个库
|
# 忽略这个库
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@@ -170,7 +170,7 @@ class TrimeMedia:
|
|||||||
movies = []
|
movies = []
|
||||||
items = self._api.search_list(keywords=title) or []
|
items = self._api.search_list(keywords=title) or []
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.type != fnapi.Type.Movie:
|
if item.type != fnapi.Type.MOVIE:
|
||||||
continue
|
continue
|
||||||
if (
|
if (
|
||||||
(not tmdb_id or tmdb_id == item.tmdb_id)
|
(not tmdb_id or tmdb_id == item.tmdb_id)
|
||||||
@@ -361,11 +361,11 @@ class TrimeMedia:
|
|||||||
"""
|
"""
|
||||||
拼装播放链接
|
拼装播放链接
|
||||||
"""
|
"""
|
||||||
if item.type == fnapi.Type.Episode:
|
if item.type == fnapi.Type.EPISODE:
|
||||||
return f"{host}/v/tv/episode/{item.guid}"
|
return f"{host}/v/tv/episode/{item.guid}"
|
||||||
elif item.type == fnapi.Type.Season:
|
elif item.type == fnapi.Type.SEASON:
|
||||||
return f"{host}/v/tv/season/{item.guid}"
|
return f"{host}/v/tv/season/{item.guid}"
|
||||||
elif item.type == fnapi.Type.Movie:
|
elif item.type == fnapi.Type.MOVIE:
|
||||||
return f"{host}/v/movie/{item.guid}"
|
return f"{host}/v/movie/{item.guid}"
|
||||||
elif item.type == fnapi.Type.TV:
|
elif item.type == fnapi.Type.TV:
|
||||||
return f"{host}/v/tv/{item.guid}"
|
return f"{host}/v/tv/{item.guid}"
|
||||||
@@ -379,22 +379,22 @@ class TrimeMedia:
|
|||||||
"""
|
"""
|
||||||
:params use_backdrop: 是否优先使用Backdrop类型的图片
|
:params use_backdrop: 是否优先使用Backdrop类型的图片
|
||||||
"""
|
"""
|
||||||
if item.type == fnapi.Type.Episode:
|
if item.type == fnapi.Type.EPISODE:
|
||||||
title = item.tv_title
|
title = item.tv_title
|
||||||
subtitle = f"S{item.season_number}:{item.episode_number} - {item.title}"
|
subtitle = f"S{item.season_number}:{item.episode_number} - {item.title}"
|
||||||
else:
|
else:
|
||||||
title = item.title
|
title = item.title
|
||||||
subtitle = "电影" if item.type == fnapi.Type.Movie else "视频"
|
subtitle = "电影" if item.type == fnapi.Type.MOVIE else "视频"
|
||||||
type = (
|
types = (
|
||||||
MediaType.MOVIE.value
|
MediaType.MOVIE.value
|
||||||
if item.type in [fnapi.Type.Movie, fnapi.Type.Video]
|
if item.type in [fnapi.Type.MOVIE, fnapi.Type.VIDEO]
|
||||||
else MediaType.TV.value
|
else MediaType.TV.value
|
||||||
)
|
)
|
||||||
return schemas.MediaServerPlayItem(
|
return schemas.MediaServerPlayItem(
|
||||||
id=item.guid,
|
id=item.guid,
|
||||||
title=title,
|
title=title,
|
||||||
subtitle=subtitle,
|
subtitle=subtitle,
|
||||||
type=type,
|
type=types,
|
||||||
image=f"{self._api.host}{item.poster}",
|
image=f"{self._api.host}{item.poster}",
|
||||||
link=self.__build_play_url(self._playhost or self._api.host, item),
|
link=self.__build_play_url(self._playhost or self._api.host, item),
|
||||||
percent=(
|
percent=(
|
||||||
@@ -421,22 +421,22 @@ class TrimeMedia:
|
|||||||
"""
|
"""
|
||||||
if not self.is_authenticated():
|
if not self.is_authenticated():
|
||||||
return None
|
return None
|
||||||
if (SIZE := limit) is None:
|
if (page_size := limit) is None:
|
||||||
SIZE = -1
|
page_size = -1
|
||||||
items = (
|
items = (
|
||||||
self._api.item_list(
|
self._api.item_list(
|
||||||
guid=parent,
|
guid=parent,
|
||||||
page=start_index + 1,
|
page=start_index + 1,
|
||||||
page_size=SIZE,
|
page_size=page_size,
|
||||||
type=[fnapi.Type.Movie, fnapi.Type.TV, fnapi.Type.Directory],
|
types=[fnapi.Type.MOVIE, fnapi.Type.TV, fnapi.Type.DIRECTORY],
|
||||||
)
|
)
|
||||||
or []
|
or []
|
||||||
)
|
)
|
||||||
for item in items:
|
for item in items:
|
||||||
if item.type == fnapi.Type.Directory:
|
if item.type == fnapi.Type.DIRECTORY:
|
||||||
for items in self.get_items(parent=item.guid):
|
for items in self.get_items(parent=item.guid):
|
||||||
yield items
|
yield items
|
||||||
elif item.type in [fnapi.Type.Movie, fnapi.Type.TV]:
|
elif item.type in [fnapi.Type.MOVIE, fnapi.Type.TV]:
|
||||||
yield self.__build_media_server_item(item)
|
yield self.__build_media_server_item(item)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ class TrimeMedia:
|
|||||||
self._api.item_list(
|
self._api.item_list(
|
||||||
page=1,
|
page=1,
|
||||||
page_size=max(100, num * 5),
|
page_size=max(100, num * 5),
|
||||||
type=[fnapi.Type.Movie, fnapi.Type.TV],
|
types=[fnapi.Type.MOVIE, fnapi.Type.TV],
|
||||||
)
|
)
|
||||||
or []
|
or []
|
||||||
)
|
)
|
||||||
@@ -505,7 +505,7 @@ class TrimeMedia:
|
|||||||
self._api.item_list(
|
self._api.item_list(
|
||||||
page=1,
|
page=1,
|
||||||
page_size=max(100, num * 5),
|
page_size=max(100, num * 5),
|
||||||
type=[fnapi.Type.Movie, fnapi.Type.TV],
|
types=[fnapi.Type.MOVIE, fnapi.Type.TV],
|
||||||
)
|
)
|
||||||
or []
|
or []
|
||||||
)
|
)
|
||||||
@@ -534,7 +534,7 @@ class TrimeMedia:
|
|||||||
|
|
||||||
def __is_library_blocked(self, library_guid: str):
|
def __is_library_blocked(self, library_guid: str):
|
||||||
if library := self._libraries.get(library_guid):
|
if library := self._libraries.get(library_guid):
|
||||||
if library.category == fnapi.Category.Others:
|
if library.category == fnapi.Category.OTHERS:
|
||||||
# 忽略这个库
|
# 忽略这个库
|
||||||
return True
|
return True
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user