mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-04-13 17:09:43 +08:00
fix wallpaper
This commit is contained in:
@@ -66,4 +66,4 @@ def wallpapers() -> Any:
|
||||
"""
|
||||
获取登录页面电影海报
|
||||
"""
|
||||
return WallpaperHelper().get_wallpaper()
|
||||
return WallpaperHelper().get_wallpapers()
|
||||
|
||||
@@ -2,7 +2,6 @@ import threading
|
||||
from typing import List, Union, Optional, Generator, Any
|
||||
|
||||
from app.chain import ChainBase
|
||||
from app.core.cache import cached
|
||||
from app.core.config import global_vars
|
||||
from app.db.mediaserver_oper import MediaServerOper
|
||||
from app.helper.service import ServiceConfigHelper
|
||||
@@ -92,7 +91,6 @@ class MediaServerChain(ChainBase):
|
||||
"""
|
||||
return self.run_module("mediaserver_latest", count=count, server=server, username=username)
|
||||
|
||||
@cached(maxsize=1, ttl=3600)
|
||||
def get_latest_wallpapers(self, server: Optional[str] = None, count: Optional[int] = 10,
|
||||
remote: bool = True, username: Optional[str] = None) -> List[str]:
|
||||
"""
|
||||
|
||||
@@ -13,34 +13,32 @@ class WallpaperHelper(metaclass=Singleton):
|
||||
def __init__(self):
|
||||
self.req = RequestUtils(timeout=5)
|
||||
|
||||
@staticmethod
|
||||
def get_wallpaper() -> Optional[str]:
|
||||
def get_wallpaper(self) -> Optional[str]:
|
||||
"""
|
||||
获取登录页面壁纸
|
||||
"""
|
||||
if settings.WALLPAPER == "bing":
|
||||
url = WallpaperHelper().get_bing_wallpaper()
|
||||
url = self.get_bing_wallpaper()
|
||||
elif settings.WALLPAPER == "mediaserver":
|
||||
url = MediaServerChain().get_latest_wallpaper()
|
||||
url = self.get_mediaserver_wallpaper()
|
||||
elif settings.WALLPAPER == "customize":
|
||||
url = WallpaperHelper().get_customize_wallpaper()
|
||||
url = self.get_customize_wallpaper()
|
||||
else:
|
||||
url = WallpaperHelper().get_tmdb_wallpaper()
|
||||
url = self.get_tmdb_wallpaper()
|
||||
return url
|
||||
|
||||
@staticmethod
|
||||
def get_wallpapers(num: int = 10) -> List[str]:
|
||||
def get_wallpapers(self, num: int = 10) -> List[str]:
|
||||
"""
|
||||
获取登录页面壁纸列表
|
||||
"""
|
||||
if settings.WALLPAPER == "bing":
|
||||
return WallpaperHelper().get_bing_wallpapers(num)
|
||||
return self.get_bing_wallpapers(num)
|
||||
elif settings.WALLPAPER == "mediaserver":
|
||||
return MediaServerChain().get_latest_wallpapers(count=num)
|
||||
return self.get_mediaserver_wallpapers(num)
|
||||
elif settings.WALLPAPER == "customize":
|
||||
return WallpaperHelper().get_customize_wallpapers(num)
|
||||
return self.get_customize_wallpapers(num)
|
||||
else:
|
||||
return WallpaperHelper().get_tmdb_wallpapers(num)
|
||||
return self.get_tmdb_wallpapers(num)
|
||||
|
||||
@cached(maxsize=1, ttl=3600)
|
||||
def get_tmdb_wallpaper(self) -> Optional[str]:
|
||||
@@ -89,6 +87,20 @@ class WallpaperHelper(metaclass=Singleton):
|
||||
print(str(err))
|
||||
return []
|
||||
|
||||
@cached(maxsize=1, ttl=3600)
|
||||
def get_mediaserver_wallpaper(self) -> Optional[str]:
|
||||
"""
|
||||
获取媒体服务器壁纸
|
||||
"""
|
||||
return MediaServerChain().get_latest_wallpaper()
|
||||
|
||||
@cached(maxsize=1, ttl=3600)
|
||||
def get_mediaserver_wallpapers(self, num: int = 10) -> List[str]:
|
||||
"""
|
||||
获取媒体服务器壁纸列表
|
||||
"""
|
||||
return MediaServerChain().get_latest_wallpapers(count=num)
|
||||
|
||||
@cached(maxsize=1, ttl=3600)
|
||||
def get_customize_wallpaper(self) -> Optional[str]:
|
||||
"""
|
||||
|
||||
@@ -15,7 +15,6 @@ from app.chain.mediaserver import MediaServerChain
|
||||
from app.chain.recommend import RecommendChain
|
||||
from app.chain.site import SiteChain
|
||||
from app.chain.subscribe import SubscribeChain
|
||||
from app.chain.tmdb import TmdbChain
|
||||
from app.chain.transfer import TransferChain
|
||||
from app.chain.workflow import WorkflowChain
|
||||
from app.core.config import settings
|
||||
@@ -23,6 +22,7 @@ from app.core.event import EventManager, eventmanager, Event
|
||||
from app.core.plugin import PluginManager
|
||||
from app.db.systemconfig_oper import SystemConfigOper
|
||||
from app.helper.sites import SitesHelper
|
||||
from app.helper.wallpaper import WallpaperHelper
|
||||
from app.log import logger
|
||||
from app.schemas import Notification, NotificationType, Workflow, ConfigChangeEventData
|
||||
from app.schemas.types import EventType, SystemConfigKey
|
||||
@@ -148,7 +148,7 @@ class Scheduler(metaclass=Singleton):
|
||||
},
|
||||
"random_wallpager": {
|
||||
"name": "壁纸缓存",
|
||||
"func": TmdbChain().get_trending_wallpapers,
|
||||
"func": WallpaperHelper().get_wallpapers,
|
||||
"running": False,
|
||||
},
|
||||
"sitedata_refresh": {
|
||||
|
||||
Reference in New Issue
Block a user