2021-05-19 12:00:36 +09:00
|
|
|
import toml
|
2021-05-14 15:59:50 +09:00
|
|
|
import os
|
|
|
|
import secrets
|
|
|
|
from flask import current_app
|
|
|
|
|
|
|
|
ROOT = os.path.dirname(current_app.root_path)
|
|
|
|
SEGMENTS_DIR = os.path.join(ROOT, 'stream')
|
|
|
|
SEGMENTS_M3U8 = os.path.join(SEGMENTS_DIR, 'stream.m3u8')
|
|
|
|
STREAM_TITLE = os.path.join(ROOT, 'title.txt')
|
|
|
|
|
|
|
|
DIR_STATIC = os.path.join(ROOT, 'website', 'static')
|
|
|
|
DIR_STATIC_EXTERNAL = os.path.join(DIR_STATIC, 'external')
|
|
|
|
|
|
|
|
BROADCASTER_TOKEN = secrets.token_hex(8)
|
|
|
|
|
2021-05-19 12:00:36 +09:00
|
|
|
CONFIG_FILE = os.path.join(ROOT, 'config.toml')
|
2021-07-05 20:45:32 +09:00
|
|
|
with open(CONFIG_FILE) as fp:
|
|
|
|
CONFIG = toml.load(fp)
|
2021-05-15 13:35:48 +09:00
|
|
|
|
2021-07-08 21:45:02 +09:00
|
|
|
# TODO: always read hls_time from stream.m3u8
|
2021-05-19 12:00:36 +09:00
|
|
|
|
2021-05-14 15:59:50 +09:00
|
|
|
VIEW_COUNTING_PERIOD = 30 # count views from the last x seconds
|
2021-07-10 00:16:05 +09:00
|
|
|
CHAT_TIMEOUT = 3 # seconds between chat messages
|
2021-05-14 15:59:50 +09:00
|
|
|
FLOOD_PERIOD = 20 # seconds
|
2021-07-10 00:16:05 +09:00
|
|
|
FLOOD_THRESHOLD = 4 # messages in FLOOD_PERIOD seconds
|
2021-05-14 15:59:50 +09:00
|
|
|
|
2021-07-18 12:51:39 +09:00
|
|
|
CHAT_MAX_STORAGE = 8192
|
2021-05-14 15:59:50 +09:00
|
|
|
CHAT_SCROLLBACK = 100
|
2021-07-18 12:51:39 +09:00
|
|
|
MESSAGE_MAX_LENGTH = 320
|
2021-05-14 15:59:50 +09:00
|
|
|
|
2021-05-19 12:00:36 +09:00
|
|
|
CAPTCHA_SECRET_KEY = os.urandom(12)
|
|
|
|
CAPTCHA_LIFETIME = 3600
|
|
|
|
|
|
|
|
VIEWER_ABSENT_THRESHOLD = 86400
|
|
|
|
|
2021-07-17 07:02:19 +09:00
|
|
|
BACKGROUND_COLOUR = b'\x23\x23\x23' # the same as in platform.css
|
2021-05-14 15:59:50 +09:00
|
|
|
BROADCASTER_COLOUR = b'\xff\x82\x80'
|
|
|
|
|
|
|
|
SEGMENT_INIT = 'init.mp4'
|
|
|
|
|
2021-05-19 12:00:36 +09:00
|
|
|
VIDEOJS_ENABLED_BY_DEFAULT = False
|
|
|
|
|
2021-07-08 21:45:02 +09:00
|
|
|
# if stream.m3u8 is not modified for this duration, consider the stream offline
|
|
|
|
# even if #EXT-X-ENDLIST is not present in the file. if this happens something
|
|
|
|
# has gone wrong in FFmpeg so we should turn off the stream.
|
|
|
|
STALE_PLAYLIST_THRESHOLD = 30
|
|
|
|
|
2021-05-14 15:59:50 +09:00
|
|
|
# notes: messages that can appear in the comment box
|
|
|
|
N_NONE = 0
|
|
|
|
N_TOKEN_EMPTY = 1
|
|
|
|
N_MESSAGE_EMPTY = 2
|
|
|
|
N_MESSAGE_LONG = 3
|
|
|
|
N_BANNED = 4
|
|
|
|
N_TOOFAST = 5
|
|
|
|
N_FLOOD = 6
|
|
|
|
N_CAPTCHA_MISSING = 7
|
|
|
|
N_CAPTCHA_WRONG = 8
|
2021-05-19 12:00:36 +09:00
|
|
|
N_CAPTCHA_USED = 9
|
|
|
|
N_CAPTCHA_EXPIRED = 10
|
|
|
|
N_CAPTCHA_RANDOM = 11
|
|
|
|
N_CONFIRM = 12
|
2021-07-18 12:51:39 +09:00
|
|
|
N_WORDFILTER = 13
|
|
|
|
N_WORDFILTER_BAN = 14
|
|
|
|
N_APPEAR_OK = 15
|
|
|
|
N_APPEAR_FAIL = 16
|
2021-05-14 15:59:50 +09:00
|
|
|
|
|
|
|
NOTES = {N_NONE: '',
|
|
|
|
N_TOKEN_EMPTY: 'illegal token',
|
|
|
|
N_MESSAGE_EMPTY: 'no message',
|
|
|
|
N_MESSAGE_LONG: 'message too long',
|
|
|
|
N_BANNED: 'you cannot chat',
|
|
|
|
N_TOOFAST: 'resend your message',
|
|
|
|
N_FLOOD: 'solve this captcha',
|
|
|
|
N_CAPTCHA_MISSING: 'please captcha',
|
|
|
|
N_CAPTCHA_WRONG: 'you got the captcha wrong',
|
2021-05-19 12:00:36 +09:00
|
|
|
N_CAPTCHA_USED: 'captcha was used already',
|
|
|
|
N_CAPTCHA_EXPIRED: 'the captcha expired',
|
2021-05-14 15:59:50 +09:00
|
|
|
N_CAPTCHA_RANDOM: 'a wild captcha appears',
|
|
|
|
N_CONFIRM: 'confirm you want to send',
|
2021-07-18 12:51:39 +09:00
|
|
|
N_WORDFILTER: 'blocked by word filter',
|
|
|
|
N_WORDFILTER_BAN: 'banned by word filter',
|
2021-05-14 15:59:50 +09:00
|
|
|
N_APPEAR_OK: 'appearance got changed',
|
|
|
|
N_APPEAR_FAIL: 'name/pw too long; no change'}
|