From a1484c572c278fc1fc8c1e32a1ea38131025c1c1 Mon Sep 17 00:00:00 2001 From: codey Date: Tue, 18 Feb 2025 13:59:17 -0500 Subject: [PATCH] small refactor --- base.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/base.py b/base.py index 613a5b3..dbf9ee3 100644 --- a/base.py +++ b/base.py @@ -74,25 +74,23 @@ End Blacklisted Routes Actionable Routes """ -randmsg_endpoint = importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants) -transcription_endpoints = importlib.import_module("endpoints.transcriptions").Transcriptions(app, util, constants) -ai_endpoints = importlib.import_module("endpoints.ai").AI(app, util, constants) -# Below also provides: /lyric_cache_list/ (in addition to /lyric_search/) -lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants) -# Below provides numerous LastFM-fed endpoints -lastfm_endpoints = importlib.import_module("endpoints.lastfm").LastFM(app, util, constants) -# Below: YT endpoint(s) -yt_endpoints = importlib.import_module("endpoints.yt").YT(app, util, constants) -# Below: XC endpoint(s) -xc_endpoints = importlib.import_module("endpoints.xc").XC(app, util, constants) -# Below: Karma endpoint(s) -karma_endpoints = importlib.import_module("endpoints.karma").Karma(app, util, constants) -# Below: Radio endpoint(s) - in development, sporadically loaded as needed -radio_endpoints = importlib.import_module("endpoints.radio").Radio(app, util, constants) -# Below: Misc endpoints -misc_endpoints = importlib.import_module("endpoints.misc").Misc(app, util, constants, radio_endpoints) -# Below: Mgr Endpoints -mgr_endpoints = importlib.import_module("endpoints.mgr.mgr_test").Mgr(app, util, constants) +routes: dict = { + 'randmsg': importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants), + 'transcriptions': importlib.import_module("endpoints.transcriptions").Transcriptions(app, util, constants), + 'ai': importlib.import_module("endpoints.ai").AI(app, util, constants), + 'lyrics': importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants), + 'lastfm': importlib.import_module("endpoints.lastfm").LastFM(app, util, constants), + 'yt': importlib.import_module("endpoints.yt").YT(app, util, constants), + 'xc': importlib.import_module("endpoints.xc").XC(app, util, constants), + 'karma': importlib.import_module("endpoints.karma").Karma(app, util, constants), + 'radio': importlib.import_module("endpoints.radio").Radio(app, util, constants), + 'mgr': importlib.import_module("endpoints.mgr.mgr_test").Mgr(app, util, constants), +} + +# Misc endpoint depends on radio endpoint instance +radio_endpoint = routes.get('radio') +if radio_endpoint: + routes['misc'] = importlib.import_module("endpoints.misc").Misc(app, util, constants, radio_endpoint) """ End Actionable Routes @@ -103,5 +101,5 @@ End Actionable Routes Startup """ redis = redis_cache.RedisCache() -asyncio.get_event_loop().create_task( +loop.create_task( redis.create_index()) \ No newline at end of file