Skip to content

Commit

Permalink
feat(api): expose library-resume to API (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saviio authored Oct 24, 2023
1 parent f6a7eb9 commit 88c2813
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions web/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def __init__(self):
"get_category_config": self.get_category_config,
"get_system_processes": self.get_system_processes,
"run_plugin_method": self.run_plugin_method,
"get_library_resume": self.__get_resume,
}
# 远程命令响应
self._commands = {
Expand Down Expand Up @@ -2610,6 +2611,15 @@ def __restory_backup(data):

return {"code": 1, "msg": "文件不存在"}

@staticmethod
def __get_resume(data):
"""
获得继续观看
"""
num = data.get("num") or 12
# 实测,plex 似乎无法按照数目返回,此处手动切片
return { "code": 0, "list": MediaServer().get_resume(num)[0:num] }

@staticmethod
def __start_mediasync(data):
"""
Expand Down
11 changes: 11 additions & 0 deletions web/apiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,17 @@ def post():
"""
return WebAction().api_action(cmd='get_library_playhistory')

@library.route('/mediaserver/resume')
class LibraryResume(ClientResource):
parser = reqparse.RequestParser()
parser.add_argument('num', type=int, help='返回记录数', location='form', required=True)

@library.doc(parser=parser)
def post(self):
"""
查询媒体库继续观看列表
"""
return WebAction().api_action(cmd='get_library_resume', data=self.parser.parse_args())

@library.route('/mediaserver/statistics')
class LibraryStatistics(ClientResource):
Expand Down

0 comments on commit 88c2813

Please sign in to comment.