almost final app
This commit is contained in:
22
app/app.py
22
app/app.py
@@ -4,6 +4,8 @@ import os
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
@@ -217,7 +219,27 @@ def initialize_playlist():
|
||||
download_playlist_files_from_server()
|
||||
Logger.info("Playlist initialization complete.")
|
||||
|
||||
# Function to check for playlist updates every 5 minutes
|
||||
def periodic_playlist_check():
|
||||
while True:
|
||||
try:
|
||||
Logger.info("Checking for playlist updates...")
|
||||
# Download the playlist files from the server
|
||||
download_playlist_files_from_server()
|
||||
# Create the updated playlist with local file paths
|
||||
create_updated_playlist()
|
||||
Logger.info("Playlist check complete.")
|
||||
except Exception as e:
|
||||
Logger.error(f"Error during playlist check: {e}")
|
||||
time.sleep(300) # Wait for 5 minutes (300 seconds) before checking again
|
||||
|
||||
# Start the periodic playlist check in a background thread
|
||||
def start_playlist_check_thread():
|
||||
thread = threading.Thread(target=periodic_playlist_check, daemon=True)
|
||||
thread.start()
|
||||
|
||||
if __name__ == '__main__':
|
||||
initialize_playlist() # Check and download playlist on startup
|
||||
create_updated_playlist() # Create the updated playlist
|
||||
start_playlist_check_thread() # Start the background thread for periodic checks
|
||||
app.run(host='0.0.0.0', port=1025)
|
||||
Reference in New Issue
Block a user