Merge pull request #156 from gzxy0102/fix-docker
Browse files- Dockerfile +13 -5
- myUtils/auth.py +9 -6
- sau_backend.py +6 -2
Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
FROM node:22.21.1
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
@@ -11,6 +11,11 @@ RUN npm install
|
|
| 11 |
ENV NODE_ENV=production
|
| 12 |
ENV PATH=/app/node_modules/.bin:$PATH
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
RUN npm run build
|
| 15 |
|
| 16 |
|
|
@@ -20,10 +25,6 @@ WORKDIR /app
|
|
| 20 |
|
| 21 |
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright
|
| 22 |
|
| 23 |
-
COPY --from=builder /app/dist/index.html /app
|
| 24 |
-
COPY --from=builder /app/dist/assets /app/assets
|
| 25 |
-
COPY --from=builder /app/dist/vite.svg /app
|
| 26 |
-
|
| 27 |
RUN apt-get update && apt-get install -y --no-install-recommends libnss3 \
|
| 28 |
libnspr4 \
|
| 29 |
libdbus-1-3 \
|
|
@@ -48,8 +49,15 @@ RUN playwright install chromium-headless-shell
|
|
| 48 |
|
| 49 |
COPY . .
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
RUN cp conf.example.py conf.py
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
EXPOSE 5409
|
| 54 |
|
| 55 |
CMD ["python", "sau_backend.py"]
|
|
|
|
| 1 |
+
FROM node:22.21.1 AS builder
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 11 |
ENV NODE_ENV=production
|
| 12 |
ENV PATH=/app/node_modules/.bin:$PATH
|
| 13 |
|
| 14 |
+
# 替换前端中的地址
|
| 15 |
+
RUN sed -i 's#\${baseUrl}##g' /app/src/views/AccountManagement.vue
|
| 16 |
+
RUN sed -i "s#\${import\.meta\.env\.VITE_API_BASE_URL || 'http:\/\/localhost:5409'}##g" /app/src/api/material.js
|
| 17 |
+
RUN sed -i 's#localhost:5409##g' /app/.env.production
|
| 18 |
+
|
| 19 |
RUN npm run build
|
| 20 |
|
| 21 |
|
|
|
|
| 25 |
|
| 26 |
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
RUN apt-get update && apt-get install -y --no-install-recommends libnss3 \
|
| 29 |
libnspr4 \
|
| 30 |
libdbus-1-3 \
|
|
|
|
| 49 |
|
| 50 |
COPY . .
|
| 51 |
|
| 52 |
+
COPY --from=builder /app/dist/index.html /app
|
| 53 |
+
COPY --from=builder /app/dist/assets /app/assets
|
| 54 |
+
COPY --from=builder /app/dist/vite.svg /app/assets
|
| 55 |
+
|
| 56 |
RUN cp conf.example.py conf.py
|
| 57 |
|
| 58 |
+
RUN mkdir -p /app/videoFile
|
| 59 |
+
RUN mkdir -p /app/cookiesFile
|
| 60 |
+
|
| 61 |
EXPOSE 5409
|
| 62 |
|
| 63 |
CMD ["python", "sau_backend.py"]
|
myUtils/auth.py
CHANGED
|
@@ -5,15 +5,16 @@ import os
|
|
| 5 |
from playwright.async_api import async_playwright
|
| 6 |
from xhs import XhsClient
|
| 7 |
|
| 8 |
-
from conf import BASE_DIR
|
| 9 |
from utils.base_social_media import set_init_script
|
| 10 |
from utils.log import tencent_logger, kuaishou_logger, douyin_logger
|
| 11 |
from pathlib import Path
|
| 12 |
from uploader.xhs_uploader.main import sign_local
|
| 13 |
|
|
|
|
| 14 |
async def cookie_auth_douyin(account_file):
|
| 15 |
async with async_playwright() as playwright:
|
| 16 |
-
browser = await playwright.chromium.launch(headless=
|
| 17 |
context = await browser.new_context(storage_state=account_file)
|
| 18 |
context = await set_init_script(context)
|
| 19 |
# 创建一个新的页面
|
|
@@ -38,9 +39,10 @@ async def cookie_auth_douyin(account_file):
|
|
| 38 |
await browser.close()
|
| 39 |
return False
|
| 40 |
|
|
|
|
| 41 |
async def cookie_auth_tencent(account_file):
|
| 42 |
async with async_playwright() as playwright:
|
| 43 |
-
browser = await playwright.chromium.launch(headless=
|
| 44 |
context = await browser.new_context(storage_state=account_file)
|
| 45 |
context = await set_init_script(context)
|
| 46 |
# 创建一个新的页面
|
|
@@ -55,9 +57,10 @@ async def cookie_auth_tencent(account_file):
|
|
| 55 |
tencent_logger.success("[+] cookie 有效")
|
| 56 |
return True
|
| 57 |
|
|
|
|
| 58 |
async def cookie_auth_ks(account_file):
|
| 59 |
async with async_playwright() as playwright:
|
| 60 |
-
browser = await playwright.chromium.launch(headless=
|
| 61 |
context = await browser.new_context(storage_state=account_file)
|
| 62 |
context = await set_init_script(context)
|
| 63 |
# 创建一个新的页面
|
|
@@ -76,7 +79,7 @@ async def cookie_auth_ks(account_file):
|
|
| 76 |
|
| 77 |
async def cookie_auth_xhs(account_file):
|
| 78 |
async with async_playwright() as playwright:
|
| 79 |
-
browser = await playwright.chromium.launch(headless=
|
| 80 |
context = await browser.new_context(storage_state=account_file)
|
| 81 |
context = await set_init_script(context)
|
| 82 |
# 创建一个新的页面
|
|
@@ -99,7 +102,7 @@ async def cookie_auth_xhs(account_file):
|
|
| 99 |
return True
|
| 100 |
|
| 101 |
|
| 102 |
-
async def check_cookie(type,file_path):
|
| 103 |
match type:
|
| 104 |
# 小红书
|
| 105 |
case 1:
|
|
|
|
| 5 |
from playwright.async_api import async_playwright
|
| 6 |
from xhs import XhsClient
|
| 7 |
|
| 8 |
+
from conf import BASE_DIR, LOCAL_CHROME_HEADLESS
|
| 9 |
from utils.base_social_media import set_init_script
|
| 10 |
from utils.log import tencent_logger, kuaishou_logger, douyin_logger
|
| 11 |
from pathlib import Path
|
| 12 |
from uploader.xhs_uploader.main import sign_local
|
| 13 |
|
| 14 |
+
|
| 15 |
async def cookie_auth_douyin(account_file):
|
| 16 |
async with async_playwright() as playwright:
|
| 17 |
+
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
| 18 |
context = await browser.new_context(storage_state=account_file)
|
| 19 |
context = await set_init_script(context)
|
| 20 |
# 创建一个新的页面
|
|
|
|
| 39 |
await browser.close()
|
| 40 |
return False
|
| 41 |
|
| 42 |
+
|
| 43 |
async def cookie_auth_tencent(account_file):
|
| 44 |
async with async_playwright() as playwright:
|
| 45 |
+
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
| 46 |
context = await browser.new_context(storage_state=account_file)
|
| 47 |
context = await set_init_script(context)
|
| 48 |
# 创建一个新的页面
|
|
|
|
| 57 |
tencent_logger.success("[+] cookie 有效")
|
| 58 |
return True
|
| 59 |
|
| 60 |
+
|
| 61 |
async def cookie_auth_ks(account_file):
|
| 62 |
async with async_playwright() as playwright:
|
| 63 |
+
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
| 64 |
context = await browser.new_context(storage_state=account_file)
|
| 65 |
context = await set_init_script(context)
|
| 66 |
# 创建一个新的页面
|
|
|
|
| 79 |
|
| 80 |
async def cookie_auth_xhs(account_file):
|
| 81 |
async with async_playwright() as playwright:
|
| 82 |
+
browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
|
| 83 |
context = await browser.new_context(storage_state=account_file)
|
| 84 |
context = await set_init_script(context)
|
| 85 |
# 创建一个新的页面
|
|
|
|
| 102 |
return True
|
| 103 |
|
| 104 |
|
| 105 |
+
async def check_cookie(type, file_path):
|
| 106 |
match type:
|
| 107 |
# 小红书
|
| 108 |
case 1:
|
sau_backend.py
CHANGED
|
@@ -32,8 +32,12 @@ def custom_static(filename):
|
|
| 32 |
|
| 33 |
# 处理 favicon.ico 静态资源(未来打包用)
|
| 34 |
@app.route('/favicon.ico')
|
| 35 |
-
def favicon(
|
| 36 |
-
return send_from_directory(os.path.join(current_dir, 'assets'), '
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# (未来打包用)
|
| 39 |
@app.route('/')
|
|
|
|
| 32 |
|
| 33 |
# 处理 favicon.ico 静态资源(未来打包用)
|
| 34 |
@app.route('/favicon.ico')
|
| 35 |
+
def favicon():
|
| 36 |
+
return send_from_directory(os.path.join(current_dir, 'assets'), 'vite.svg')
|
| 37 |
+
|
| 38 |
+
@app.route('/vite.svg')
|
| 39 |
+
def vite_svg():
|
| 40 |
+
return send_from_directory(os.path.join(current_dir, 'assets'), 'vite.svg')
|
| 41 |
|
| 42 |
# (未来打包用)
|
| 43 |
@app.route('/')
|