logicdn 1.0.543 → 1.0.547

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,48 +1,56 @@
1
- import sys
2
- import json
3
- import time
4
- from datetime import datetime
5
-
6
- import requests
7
- from biz import sentence, friend
8
-
9
- CONF_PATH = 'asset/data/bundle.json'
10
- TODAY = datetime.today().strftime('%Y-%m-%d')
11
-
12
-
13
- class Bundle:
14
- def __init__(self):
15
- self.sentences = sentence.Api().pure_data()
16
- self.friends = friend.FriendLinkDoctor().check_boby()
17
-
18
- def save(self):
19
- with open(CONF_PATH, 'w') as f:
20
- json.dump({
21
- 'code': 0,
22
- 'msg': 'success',
23
- 'date': TODAY,
24
- 'support_url': 'https://logi.im',
25
- 'sentences': self.sentences,
26
- 'friends': self.friends
27
- }, f)
28
-
29
- @staticmethod
30
- def refresh():
31
- api = 'https://{}.jsdelivr.net/npm/logicdn/logi.im/api/asset/data/bundle.json'
32
- for _ in range(5):
33
- try:
34
- purge = requests.get(api.format('purge')).json()
35
- data = requests.get(api.format('cdn')).json()
36
- print(purge.get('status'), data['date'])
37
- if data['date'] == TODAY:
38
- return
39
- except Exception:
40
- pass
41
- time.sleep(60)
42
-
43
-
44
- if __name__ == '__main__':
45
- if len(sys.argv) != 1 and sys.argv[1] == 'r':
46
- Bundle.refresh()
47
- else:
48
- Bundle().save()
1
+ import sys
2
+ import json
3
+ import time
4
+ from datetime import datetime
5
+
6
+ import requests
7
+ from biz import sentence, friend
8
+
9
+ CONF_PATH = 'asset/data/bundle.json'
10
+ PACKAGE_PATH = '../../package.json'
11
+ TODAY = datetime.today().strftime('%Y-%m-%d')
12
+
13
+
14
+ class Bundle:
15
+ def __init__(self):
16
+ self.sentences = sentence.Api().pure_data()
17
+ self.friends = friend.FriendLinkDoctor().check_boby()
18
+
19
+ def save(self):
20
+ version = None
21
+ with open(PACKAGE_PATH, 'r') as f:
22
+ splitted = json.load(f)['version'].split(".")
23
+ splitted.append(str(int(splitted.pop()) + 2))
24
+ version = '.'.join(splitted)
25
+
26
+ with open(CONF_PATH, 'w') as f:
27
+ json.dump({
28
+ 'code': 0,
29
+ 'msg': 'success',
30
+ 'date': TODAY,
31
+ 'version': version,
32
+ 'support_url': 'https://logi.im',
33
+ 'sentences': self.sentences,
34
+ 'friends': self.friends
35
+ }, f)
36
+
37
+ @staticmethod
38
+ def refresh():
39
+ api = 'https://{}.jsdelivr.net/npm/logicdn/logi.im/api/asset/data/bundle.json'
40
+ for _ in range(5):
41
+ try:
42
+ purge = requests.get(api.format('purge')).json()
43
+ data = requests.get(api.format('cdn')).json()
44
+ print(purge.get('status'), data['date'])
45
+ if data['date'] == TODAY:
46
+ return
47
+ except Exception:
48
+ pass
49
+ time.sleep(60)
50
+
51
+
52
+ if __name__ == '__main__':
53
+ if len(sys.argv) != 1 and sys.argv[1] == 'r':
54
+ Bundle.refresh()
55
+ else:
56
+ Bundle().save()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logicdn",
3
- "version": "1.0.543",
3
+ "version": "1.0.547",
4
4
  "description": "Static CDN for Personal Use",
5
5
  "main": "index.mjs",
6
6
  "repository": {