Files
conjurer/spotify_dl/scaffold.py
T
gitea 0147b22000 Tag: 0.2
Intermediate commits (oldest → newest):
- Fixed version of spotify_dl
- I also modified yt_dlp. But I do not remember what I changed. Have fun
- Poprawiono obsluge rotowanych logow i troche ulepszono funkcje opowiadania o fabryczcce
- Fucking windows bugfix and playlist gen fix
2025-10-30 16:58:49 +01:00

64 lines
1.9 KiB
Python

import logging
from os import getenv
import sentry_sdk
from rich.logging import RichHandler
from rich.console import Console
__all__ = ["log", "setLogLevel", "get_tokens", "console"]
logging.basicConfig(
level=logging.INFO,
format="%(message)s",
datefmt="[%X]",
handlers=[RichHandler(show_level=False, show_time=False)],
)
console = Console()
log = logging.getLogger("sdl")
sentry_sdk.init(
"https://fc66a23d79634b9bba1690ea13e289f0@o321064.ingest.sentry.io/2383261"
)
def setLogLevel(level):
"""
Sets the log level of the global logger to the passed level
:param level: the log level
"""
logging.getLogger().setLevel(level)
def get_tokens():
"""
Checks if the required API keys for Spotify has been set.
:param name: Name to be cleaned up
:return string containing the cleaned name
"""
log.debug("Checking for tokens")
CLIENT_ID = getenv("SPOTIPY_CLIENT_ID")
CLIENT_SECRET = getenv("SPOTIPY_CLIENT_SECRET")
log.debug("Tokens fetched : %s %s ", CLIENT_ID, CLIENT_SECRET)
if CLIENT_ID is None or CLIENT_SECRET is None:
print(
"""
You need to set your Spotify API credentials. You can do this by
setting environment variables like so:
Linux:
export SPOTIPY_CLIENT_ID='your-spotify-client-id'
export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
Windows Powershell:
$env:SPOTIPY_CLIENT_ID='your-spotify-client-id'
$env:SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
Windows CMD:
set SPOTIPY_CLIENT_ID=your-spotify-client-id
set SPOTIPY_CLIENT_SECRET=your-spotify-client-secret
Get your credentials at
https://developer.spotify.com/dashboard
"""
)
return None
return CLIENT_ID, CLIENT_SECRET