Skip to content

Commit

Permalink
fix 播放限速插件
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Aug 12, 2023
1 parent 153d22d commit c2ae88a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app/modules/emby/emby.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ def get_data(self, url: str) -> Optional[Response]:
自定义URL从媒体服务器获取数据,其中{HOST}、{APIKEY}、{USER}会被替换成实际的值
:param url: 请求地址
"""
if not self._host or not self._apikey:
return None
url = url.replace("{HOST}", self._host)\
.replace("{APIKEY}", self._apikey)\
.replace("{USER}", self._user)
Expand Down
2 changes: 2 additions & 0 deletions app/modules/jellyfin/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ def get_data(self, url: str) -> Optional[Response]:
自定义URL从媒体服务器获取数据,其中{HOST}、{APIKEY}、{USER}会被替换成实际的值
:param url: 请求地址
"""
if not self._host or not self._apikey:
return None
url = url.replace("{HOST}", self._host)\
.replace("{APIKEY}", self._apikey)\
.replace("{USER}", self._user)
Expand Down
8 changes: 5 additions & 3 deletions app/plugins/speedlimiter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from app.core.config import settings
from app.core.event import eventmanager, Event
from app.log import logger
from app.modules.emby import Emby
from app.modules.jellyfin import Jellyfin
from app.modules.plex import Plex
from app.modules.qbittorrent import Qbittorrent
from app.modules.transmission import Transmission
Expand Down Expand Up @@ -143,7 +145,7 @@ def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
'props': {
'chips': True,
'multiple': True,
'model': 'sign_sites',
'model': 'downloader',
'label': '下载器',
'items': [
{'title': 'Qbittorrent', 'value': 'qbittorrent'},
Expand Down Expand Up @@ -266,7 +268,7 @@ def __check_playing_sessions(self, event: Event = None):
if settings.MEDIASERVER == "emby":
req_url = "{HOST}emby/Sessions?api_key={APIKEY}"
try:
res = RequestUtils().get_res(req_url)
res = Emby().get_data(req_url)
if res and res.status_code == 200:
sessions = res.json()
for session in sessions:
Expand All @@ -282,7 +284,7 @@ def __check_playing_sessions(self, event: Event = None):
elif settings.MEDIASERVER == "jellyfin":
req_url = "{HOST}Sessions?api_key={APIKEY}"
try:
res = RequestUtils().get_res(req_url)
res = Jellyfin().get_data(req_url)
if res and res.status_code == 200:
sessions = res.json()
for session in sessions:
Expand Down

0 comments on commit c2ae88a

Please sign in to comment.