make redis to config
This commit is contained in:
parent
95c7ee717b
commit
a740413f4e
3
.gitignore
vendored
3
.gitignore
vendored
@ -103,3 +103,6 @@ ENV/
|
||||
|
||||
cookie.txt
|
||||
logs
|
||||
|
||||
config.json
|
||||
|
||||
|
12
sample.py
12
sample.py
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import asyncio
|
||||
import http.cookies
|
||||
import json
|
||||
@ -15,6 +14,11 @@ import redis
|
||||
import blivedm
|
||||
from blivedm.clients import ws_base
|
||||
|
||||
with open("config.json") as conf_f:
|
||||
conf = json.load(conf_f)
|
||||
|
||||
redis_conf = conf.get("redis", {})
|
||||
|
||||
os.makedirs("logs", exist_ok=True)
|
||||
room_status_log = open("logs/room_status.jsonl", "a", encoding="utf-8")
|
||||
|
||||
@ -24,7 +28,11 @@ logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger()
|
||||
|
||||
room_list_key = "bilibili.live.danmu.room_list"
|
||||
r = redis.Redis(host="redis", port=6379, db=0)
|
||||
r = redis.Redis(
|
||||
host=redis_conf.get("host", "127.0.0.1"),
|
||||
port=redis_conf.get("port", 6379),
|
||||
db=redis_conf.get("port", 0),
|
||||
)
|
||||
|
||||
TEST_ROOM_IDS = [int(room_id) for room_id in set(r.lrange(room_list_key, 0, -1))]
|
||||
clients = {}
|
||||
|
Loading…
Reference in New Issue
Block a user