forked from TomoeMami/S1PlainTextBackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleadd.py
executable file
·32 lines (31 loc) · 1.41 KB
/
simpleadd.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
# -*- coding: UTF-8 -*-
import codecs
import sys
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
import os
import json
import io
import time
rootdir="/home/ubuntu/S1PlainTextBackup/"
with open(rootdir+'RefreshingData.json',"r",encoding='utf-8') as f:
thdata=json.load(f)
flag = 1
ids = []
for i in range(len(thdata)):
ids.append(thdata[i]['id'])
while(flag):
threadid = input(u"S1 thread ID: ")
if(threadid == '0'):
break
if(threadid in ids):
print(u"早就有了!更新时间")
thdata[ids.index(threadid)]['lastedit'] = int(time.time())
thdata[ids.index(threadid)]['active'] = True
else:
print(u'请输入版面分类代号:\n1 = 外野,11 = 外野专楼\n2 = 漫区,22 = 漫区专楼\n3 = 游戏区,33 = 游戏区专楼\n4 = 虚拟主播区,44 = 虚拟主播区专楼')
threadcategory = input(u'我选:')
catechooser = {'1':'外野','11':'外野专楼','2':'漫区','22':'漫区专楼','3':'游戏区','33':'游戏区专楼','4':'虚拟主播区','44':'虚拟主播区专楼'}
newthread = {"id": threadid,"totalpage": 1,"title": "待更新","lastedit": int(time.time()),"category": catechooser[threadcategory],"active": True}
thdata.append(newthread)
with open(rootdir+'RefreshingData.json',"w",encoding='utf-8') as f:
f.write(json.dumps(thdata,indent=2,ensure_ascii=False))