diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d6ef51e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.6 +WORKDIR /Project/Middle-server + +COPY requirements.txt ./ +RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple + +COPY . . + +CMD ["gunicorn", "start:app", "-c", "./gunicorn.conf.py"] \ No newline at end of file diff --git a/__pycache__/gunicorn.conf.cpython-310.pyc b/__pycache__/gunicorn.conf.cpython-310.pyc new file mode 100644 index 0000000..ba61ce8 Binary files /dev/null and b/__pycache__/gunicorn.conf.cpython-310.pyc differ diff --git a/gunicorn.conf.py b/gunicorn.conf.py new file mode 100644 index 0000000..ccf7cef --- /dev/null +++ b/gunicorn.conf.py @@ -0,0 +1,3 @@ +workers = 5 # 定义同时开启的处理请求的进程数量,根据网站流量适当调整 +worker_class = "gevent" # 采用gevent库,支持异步处理请求,提高吞吐量 +bind = "0.0.0.0:80" \ No newline at end of file diff --git a/plugin/NavidromePlaylistSync/api/playlist.py b/plugin/NavidromePlaylistSync/api/playlist.py index db6dd82..36ace02 100644 --- a/plugin/NavidromePlaylistSync/api/playlist.py +++ b/plugin/NavidromePlaylistSync/api/playlist.py @@ -1,10 +1,12 @@ import requests +host = 'http://192.168.124.12:4533' + def getPlaylist(token): headers = { 'x-nd-authorization': f'Bearer {token}' } - res = requests.get('https://music.hiiragi.club:8081/api/playlist?_end=50&_order=ASC&_sort=id&_start=0', headers = headers) + res = requests.get(f'{host}/api/playlist?_end=50&_order=ASC&_sort=id&_start=0', headers = headers) resJson = res.json() return resJson @@ -13,13 +15,13 @@ def downloadPlayList(palyListId, token): 'Accept': 'audio/x-mpegurl', 'x-nd-authorization': f'Bearer {token}' } - res = requests.get(f'https://music.hiiragi.club:8081/api/playlist/{palyListId}/tracks', headers = headers) + res = requests.get(f'{host}/api/playlist/{palyListId}/tracks', headers = headers) return res.content def delPlaylist(playlistId, token): headers = { 'x-nd-authorization': f'Bearer {token}' } - res = requests.delete(f'https://music.hiiragi.club:8081/api/playlist/{playlistId}', headers = headers) + res = requests.delete(f'{host}/api/playlist/{playlistId}', headers = headers) resJson = res.json() return resJson \ No newline at end of file diff --git a/plugin/NavidromePlaylistSync/app.py b/plugin/NavidromePlaylistSync/app.py index 69694b4..d42c50f 100644 --- a/plugin/NavidromePlaylistSync/app.py +++ b/plugin/NavidromePlaylistSync/app.py @@ -25,9 +25,9 @@ def start(): sync() - # if len(delPlaylistIds) > 0: - # for delId in delPlaylistIds: - # delPlaylist(delId, token) + if len(delPlaylistIds) > 0: + for delId in delPlaylistIds: + delPlaylist(delId, token) if __name__ == 'main': start() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..afdc3a0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +gunicorn +gevent +flask +requests +webdavclient3 \ No newline at end of file diff --git a/app.py b/start.py similarity index 91% rename from app.py rename to start.py index c11c4b4..28402e1 100644 --- a/app.py +++ b/start.py @@ -63,4 +63,7 @@ class GatewayServer(): gateway_server = GatewayServer() app = gateway_server.app -app.run(port=15000, host="192.168.124.12", debug=True) \ No newline at end of file +# app.run(port=15000, host="192.168.124.12", debug=True) + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file