From 90ba460c6d5f21bd23a2135f1056201f5cf7b6a8 Mon Sep 17 00:00:00 2001 From: kijk2869 Date: Sun, 27 Sep 2020 21:32:45 +0900 Subject: [PATCH] feat(config): add extra extractor option --- discodo/__main__.py | 26 +++++++++++++++++++++++++- discodo/client/voice_client.py | 3 ++- discodo/server/events.py | 4 +++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/discodo/__main__.py b/discodo/__main__.py index 18e3b594..967abf20 100644 --- a/discodo/__main__.py +++ b/discodo/__main__.py @@ -10,8 +10,8 @@ from hypercorn.config import Config as hypercornConfig from websockets import auth -from .config import Config from . import __version__ +from .config import Config log = logging.getLogger("discodo") @@ -182,6 +182,27 @@ def is_valid_file(parser, args): help="seconds to cleanup player when connection of discord terminated (default: 300)", ) +extExtractorParser = parser.add_argument_group("Extra Extractor Option") + +extExtractorParser.add_argument( + "--enabled-extractor", + action="append", + default=[], + help="Extra extractors to enable (Support melon and spotify)", +) +extExtractorParser.add_argument( + "--spotify-id", + type=str, + default=None, + help="Spotify API id (default: None)", +) +extExtractorParser.add_argument( + "--spotify-secret", + type=str, + default=None, + help="Spotify API secret (default: None)", +) + logParser = parser.add_argument_group("Logging Option") logParser.add_argument( @@ -204,6 +225,9 @@ def is_valid_file(parser, args): Config.DEFAULT_GAPLESS = args.default_gapless Config.BUFFERLIMIT = args.bufferlimit Config.VCTIMEOUT = args.timeout + Config.ENABLED_EXT_EXTRACTOR = args.enabled_extractor + Config.SPOTIFY_ID = args.spotify_id + Config.SPOTIFY_SECRET = args.spotify_secret else: verbose = args.config.pop("verbose", False) diff --git a/discodo/client/voice_client.py b/discodo/client/voice_client.py index 08088ad5..6e0e5b95 100644 --- a/discodo/client/voice_client.py +++ b/discodo/client/voice_client.py @@ -1,4 +1,5 @@ import asyncio + from ..utils import EventDispatcher @@ -131,4 +132,4 @@ async def lyricsDone(Data): return Data async def destroy(self) -> dict: - return await self.query("VC_DESTROY", Event="VC_DESTROYED") \ No newline at end of file + return await self.query("VC_DESTROY", Event="VC_DESTROYED") diff --git a/discodo/server/events.py b/discodo/server/events.py index 3c6650cf..661b9309 100644 --- a/discodo/server/events.py +++ b/discodo/server/events.py @@ -1,6 +1,8 @@ import asyncio import uuid + from discodo.source import SubtitleSource + from ..errors import NotConnected, NotPlaying from ..source import AudioData from ..status import getStatus @@ -384,4 +386,4 @@ async def requestSubtitle(self, Data: dict) -> None: "language": Data["language"], }, } - return await self.sendJson(payload) \ No newline at end of file + return await self.sendJson(payload)