-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonTryEverythingWin.py
109 lines (99 loc) · 4.15 KB
/
pythonTryEverythingWin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os
import logging
import platform
import random
import time
import signal
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger
from apscheduler.schedulers.background import BackgroundScheduler
from putdonwphone import ffmeg_to_mp4
from putdonwphone import englisword
from putdonwphone.not_watch_news.zhihu import not_watch_zhihu_news_10_min_small
from putdonwphone import mykuaishou2
LOG_FORMAT = "[%(asctime)s][%(levelname)s][%(filename)s:%(funcName)s:%(lineno)d] %(message)s"
DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def auto_window_task():
"""headless自动操作"""
file_path, habit_name,habit_detail = englisword.interface_get_daily_englis_word()
time.sleep(random.randint(1,5))
if platform.system() == "Windows":
OUT_PATH = r"D:\mp4\output"
BACK_PATH = r"D:\mp4\bak"
else:
OUT_PATH = r"/root/mp4/output"
BACK_PATH = r"/root/mp4/bak"
try:
# cookies台容易过去了 因此去掉了
time.sleep(random.randint(1,5))
not_watch_zhihu_news_10_min_small.interface_auo_upload_zhihu_small()
logging.info("---------------myzhihu-----------------")
time.sleep(random.randint(1,5))
mykuaishou2.interface_auo_upload_kuaishou2("pic",file_path, habit_name,habit_detail)
logging.info("---------------mykuaishou2-----------------")
finally:
print("---------------")
def auto_upload_mp4():
time.sleep(random.randint(1,5))
if platform.system() == "Windows":
OUT_PATH = r"D:\mp4\output"
BACK_PATH = r"D:\mp4\bak"
else:
OUT_PATH = r"/root/mp4/output"
BACK_PATH = r"/root/mp4/bak"
try:
print("")
finally:
print("...")
def change_mp4_to_small():
logging.debug("change_mp4_to_small")
try:
ffmeg_to_mp4.interface_mp4_to_post()
except Exception as myunkonw:
logging.error(f"处理视频文件时出错: {str(myunkonw)}")
#########################
class TimeoutException(Exception):
pass
def timeout_handler(signum, frame):
"""_summary_
Args:
signum (_type_): _description_
frame (_type_): _description_
Raises:
TimeoutException: _description_
"""
raise TimeoutException("Function execution timed out.")
###########################################################
if __name__ == "__main__":
if platform.system() == "Windows":
log_path = r"D:\mp4\log\pythonTryEverythingWin.log"
else:
log_path = "pythonTryEverythingWin.log"
logging.basicConfig(level=logging.DEBUG,
format=LOG_FORMAT,
datefmt=DATE_FORMAT,
filename=log_path
)
logging.info("""
┌──────────────────────────────────────────────────────────────────────┐
│ │
│ • Start pythonTryEverythingWin • │
│ │
└──────────────────────────────────────────────────────────────────────┘
""")
job_defaults = {
'coalesce': False,
'max_instances': 1
}
auto_window_task()
backsched = BlockingScheduler(job_defaults=job_defaults, timezone='Asia/Shanghai')
# 习惯养成--早睡早起
# pip install apscheduler
#12点:发一个图文
backsched.add_job(auto_window_task, CronTrigger.from_crontab("0 18 * * *"), id="get_up")
#1点:开始切换文件
backsched.add_job(change_mp4_to_small, CronTrigger.from_crontab("0 1 * * *"), id="cut_big_file")
#4点:开始上传文件
backsched.add_job(auto_upload_mp4, CronTrigger.from_crontab("0 2 * * *"), id="put_small_file")
print("start pythonTryEverythingWin")
backsched.start()