Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
blastbeng committed Sep 26, 2024
1 parent 67d7aa3 commit 22e2e9e
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 204 deletions.
8 changes: 6 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ class Config(object):
"""All application configurations"""

# Secret key
SECRET_KEY = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(128))
SECRET_KEY = ''.join(
random.choice(
string.ascii_lowercase +
string.digits) for _ in range(128))
SCHEDULER_API_ENABLED = True
SCHEDULER_API_PREFIX = "/api/v1/scheduler"

# Database configurations
SQLALCHEMY_DATABASE_NAME = 'spotisub.sqlite3'
SQLALCHEMY_DATABASE_PATH = 'sqlite:///' + os.path.join(basedir, 'cache')
SQLALCHEMY_DATABASE_URI = os.path.join(SQLALCHEMY_DATABASE_PATH, SQLALCHEMY_DATABASE_NAME)
SQLALCHEMY_DATABASE_URI = os.path.join(
SQLALCHEMY_DATABASE_PATH, SQLALCHEMY_DATABASE_NAME)
SQLALCHEMY_TRACK_MODIFICATIONS = False
7 changes: 3 additions & 4 deletions init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
from dotenv import load_dotenv
import spotipy
from spotipy import SpotifyOAuth
from spotisub.core.external.utils.constants import constants

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

client_id = os.environ.get(constants.SPOTIPY_CLIENT_ID)
client_secret = os.environ.get(constants.SPOTIPY_CLIENT_SECRET)
redirect_uri = os.environ.get(constants.SPOTIPY_REDIRECT_URI)
client_id = os.environ.get("SPOTIPY_CLIENT_ID")
client_secret = os.environ.get("SPOTIPY_CLIENT_SECRET")
redirect_uri = os.environ.get("SPOTIPY_REDIRECT_URI")
SCOPE = "user-top-read,user-library-read,user-read-recently-played"

creds = SpotifyOAuth(
Expand Down
4 changes: 1 addition & 3 deletions spotisub/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Spotisub init module"""
from spotisub import routes, classes, errors
import logging
import os

Expand Down Expand Up @@ -32,6 +33,3 @@
configuration_db = SQLAlchemy(spotisub)
login = LoginManager(spotisub)
login.login_view = 'login'


from spotisub import routes, classes, errors
8 changes: 6 additions & 2 deletions spotisub/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash


class ComparisonHelper:
def __init__(self, track, artist_spotify, found,
excluded, song_ids, track_helper):
Expand All @@ -14,15 +15,18 @@ def __init__(self, track, artist_spotify, found,
self.song_ids = song_ids
self.track_helper = track_helper


@login.user_loader
def load_user(id):
"""Load user by their ID"""
return User.query.get(int(id))


class User(configuration_db.Model, UserMixin):
"""User table"""
id = configuration_db.Column(configuration_db.Integer, primary_key=True)
username = configuration_db.Column(configuration_db.String(32), unique=True, index=True)
username = configuration_db.Column(
configuration_db.String(32), unique=True, index=True)
password_hash = configuration_db.Column(configuration_db.String(128))

def __repr__(self):
Expand All @@ -34,4 +38,4 @@ def set_password(self, password):

def check_password(self, password):
"""Confirms a user's password"""
return check_password_hash(self.password_hash, password)
return check_password_hash(self.password_hash, password)
16 changes: 8 additions & 8 deletions spotisub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SPLIT_TOKENS = ["(", "-", "feat"]


#Configuration constants
# Configuration constants
ARTIST_GEN_SCHED = "ARTIST_GEN_SCHED"
ARTIST_TOP_GEN_SCHED = "ARTIST_GEN_SCHED"
EXCLUDED_WORDS = "EXCLUDED_WORDS"
Expand Down Expand Up @@ -31,7 +31,7 @@
SUBSONIC_API_PASS = "SUBSONIC_API_PASS"
SUBSONIC_API_PORT = "SUBSONIC_API_PORT"

#Default configuration values constants
# Default configuration values constants
ARTIST_GEN_SCHED_DEFAULT_VALUE = "1"
ARTIST_TOP_GEN_SCHED_DEFAULT_VALUE = "1"
EXCLUDED_WORDS_DEFAULT_VALUE = "acoustic,instrumental,demo"
Expand All @@ -54,9 +54,9 @@
SUBSONIC_API_BASE_URL_DEFAULT_VALUE = ""


#Scheduler constants
JOB_AR_ID='artist_recommendations'
JOB_ATT_ID='artist_top_tracks'
JOB_MR_ID='my_recommendations'
JOB_UP_ID='user_playlists'
JOB_ST_ID='saved_tracks'
# Scheduler constants
JOB_AR_ID = 'artist_recommendations'
JOB_ATT_ID = 'artist_top_tracks'
JOB_MR_ID = 'my_recommendations'
JOB_UP_ID = 'user_playlists'
JOB_ST_ID = 'saved_tracks'
Loading

0 comments on commit 22e2e9e

Please sign in to comment.