ck_everphoto.EverPhoto.main()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 31
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 25
nop 1
dl 0
loc 31
rs 9.28
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
"""
3
:author @CAB233
4
:url https://github.com/CAB233/everphoto_checkin
5
cron: 3 22 * * *
6
new Env('时光相册');
7
"""
8
9
import requests
10
11
from notify_mtr import send
12
from utils import get_data
13
14
15
class EverPhoto:
16
    def __init__(self, check_items):
17
        self.check_items = check_items
18
19
    def main(self):
20
        msg_all = ""
21
        url = "https://openapi.everphoto.cn/sf/3/v4/PostCheckIn"
22
        login_url = "https://web.everphoto.cn/api/auth"
23
        for check_item in self.check_items:
24
            mobile = check_item.get("mobile")
25
            password = check_item.get("password")
26
27
            login_key = f"mobile={mobile}&password={password}"
28
            header = {
29
                "user-agent": "EverPhoto/4.5.0 (Android;4050002;MuMu;23;dev)",
30
                "application": "tc.everphoto",
31
            }
32
            data = requests.post(login_url, login_key, headers=header).json()["data"]
33
34
            header = {
35
                "user-agent": "EverPhoto/4.5.0 (Android;4050002;MuMu;23;dev)",
36
                "application": "tc.everphoto",
37
                "content-type": "application/json",
38
                "host": "openapi.everphoto.cn",
39
                "connection": "Keep-Alive",
40
                "authorization": f'Bearer {data["token"]}',
41
            }
42
43
            res = requests.post(url, headers=header).json()
44
            checkin_result = res["data"]["checkin_result"]
45
            continuity = res["data"]["continuity"]
46
47
            msg = f"是否为今日第一次签到:{checkin_result}\n累积签到天数:{continuity}"
48
            msg_all += msg + "\n\n"
49
        return msg_all
50
51
52
if __name__ == "__main__":
53
    _data = get_data()
54
    _check_items = _data.get("EVERPHOTO", [])
55
    result = EverPhoto(check_items=_check_items).main()
56
    send("时光相册", result)
57