swingmusic/server/app/api/__init__.py
geoffrey45 d98cc0547e Save complete tracks and albums to the db for faster startup
- refactor function locations
- add logger
- check for new tracks instead of re-processing all files
2022-04-21 10:16:45 +03:00

39 lines
1.0 KiB
Python

"""
This module contains all the Flask Blueprints and API routes. It also contains all the globals list
that are used through-out the app. It handles the initialization of the watchdog,
checking and creating config dirs and starting the re-indexing process using a background thread.
"""
from typing import List, Set
from app import models, instances
from app import functions, helpers, prep
from app.lib import albumslib
from app.lib import folderslib
from app.lib import playlistlib
DB_TRACKS = instances.tracks_instance.get_all_tracks()
VALID_FOLDERS: Set[str] = set()
ALBUMS: List[models.Album] = []
TRACKS: List[models.Track] = []
PLAYLISTS: List[models.Playlist] = []
FOLDERS: Set[models.Folder] = set()
@helpers.background
def initialize() -> None:
"""
Runs all the necessary setup functions.
"""
functions.start_watchdog()
prep.create_config_dir()
albumslib.create_everything()
folderslib.run_scandir()
playlistlib.create_all_playlists()
functions.reindex_tracks()
initialize()