make redis to config

This commit is contained in:
tursom 2024-03-16 15:00:45 +08:00
parent 95c7ee717b
commit a740413f4e
2 changed files with 13 additions and 2 deletions

3
.gitignore vendored
View File

@ -103,3 +103,6 @@ ENV/
cookie.txt
logs
config.json

View File

@ -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 = {}