Currently Playing
+No song playing
+ +Queue
+ +-
+
+
diff --git a/main1.py b/main1.py index df6cf4b..568dc04 100644 --- a/main1.py +++ b/main1.py @@ -19,6 +19,10 @@ music_directory = os.path.expanduser('~/Music') # Adjust path as necessary def index(): return render_template('manage1.html') +@app.route('/admin') +def index(): + return render_template('manage1.html') + @app.route('/display') def display(): return render_template('display1.html') diff --git a/main3.py b/main3.py new file mode 100644 index 0000000..cc70c69 --- /dev/null +++ b/main3.py @@ -0,0 +1,72 @@ +from flask import Flask, render_template +from flask_socketio import SocketIO, emit +from flask_cors import CORS +import yt_dlp +import vlc +import time +import os +import eyed3 + +home_directory = os.path.expanduser("~") +#app = Flask(__name__,template_folder=home_directory) +app = Flask(__name__, template_folder=(home_directory + "/Code/GR/GR-Jukebox")) +socketio = SocketIO(app, cors_allowed_origins="*") +CORS(app) +player = vlc.MediaPlayer() +music_queue = [] +title_queue = [] +music_directory = os.path.expanduser('~/Music') + +@app.route('/') +def index(): + return render_template('manage1.html') + +@app.route('/display') +def display(): + return render_template('display1.html') + +@socketio.on('list_music') +def list_music(): + music_files = [] + for filename in os.listdir(music_directory): + if filename.endswith('.mp3'): + path = os.path.join(music_directory, filename) + audiofile = eyed3.load(path) + title = audiofile.tag.title if audiofile.tag else 'Unknown Title' + music_files.append({'id': filename.split('.')[0], 'title': title}) + emit('music_list', music_files) + +@socketio.on('download') +def download(data): + url = data['youtube_url'] + # ... existing download logic ... + emit('download_status', {'status': 'success', 'message': 'Song added successfully'}) + +@socketio.on('play') +def play(data): + global playing_thread + music_queue.append(data['songId']) + title_queue.append(data['songTitle']) + if not playing_thread: + # ... existing play logic ... + emit('play_status', {'status': 'success', 'message': 'Playing song'}) + +@socketio.on('get_queue') +def get_queue(): + emit('queue', [{'id': idx, 'title': title} for idx, title in enumerate(title_queue)]) + +@socketio.on('remove_from_queue') +def remove_from_queue(data): + song_id = int(data['songId']) + # ... existing remove logic ... + emit('remove_status', {'status': 'success', 'message': 'Song removed successfully'}) + +@socketio.on('current') +def current(): + if len(title_queue) > 0: + emit('current_song', {'title': title_queue[0]}) + else: + emit('current_song', {'title': 'Nothing is playing'}) + +if __name__ == "__main__": + socketio.run(app, host='0.0.0.0', debug=True, port=5000) diff --git a/music-dashboard.html b/music-dashboard.html new file mode 100644 index 0000000..72d6744 --- /dev/null +++ b/music-dashboard.html @@ -0,0 +1,890 @@ + + + +
+ + +No song playing
+ +