Evilmass
commited on
Commit
•
5cef9c4
1
Parent(s):
5b6bac4
fix tsdm cliwork
Browse files- Dockerfile +2 -3
- _playwright/tsdm.py +6 -6
Dockerfile
CHANGED
@@ -5,8 +5,6 @@ WORKDIR /tmp
|
|
5 |
|
6 |
# depends
|
7 |
RUN apt-get update -y
|
8 |
-
|
9 |
-
# pip
|
10 |
COPY ./requirements.txt /tmp/requirements.txt
|
11 |
RUN pip install -r /tmp/requirements.txt
|
12 |
|
@@ -26,12 +24,13 @@ ENV HOME=/home/user \
|
|
26 |
# Set the working directory to the user's home directory
|
27 |
WORKDIR $HOME/app
|
28 |
|
|
|
29 |
RUN mkdir $HOME/app/cookie $HOME/app/log $HOME/app/_playwright $HOME/app/config
|
30 |
|
31 |
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
32 |
RUN playwright install chromium firefox
|
33 |
|
34 |
-
# use cache
|
35 |
FROM builder
|
36 |
|
37 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
|
|
5 |
|
6 |
# depends
|
7 |
RUN apt-get update -y
|
|
|
|
|
8 |
COPY ./requirements.txt /tmp/requirements.txt
|
9 |
RUN pip install -r /tmp/requirements.txt
|
10 |
|
|
|
24 |
# Set the working directory to the user's home directory
|
25 |
WORKDIR $HOME/app
|
26 |
|
27 |
+
# create folder
|
28 |
RUN mkdir $HOME/app/cookie $HOME/app/log $HOME/app/_playwright $HOME/app/config
|
29 |
|
30 |
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
31 |
RUN playwright install chromium firefox
|
32 |
|
33 |
+
# use build cache
|
34 |
FROM builder
|
35 |
|
36 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
_playwright/tsdm.py
CHANGED
@@ -27,7 +27,7 @@ from __init__ import (
|
|
27 |
# 判断登录状态
|
28 |
async def is_login(page):
|
29 |
await page.goto(tsdm_url)
|
30 |
-
if await page.
|
31 |
tsdm_logger.info("登录成功")
|
32 |
return True
|
33 |
else:
|
@@ -46,16 +46,16 @@ async def sign(page):
|
|
46 |
|
47 |
# 签到
|
48 |
await page.goto(tsdm_sign_url)
|
49 |
-
if
|
50 |
sign_res = "今天已签到"
|
51 |
tsdm_logger.info(sign_res)
|
52 |
msg.append(sign_res)
|
53 |
else:
|
|
|
54 |
mind = random.choice(list(tsdm_minds.keys()))
|
55 |
tsdm_logger.info(f"签到心情选择:{tsdm_minds[mind]}")
|
56 |
await page.get_by_role("combobox").select_option(mind)
|
57 |
await page.get_by_label("自己填写").check() # 不想填写
|
58 |
-
song = await get_streevoice_today_song(page)
|
59 |
await page.locator("#todaysay").type(song, delay=200)
|
60 |
await page.get_by_text("点我签到!").click()
|
61 |
sign_res = "签到成功"
|
@@ -74,14 +74,14 @@ async def cliwork(page):
|
|
74 |
# 打工
|
75 |
await page.goto(tsdm_url) # 切换回电脑版
|
76 |
await page.goto(tsdm_cliwork_url)
|
77 |
-
if
|
78 |
has_work = "今天已打工"
|
79 |
tsdm_logger.info(has_work)
|
80 |
msg.append(has_work)
|
81 |
else:
|
82 |
for pid in tsdm_plugin_id:
|
83 |
-
await page.locator(f"#np_advid{pid}
|
84 |
-
await page.bring_to_front() #
|
85 |
await page.locator("#workstart").click() # 领取奖励
|
86 |
work_res = "打工成功"
|
87 |
tsdm_logger.info(work_res)
|
|
|
27 |
# 判断登录状态
|
28 |
async def is_login(page):
|
29 |
await page.goto(tsdm_url)
|
30 |
+
if await page.get_by_role("link", name="设置").is_enabled():
|
31 |
tsdm_logger.info("登录成功")
|
32 |
return True
|
33 |
else:
|
|
|
46 |
|
47 |
# 签到
|
48 |
await page.goto(tsdm_sign_url)
|
49 |
+
if page.get_by_text("今天已签到"):
|
50 |
sign_res = "今天已签到"
|
51 |
tsdm_logger.info(sign_res)
|
52 |
msg.append(sign_res)
|
53 |
else:
|
54 |
+
song = await get_streevoice_today_song(page)
|
55 |
mind = random.choice(list(tsdm_minds.keys()))
|
56 |
tsdm_logger.info(f"签到心情选择:{tsdm_minds[mind]}")
|
57 |
await page.get_by_role("combobox").select_option(mind)
|
58 |
await page.get_by_label("自己填写").check() # 不想填写
|
|
|
59 |
await page.locator("#todaysay").type(song, delay=200)
|
60 |
await page.get_by_text("点我签到!").click()
|
61 |
sign_res = "签到成功"
|
|
|
74 |
# 打工
|
75 |
await page.goto(tsdm_url) # 切换回电脑版
|
76 |
await page.goto(tsdm_cliwork_url)
|
77 |
+
if not page.get_by_role("link", name="打工挣钱"):
|
78 |
has_work = "今天已打工"
|
79 |
tsdm_logger.info(has_work)
|
80 |
msg.append(has_work)
|
81 |
else:
|
82 |
for pid in tsdm_plugin_id:
|
83 |
+
await page.locator(f"#np_advid{pid}").get_by_role("link").click()
|
84 |
+
await page.bring_to_front() # 激活第一个标签页
|
85 |
await page.locator("#workstart").click() # 领取奖励
|
86 |
work_res = "打工成功"
|
87 |
tsdm_logger.info(work_res)
|