Skip to content

Commit

Permalink
🎨 Use Python: black JavaScript: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreo authored and Oreo committed Oct 18, 2021
1 parent d9d08f1 commit 0c1111d
Show file tree
Hide file tree
Showing 57 changed files with 1,668 additions and 1,500 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,4 @@ notify.json5

# Others
magic.json
ss*
81 changes: 41 additions & 40 deletions README.md

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions api_leetcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def main():
"operationName": "questionOfToday",
"variables": {},
"query": "query questionOfToday { todayRecord { question { questionFrontendId questionTitleSlug "
"__typename } lastSubmission { id __typename } date userStatus __typename }} "
}
"__typename } lastSubmission { id __typename } date userStatus __typename }} ",
},
)
leetcodeTitle = (
json.loads(response.text)
.get("data").get("todayRecord")[0].get("question").get("questionTitleSlug")
.get("data")
.get("todayRecord")[0]
.get("question")
.get("questionTitleSlug")
)

# 获取今日每日一题的所有信息
Expand All @@ -52,8 +55,8 @@ def main():
"envInfo book { id bookName pressName source "
"shortDescription fullDescription bookImgUrl pressImgUrl "
"productUrl __typename } isSubscribed isDailyQuestion "
"dailyRecordStatus editorType ugcQuestionId style __typename }}"
}
"dailyRecordStatus editorType ugcQuestionId style __typename }}",
},
)
# 转化成json格式
jsonText = json.loads(response.text).get("data").get("question")
Expand Down
11 changes: 9 additions & 2 deletions api_ran_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ def change_db():
first = True
with open("/ql/db/crontab.db", "r", encoding="UTF-8") as f:
for i in f.readlines():
if i.find("Oreomeow_checkinpanel_master") != -1 and i.find("ran_time") == -1:
if (
i.find("Oreomeow_checkinpanel_master") != -1
and i.find("ran_time") == -1
):
record = json.loads(i)
if record.get("isDisabled") == 0:
if i.find("motto") != -1 or i.find("leetcode") != -1 or i.find("weather") != -1:
if (
i.find("motto") != -1
or i.find("leetcode") != -1
or i.find("weather") != -1
):
record["schedule"] = change_time(record["schedule"], True)
else:
record["schedule"] = change_time(record["schedule"], first)
Expand Down
14 changes: 11 additions & 3 deletions api_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ def main(self):
:return:
"""
try:
with open(os.path.join(os.path.dirname(__file__), "city.json"), "r", encoding="utf-8") as city_file:
with open(
os.path.join(os.path.dirname(__file__), "city.json"),
"r",
encoding="utf-8",
) as city_file:
city_map = json.loads(city_file.read())
except Exception:
with open("/ql/repo/Oreomeow_checkinpanel_master/city.json", "r", encoding="utf-8") as city_file:
with open(
"/ql/repo/Oreomeow_checkinpanel_master/city.json", "r", encoding="utf-8"
) as city_file:
city_map = json.loads(city_file.read())
msg_all = ""
for city_name in self.check_items:
Expand All @@ -41,7 +47,9 @@ def main(self):
notice = today_weather.get("notice")
high = today_weather.get("high")
low = today_weather.get("low")
temperature = f"温度: {low[low.find(' ') + 1:]}/{high[high.find(' ') + 1:]}"
temperature = (
f"温度: {low[low.find(' ') + 1:]}/{high[high.find(' ') + 1:]}"
)
wind = f"{today_weather.get('fx')}: {today_weather.get('fl')}"
aqi = f"空气: {today_weather.get('aqi')}"
msg = f"城市: {city_name}\n时间: {today_time}\n{notice}\n{temperature}\n{wind}\n{aqi}\n"
Expand Down
5 changes: 3 additions & 2 deletions checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ console.log(`⏳ 开始执行 ${pyname}`)
$exec(`python3 https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/${pyname}`, {
cwd: './script/Shell/checkinpanel',
timeout: 0,
// prettier-ignore
env: {
ENV_PATH: $store.get('ENV_PATH', 'string'), // 自定义配置文件路径,如 /usr/local/app/script/Lists/.env
NOTIFY_CONFIG_PATH: $store.get('NOTIFY_CONFIG_PATH', 'string'), // 自定义通知配置文件路径,如 /usr/locallocal/app/script/Lists/notify.json5
Expand Down Expand Up @@ -36,5 +37,5 @@ $exec(`python3 https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/${
},
cb(data, error) {
error ? console.error(error) : console.log(data)
}
})
},
})
3 changes: 2 additions & 1 deletion checkinjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ console.log(`⏳ 开始执行 ${jsname}`)
$exec(`node https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/${jsname}`, {
cwd: './script/Shell/checkinpanel',
timeout: 0,
// prettier-ignore
env: {
ENV_PATH: $store.get('ENV_PATH', 'string'), // 自定义配置文件路径,如 /usr/local/app/script/Lists/.env
NOTIFY_CONFIG_PATH: $store.get('NOTIFY_CONFIG_PATH', 'string'), // 自定义通知配置文件路径,如 /usr/locallocal/app/script/Lists/notify.json5
Expand Down Expand Up @@ -33,5 +34,5 @@ $exec(`node https://raw.githubusercontent.com/Oreomeow/checkinpanel/master/${jsn
TG_PROXY_AUTH: $store.get('TG_PROXY_AUTH', 'string'), // tg 代理配置认证参数,可不填
TG_PROXY_HOST: $store.get('TG_PROXY_HOST', 'string'), // tg 机器人的 TG_PROXY_HOST,例:127.0.0.1,可不填
TG_PROXY_PORT: $store.get('TG_PROXY_PORT', 'string') // tg 机器人的 TG_PROXY_PORT,例:1080,可不填
}
},
})
5 changes: 3 additions & 2 deletions checkinsh.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ console.log(`⏳ 开始执行 ${shname}`)
$exec(`chmod +x ${shname} && bash ${shname}`, {
cwd: './script/Shell/checkinpanel',
timeout: 0,
// prettier-ignore
env: {
ENV_PATH: $store.get('ENV_PATH', 'string'), // 自定义配置文件路径,如 /usr/local/app/script/Lists/.env
NOTIFY_CONFIG_PATH: $store.get('NOTIFY_CONFIG_PATH', 'string'), // 自定义通知配置文件路径,如 /usr/locallocal/app/script/Lists/notify.json5
Expand Down Expand Up @@ -36,5 +37,5 @@ $exec(`chmod +x ${shname} && bash ${shname}`, {
},
cb(data, error) {
error ? console.error(error) : console.log(data)
}
})
},
})
50 changes: 25 additions & 25 deletions ck_acfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ def get_cookies(session, phone, password):
"devicetype": "0",
"accept-language": "zh-Hans-CN;q=1, en-CN;q=0.9, ja-CN;q=0.8, zh-Hant-HK;q=0.7, io-Latn-CN;q=0.6",
"accept": "application/json",
"content-type": "application/x-www-form-urlencoded"
"content-type": "application/x-www-form-urlencoded",
}
data = f"password={password}&username={phone}"
response = session.post(
url=url, data=data, headers=headers, verify=False)
response = session.post(url=url, data=data, headers=headers, verify=False)
acpasstoken = response.json().get("acPassToken")
auth_key = str(response.json().get("auth_key"))
if acpasstoken and auth_key:
Expand All @@ -45,19 +44,19 @@ def get_token(session, cookies):
url = "https://id.app.acfun.cn/rest/web/token/get"
data = "sid=acfun.midground.api"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = session.post(url=url, cookies=cookies,
data=data, headers=headers, verify=False)
response = session.post(
url=url, cookies=cookies, data=data, headers=headers, verify=False
)
return response.json().get("acfun.midground.api_st")

def get_video(self, session):
url = "https://www.acfun.cn/rest/pc-direct/rank/channel"
data = "channelId=0&rankPeriod=DAY"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70",
}
response = session.post(
url=url, data=data, headers=headers, verify=False)
response = session.post(url=url, data=data, headers=headers, verify=False)
self.contentid = response.json().get("rankList")[0].get("contentId")
return self.contentid

Expand All @@ -67,8 +66,7 @@ def sign(session, cookies):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"
}
response = session.post(
url=url, cookies=cookies, headers=headers, verify=False)
response = session.post(url=url, cookies=cookies, headers=headers, verify=False)
return response.json().get("msg")

@staticmethod
Expand All @@ -77,10 +75,11 @@ def danmu(session, cookies):
body = "body=sitoi&color=16777215&id=27259341&mode=1&position=5019&size=25&subChannelId=84&subChannelName=%E4%B8%BB%E6%9C%BA%E5%8D%95%E6%9C%BA&type=douga&videoId=22898696"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70",
}
response = session.post(url=url, cookies=cookies,
data=body, headers=headers, verify=False)
response = session.post(
url=url, cookies=cookies, data=body, headers=headers, verify=False
)
if response.json().get("result") == 0:
msg = "弹幕成功"
else:
Expand All @@ -92,10 +91,11 @@ def throwbanana(self, session, cookies):
body = f"count=1&resourceId={self.contentid}&resourceType=2"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70",
}
response = session.post(url=url, cookies=cookies,
data=body, headers=headers, verify=False)
response = session.post(
url=url, cookies=cookies, data=body, headers=headers, verify=False
)
if response.json().get("result") == 0:
msg = "香蕉成功"
else:
Expand All @@ -107,14 +107,16 @@ def like(self, session, token):
unlike_url = "https://api.kuaishouzt.com/rest/zt/interact/delete"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70"
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70",
}
cookies = {"acfun.midground.api_st": token, "kpn": "ACFUN_APP"}
body = f"interactType=1&objectId={self.contentid}&objectType=2&subBiz=mainApp"
response = session.post(url=like_url, cookies=cookies,
data=body, headers=headers, verify=False)
session.post(url=unlike_url, cookies=cookies,
data=body, headers=headers, verify=False)
response = session.post(
url=like_url, cookies=cookies, data=body, headers=headers, verify=False
)
session.post(
url=unlike_url, cookies=cookies, data=body, headers=headers, verify=False
)
if response.json().get("result") == 1:
msg = "点赞成功"
else:
Expand All @@ -124,8 +126,7 @@ def like(self, session, token):
def share(self, session, cookies):
url = "https://api-ipv6.acfunchina.com/rest/app/task/reportTaskAction?taskType=1&market=tencent&product=ACFUN_APP&appMode=0"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = session.get(
url=url, cookies=cookies, headers=headers, verify=False)
response = session.get(url=url, cookies=cookies, headers=headers, verify=False)
if response.json().get("result") == 0:
msg = "分享成功"
else:
Expand All @@ -140,8 +141,7 @@ def main(self):
session = requests.session()

self.get_video(session=session)
cookies = self.get_cookies(
session=session, phone=phone, password=password)
cookies = self.get_cookies(session=session, phone=phone, password=password)
token = self.get_token(session=session, cookies=cookies)

sign_msg = self.sign(session=session, cookies=cookies)
Expand Down
19 changes: 11 additions & 8 deletions ck_airport.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def checkin(url, email, password):
login_url = url + "/auth/login"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
}

post_data = "email=" + email + "&passwd=" + password + "&code="
Expand All @@ -51,11 +51,10 @@ def checkin(url, email, password):

headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
"Referer": url + "/user"
"Referer": url + "/user",
}

response = session.post(
url + "/user/checkin", headers=headers, verify=False)
response = session.post(url + "/user/checkin", headers=headers, verify=False)
# print(response.text)
msg = url + "\n" + (response.json()).get("msg")

Expand All @@ -70,10 +69,14 @@ def checkin(url, email, password):
rest = re.findall(r'\["Unused_Traffic", "(.*?)"]', response.text)[0]
msg = (
url
+ "\n- 今日签到信息:" + str(msg)
+ "\n- 用户等级:" + str(level)
+ "\n- 到期时间:" + str(day)
+ "\n- 剩余流量:" + str(rest)
+ "\n- 今日签到信息:"
+ str(msg)
+ "\n- 用户等级:"
+ str(level)
+ "\n- 到期时间:"
+ str(day)
+ "\n- 剩余流量:"
+ str(rest)
)
return msg
except Exception:
Expand Down
3 changes: 2 additions & 1 deletion ck_baidu_url_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def main(self):
times = int(check_item.get("times", 100))
if data_url and submit_url:
msg = self.url_submit(
data_url=data_url, submit_url=submit_url, times=times)
data_url=data_url, submit_url=submit_url, times=times
)
else:
msg = "配置错误"
msg_all += msg + "\n\n"
Expand Down
Loading

0 comments on commit 0c1111d

Please sign in to comment.