Simplify getting timestamp
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
from base64 import urlsafe_b64encode as b64enc
|
from base64 import urlsafe_b64encode as b64enc
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import calendar, datetime, pytz
|
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from base64 import urlsafe_b64encode as b64enc
|
from base64 import urlsafe_b64encode as b64enc
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
import calendar, datetime, pytz
|
import time
|
||||||
import random
|
import random
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
@@ -141,11 +141,7 @@ def _build(video_id, _ts1, _ts2, _ts3, _ts4, _ts5, topchat_only):
|
|||||||
|
|
||||||
def _times(past_sec):
|
def _times(past_sec):
|
||||||
|
|
||||||
def unixts_now():
|
n = int(time.time())
|
||||||
now = datetime.datetime.now(pytz.utc)
|
|
||||||
return calendar.timegm(now.utctimetuple())
|
|
||||||
|
|
||||||
n = unixts_now()
|
|
||||||
|
|
||||||
_ts1= n - random.uniform(0,1*3)
|
_ts1= n - random.uniform(0,1*3)
|
||||||
_ts2= n - random.uniform(0.01,0.99)
|
_ts2= n - random.uniform(0.01,0.99)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ speed_calculator.py
|
|||||||
チャットの勢いを算出するChatProcessor
|
チャットの勢いを算出するChatProcessor
|
||||||
Calculate speed of chat.
|
Calculate speed of chat.
|
||||||
"""
|
"""
|
||||||
import calendar, datetime, pytz
|
import time
|
||||||
from .chat_processor import ChatProcessor
|
from .chat_processor import ChatProcessor
|
||||||
class RingQueue:
|
class RingQueue:
|
||||||
"""
|
"""
|
||||||
@@ -143,8 +143,7 @@ class SpeedCalculator(ChatProcessor, RingQueue):
|
|||||||
'''
|
'''
|
||||||
チャットデータがない場合に空のデータをキューに投入する。
|
チャットデータがない場合に空のデータをキューに投入する。
|
||||||
'''
|
'''
|
||||||
timestamp_now = calendar.timegm(datetime.datetime.
|
timestamp_now = int(time.time())
|
||||||
now(pytz.utc).utctimetuple())
|
|
||||||
self.put({
|
self.put({
|
||||||
'chat_count':0,
|
'chat_count':0,
|
||||||
'starttime':int(timestamp_now),
|
'starttime':int(timestamp_now),
|
||||||
|
|||||||
Reference in New Issue
Block a user