updated tech stack for newer versions of python, removed pyaudio. refactored configuration into .env file and integration inside logic, removed repeat config reads
This commit is contained in:
@@ -12,28 +12,7 @@ from cogs.music.help import music_help
|
||||
|
||||
import spotipy
|
||||
from spotipy.oauth2 import SpotifyClientCredentials
|
||||
|
||||
|
||||
# Fix this pls
|
||||
|
||||
import json
|
||||
#from .. import config
|
||||
# Read data from JSON file in ./data/config.json
|
||||
def read_data():
|
||||
with open("./data/config.json", "r") as file:
|
||||
return json.load(file)
|
||||
|
||||
raise Exception("Could not load config data")
|
||||
|
||||
|
||||
def get_spotify_creds():
|
||||
data = read_data()
|
||||
data = data.get("spotify")
|
||||
|
||||
SCID = data.get("SCID")
|
||||
secret = data.get("SECRET")
|
||||
|
||||
return SCID, secret
|
||||
import config # Use centralized config
|
||||
|
||||
|
||||
|
||||
@@ -51,10 +30,13 @@ class music(commands.Cog):
|
||||
help_command.cog = self
|
||||
self.help_command = help_command
|
||||
|
||||
SCID, secret = get_spotify_creds()
|
||||
# Get Spotify credentials from centralized config
|
||||
spotify_id, spotify_secret = config.get_spotify_creds()
|
||||
# Authentication - without user
|
||||
client_credentials_manager = SpotifyClientCredentials(client_id=SCID,
|
||||
client_secret=secret)
|
||||
client_credentials_manager = SpotifyClientCredentials(
|
||||
client_id=spotify_id,
|
||||
client_secret=spotify_secret
|
||||
)
|
||||
|
||||
self.sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ import discord
|
||||
import asyncio
|
||||
|
||||
from .translate import search_song
|
||||
import config
|
||||
|
||||
db_path = "./data/music.db"
|
||||
# Get database path from centralized config
|
||||
db_path = config.get_db_path()
|
||||
|
||||
# Base FFmpeg options (will be modified by effects)
|
||||
BASE_FFMPEG_OPTS = {
|
||||
|
||||
Reference in New Issue
Block a user