added poll interval env
This commit is contained in:
5
main.py
5
main.py
@@ -1,6 +1,7 @@
|
||||
from discord.rpc import DiscordRPC
|
||||
from jellyfin.api_client import JellyfinApiClient
|
||||
from jellyfin.utils import to_rpc_payload
|
||||
from settings import settings
|
||||
import logging
|
||||
import time
|
||||
|
||||
@@ -17,11 +18,11 @@ def main():
|
||||
media_item = jellyfinApiClient.get_current_playback()
|
||||
if not media_item:
|
||||
discordRPC.clear()
|
||||
time.sleep(15)
|
||||
time.sleep(settings.poll_interval)
|
||||
continue
|
||||
|
||||
discordRPC.update(to_rpc_payload(media_item))
|
||||
time.sleep(15)
|
||||
time.sleep(settings.poll_interval)
|
||||
except KeyboardInterrupt:
|
||||
logging.info("Shutting down...")
|
||||
discordRPC.clear()
|
||||
|
||||
@@ -9,6 +9,8 @@ class Settings(BaseSettings):
|
||||
|
||||
discord_app_id: str = Field(..., env="DISCORD_APP_ID")
|
||||
|
||||
poll_interval: int = Field(15, env="POLL_INTERVAL") # default 15 seconds
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
||||
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user