mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-09 12:37:22 +00:00
minor refactoring
This commit is contained in:
parent
093c64f534
commit
8b25fc4844
@ -16,7 +16,7 @@ def initialize() -> None:
|
|||||||
Runs all the necessary setup functions.
|
Runs all the necessary setup functions.
|
||||||
"""
|
"""
|
||||||
helpers.create_config_dir()
|
helpers.create_config_dir()
|
||||||
helpers.check_for_new_songs()
|
helpers.reindex_tracks()
|
||||||
helpers.start_watchdog()
|
helpers.start_watchdog()
|
||||||
|
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ def get_artist_data(artist: str):
|
|||||||
|
|
||||||
|
|
||||||
@bp.route("/f/<folder>")
|
@bp.route("/f/<folder>")
|
||||||
@cache.cached()
|
# @cache.cached(30)
|
||||||
def get_folder_tree(folder: str):
|
def get_folder_tree(folder: str):
|
||||||
"""
|
"""
|
||||||
Returns a list of all the folders and tracks in the given folder.
|
Returns a list of all the folders and tracks in the given folder.
|
||||||
@ -291,7 +291,10 @@ def send_track_file(track_id):
|
|||||||
"""
|
"""
|
||||||
Returns an audio file that matches the passed id to the client.
|
Returns an audio file that matches the passed id to the client.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
|
filepath = instances.songs_instance.get_song_by_id(track_id)['filepath']
|
||||||
|
return send_file(filepath, mimetype="audio/mp3")
|
||||||
|
except FileNotFoundError:
|
||||||
|
return "File not found", 404
|
||||||
|
|
||||||
filepath = instances.songs_instance.get_song_by_id(track_id)['filepath']
|
|
||||||
|
|
||||||
return send_file(filepath, mimetype="audio/mp3")
|
|
||||||
|
@ -42,7 +42,7 @@ def populate():
|
|||||||
instances.songs_instance.insert_song(tags)
|
instances.songs_instance.insert_song(tags)
|
||||||
|
|
||||||
api.all_the_f_music = helpers.get_all_songs()
|
api.all_the_f_music = helpers.get_all_songs()
|
||||||
|
|
||||||
print("\n check done")
|
print("\n check done")
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def background(func):
|
|||||||
|
|
||||||
|
|
||||||
@background
|
@background
|
||||||
def check_for_new_songs():
|
def reindex_tracks():
|
||||||
"""
|
"""
|
||||||
Checks for new songs every 5 minutes.
|
Checks for new songs every 5 minutes.
|
||||||
"""
|
"""
|
||||||
@ -48,6 +48,9 @@ def check_for_new_songs():
|
|||||||
|
|
||||||
@background
|
@background
|
||||||
def start_watchdog():
|
def start_watchdog():
|
||||||
|
"""
|
||||||
|
Starts the file watcher.
|
||||||
|
"""
|
||||||
watchdoge.watch.run()
|
watchdoge.watch.run()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user