almost final app

This commit is contained in:
2025-05-11 19:18:28 +03:00
parent 3ca470f6e1
commit 9790d8be36
4 changed files with 122 additions and 33 deletions

View File

@@ -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)