Skip to content

Commit

Permalink
精确控制到第二天0时,去掉不必要的加载
Browse files Browse the repository at this point in the history
  • Loading branch information
yjqiang committed Apr 11, 2018
1 parent 80111df commit f7ce57d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Silver.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from bilibili import bilibili
import hashlib
import requests
import datetime
import time
import asyncio
import utils

class Silver():

Expand Down Expand Up @@ -50,8 +49,8 @@ async def run(self):
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), "检查宝箱状态")
temp = self.GetAward()
if temp == None or temp == -10017:
#print("# 半小时后检测是否第二天了")
await asyncio.sleep(1800)
#print("# 半小时后检测是否第二天了")
await asyncio.sleep(utils.seconds_until_tomorrow() + 300)
elif temp == 0:
print("# 打开了宝箱")
self.GetAward()
Expand Down
9 changes: 8 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ def adjust_for_chinese(str):
def CurrentTime():
currenttime = int(time.mktime(datetime.datetime.now().timetuple()))
return str(currenttime)


def seconds_until_tomorrow():
today = datetime.date.today()
tomorrow = today + datetime.timedelta(days=1)
tomorrow_start_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d')))
current_time = int(time.mktime(datetime.datetime.now().timetuple()))
return tomorrow_start_time - current_time


def fetch_medal():
print('{} {} {:^12} {:^10} {} {:^6} '.format(adjust_for_chinese('勋章'), adjust_for_chinese('主播昵称'), '亲密度', '今日的亲密度',
Expand Down

0 comments on commit f7ce57d

Please sign in to comment.