Beispiel #1
0
import logging

from starlette.requests import Request
from starlette.responses import PlainTextResponse

from pystargazer.app import app
from pystargazer.models import Event
from pystargazer.utils import get_option as _get_option

get_option = _get_option(app, "dummy_suisei")


@app.on_startup
async def startup():
    logging.info("Plugin Start")


@app.on_shutdown
async def shutdown():
    logging.info("Plugin Stop")


@app.on_create("vtubers")
async def on_create(obj):
    logging.debug("created", obj)


@app.on_delete("vtubers")
async def on_delete(obj):
    logging.debug("deleted", obj)
Beispiel #2
0
import asyncio

from starlette.requests import Request
from starlette.responses import PlainTextResponse

from pystargazer.app import app
from pystargazer.models import Event, KVPair
from pystargazer.utils import get_option as _get_option
from .apis import Bilibili
from .models import Dynamic
from .schemas import card_schema, dyn_schemas

bilibili = Bilibili()

get_option = _get_option(app, "bilibili")


@app.route("/help/bilibili", methods=["GET"])
async def youtube_help(request: Request):
    return PlainTextResponse("Field: bilibili\n"
                             "Configs[/configs/bilibili]:\n"
                             "  disabled")


@app.on_startup
async def bilibili_setup():
    try:
        await app.plugin_state.get("bilibili_since")
    except KeyError:
        await app.plugin_state.put(KVPair("bilibili_since", {}))
Beispiel #3
0
    video: Video

    def __post_init__(self):
        if self.type == ResourceType.BROADCAST and not self.video.scheduled_start_time:
            raise ValueError(
                "Missing field(s): scheduled_start_time in video.")


token_g: Iterator[str] = cycle(app.credentials.get("youtube"))
callback_url: str = app.credentials.get("base_url")
channel_list: Dict[str, List[Video]] = {}
read_list: List[Video] = []
scheduler = app.scheduler
http = AsyncClient()

get_option = _get_option(app, "youtube")


@app.on_startup
async def startup():
    await load_state()


@app.on_shutdown
async def shutdown():
    await dump_state()


@app.scheduled("interval", minutes=1)
async def state_snapshot():
    await dump_state()