From 98efbdb0fd705be84fe5dc310ce7d3f8e74cf6ff Mon Sep 17 00:00:00 2001 From: deflax Date: Thu, 6 Feb 2025 01:18:13 +0000 Subject: [PATCH] Define the rec command --- config/api/epg.json | 4 ++-- src/api/api.py | 2 +- src/api/requirements.txt | 2 +- src/discordbot/discordbot.py | 28 +++++++++++++++++++++------- src/{api => }/ffmpeg-ideas.md | 0 src/icecast/Dockerfile | 2 +- 6 files changed, 26 insertions(+), 12 deletions(-) rename src/{api => }/ffmpeg-ideas.md (100%) diff --git a/config/api/epg.json b/config/api/epg.json index 15e585a..542f309 100644 --- a/config/api/epg.json +++ b/config/api/epg.json @@ -17,11 +17,11 @@ { "name": "Deflax Records", "start_at": "now", - "prio": 2 + "prio": 1 }, { "name": "Deflax Mobile", "start_at": "now", - "prio": 2 + "prio": 1 } ] diff --git a/src/api/api.py b/src/api/api.py index 4b27560..c1037b0 100644 --- a/src/api/api.py +++ b/src/api/api.py @@ -261,7 +261,7 @@ def hls_converter(): if entry.lower().endswith('.mp4'): input_file = file_path break - logger_job.warning(f'{input_file} found. Converting to HLS...') + #logger_job.warning(f'{input_file} found. Converting to HLS...') except Exception as e: logger_job.error(e) diff --git a/src/api/requirements.txt b/src/api/requirements.txt index 2dcd387..600b810 100644 --- a/src/api/requirements.txt +++ b/src/api/requirements.txt @@ -8,4 +8,4 @@ Jinja2==3.1.5 MarkupSafe==3.0.2 waitress==3.0.2 Werkzeug==3.1.3 -python-ffmpeg==2.0.12 +python-ffmpeg==2.0.12 \ No newline at end of file diff --git a/src/discordbot/discordbot.py b/src/discordbot/discordbot.py index 8bcd16b..f28457e 100644 --- a/src/discordbot/discordbot.py +++ b/src/discordbot/discordbot.py @@ -1,11 +1,12 @@ -import asyncio -import os from datetime import datetime, timezone +import os +import asyncio +import logging +import subprocess import requests import discord from discord.ext.commands import Bot, has_permissions, CheckFailure, has_role, MissingRole from apscheduler.schedulers.asyncio import AsyncIOScheduler -import logging # Read env variables bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token') @@ -25,6 +26,7 @@ intents.message_content = True # Discord client bot = Bot(command_prefix=".", intents=intents) worshipper_role_name = "worshipper" +boss_role_name = "bosmang" # Scheduler scheduler = AsyncIOScheduler() @@ -56,6 +58,10 @@ async def hello_error(ctx, error): author_name = ctx.author.name await ctx.channel.send(f'do I know you, `{author_name}`?') +@bot.command(name='time', help='Show current time') +async def time(ctx): + await ctx.channel.send(f'The time is: `{datetime.now(timezone.utc)} UTC`') + @bot.command(name='epg', help='Lists scheduled streams') async def epg(ctx): global database @@ -74,16 +80,24 @@ async def epg(ctx): await ctx.channel.send(f'```{live_list}```') else: await ctx.channel.send('```Empty.```') - -@bot.command(name='time', help='Show current time') -async def time(ctx): - await ctx.channel.send(f'The time is: `{datetime.now(timezone.utc)} UTC`') @bot.command(name='now', help='Displays whats playing right now') async def now(ctx): head = await query_playhead() await ctx.channel.send(head) +@bot.command(name='rec', help='Start the recorder') +@has_role(boss_role_name) +async def rec(ctx): + await ctx.channel.send(f'soon...') + +@rec.error +async def rec_error(ctx, error): + if isinstance(error, CheckFailure): + author_name = ctx.author.name + await ctx.channel.send(f'{author_name} access denied') + +# Helper functions async def query_playhead(): head_url = f'https://{scheduler_hostname}/playhead' if requests.get(head_url).status_code == 200: diff --git a/src/api/ffmpeg-ideas.md b/src/ffmpeg-ideas.md similarity index 100% rename from src/api/ffmpeg-ideas.md rename to src/ffmpeg-ideas.md diff --git a/src/icecast/Dockerfile b/src/icecast/Dockerfile index abbcde7..1775965 100644 --- a/src/icecast/Dockerfile +++ b/src/icecast/Dockerfile @@ -13,4 +13,4 @@ RUN useradd radio ;\ ADD ./start.sh /start.sh -CMD ["/start.sh"] +CMD ["/start.sh"] \ No newline at end of file