Compare commits
29 Commits
cc32ee1d94
...
90bb9a1650
| Author | SHA1 | Date |
|---|---|---|
|
|
90bb9a1650 | |
|
|
0bb93c53a4 | |
|
|
bc36a00322 | |
|
|
637650a5ef | |
|
|
fd02e4c1d1 | |
|
|
1c85464a5f | |
|
|
f1eb43b325 | |
|
|
a458a85823 | |
|
|
ab3acf1279 | |
|
|
c4fd96289b | |
|
|
0930fc2c1c | |
|
|
a2ae329d54 | |
|
|
66e97aaf37 | |
|
|
a795680e99 | |
|
|
d8abd9661d | |
|
|
01f5806959 | |
|
|
74cd3625f3 | |
|
|
9721fbbc8a | |
|
|
b3fd00cb4d | |
|
|
4d0b54f7d6 | |
|
|
f3d012cbc6 | |
|
|
d0efc89e33 | |
|
|
136fa2fa74 | |
|
|
6506f7d153 | |
|
|
a7fe6a73c7 | |
|
|
fd7707eb74 | |
|
|
5f78213d92 | |
|
|
d4edb8bfec | |
|
|
b64d101f8a |
|
|
@ -0,0 +1,8 @@
|
|||
docker/
|
||||
music/
|
||||
data/
|
||||
*.org
|
||||
docker-compose.yml
|
||||
Dockerfile*
|
||||
Makefile
|
||||
.git/
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
FROM debian:bookworm-slim AS builder
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y curl openssl ca-certificates \
|
||||
git make sbcl rlwrap && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy asteroid source to container workdir
|
||||
COPY . .
|
||||
|
||||
# Download Quicklisp installer
|
||||
RUN curl -O https://beta.quicklisp.org/quicklisp.lisp
|
||||
|
||||
# Installs quicklisp and radiance
|
||||
RUN sbcl --eval "(load \"quicklisp.lisp\")" \
|
||||
--eval "(quicklisp-quickstart:install)" \
|
||||
--eval "(ql-dist:install-dist \"http://dist.shirakumo.org/shirakumo.txt\" :prompt nil)" \
|
||||
--eval "(ql:quickload :radiance)"
|
||||
|
||||
# Makes the project workdir known as a quicklisp project
|
||||
RUN mkdir -p $HOME/.config/common-lisp/source-registry.conf.d
|
||||
RUN echo '(:tree "/app/")' >> "$HOME/.config/common-lisp/source-registry.conf.d/projects.conf"
|
||||
|
||||
# Builds Asteroid binary
|
||||
RUN make
|
||||
|
||||
# Links binary to path
|
||||
ENV PATH="$PATH:/app"
|
||||
|
||||
# Adds radiance system configuration file
|
||||
COPY docker/radiance-default.conf.lisp $HOME/.config/radiance/default/radiance-core/radiance-core.conf.lisp
|
||||
|
||||
# Application
|
||||
EXPOSE 8080
|
||||
# Slynk server
|
||||
EXPOSE 4009
|
||||
|
||||
ENV ASTEROID_STREAM_URL=http://localhost:8000
|
||||
|
||||
CMD [ "asteroid" ]
|
||||
491
README.org
491
README.org
|
|
@ -1,35 +1,45 @@
|
|||
#+TITLE: Asteroid Radio - Internet Streaming Implementation
|
||||
#+AUTHOR: Database Implementation Branch
|
||||
#+DATE: 2025-09-11
|
||||
#+TITLE: Asteroid Radio - Internet Radio Streaming Platform
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
This branch implements a complete internet radio streaming system for Asteroid Radio, transforming it from a simple web interface into a fully functional streaming radio station with live broadcasting capabilities.
|
||||
Asteroid Radio is a complete internet radio streaming platform built with Common Lisp, featuring a hacker-themed terminal aesthetic. The project combines the Radiance web framework with Icecast/Liquidsoap streaming infrastructure to create a full-featured music streaming platform with live broadcasting capabilities.
|
||||
|
||||
** Project Links
|
||||
- *Repository*: https://github.com/fade/asteroid
|
||||
- *IRC*: #asteroid.music on irc.libera.chat
|
||||
- *Documentation*: See =docs/= directory for comprehensive guides
|
||||
|
||||
* Key Features
|
||||
|
||||
** Live Internet Radio Streaming
|
||||
- Continuous MP3 streaming at 128kbps stereo
|
||||
- Professional audio processing with crossfading and normalization
|
||||
- Multiple quality streams: 128kbps MP3, 96kbps AAC, 64kbps MP3
|
||||
- Professional audio processing with crossfading and ReplayGain normalization
|
||||
- Icecast2 streaming server integration
|
||||
- Liquidsoap audio pipeline for reliable broadcasting
|
||||
- Stream queue control for curated programming
|
||||
|
||||
** Music Library Management
|
||||
- Database-backed track storage with metadata extraction
|
||||
- Support for MP3, FLAC, OGG, and WAV formats
|
||||
- Automatic metadata extraction using taglib
|
||||
- Track search, filtering, and sorting capabilities
|
||||
- Track search, filtering, sorting, and pagination
|
||||
- Recursive directory scanning
|
||||
|
||||
** Web Interface
|
||||
- RADIANCE framework with CLIP templating
|
||||
- Admin dashboard for library management
|
||||
- Web player with HTML5 audio controls
|
||||
- Admin dashboard for library and user management
|
||||
- Multiple player modes: inline, pop-out, and persistent frameset
|
||||
- Live stream integration with embedded player
|
||||
- Responsive design for desktop and mobile
|
||||
- Role-based access control (Admin/DJ/Listener)
|
||||
|
||||
** Network Broadcasting
|
||||
- WSL-compatible networking for internal network access
|
||||
- Dynamic stream URL detection for multi-environment support
|
||||
- Professional streaming URLs for media players
|
||||
- Multi-listener support via Icecast2
|
||||
- Docker-based deployment for easy setup
|
||||
|
||||
* Architecture Changes
|
||||
|
||||
|
|
@ -40,46 +50,82 @@ This branch implements a complete internet radio streaming system for Asteroid R
|
|||
- Database abstraction layer for track storage
|
||||
|
||||
** Streaming Stack
|
||||
- *Icecast2*: Streaming server (port 8000)
|
||||
- *Liquidsoap*: Audio processing and streaming pipeline
|
||||
- *Icecast2*: Streaming server (port 8000) - Docker containerized
|
||||
- *Liquidsoap*: Audio processing and streaming pipeline - Docker containerized
|
||||
- *RADIANCE*: Web server and API (port 8080)
|
||||
- *Database*: Track metadata and playlist storage
|
||||
- *PostgreSQL*: Database backend (configured, ready for migration)
|
||||
- *Docker Compose*: Container orchestration
|
||||
|
||||
** File Structure
|
||||
#+BEGIN_SRC
|
||||
asteroid/
|
||||
├── asteroid.lisp # Main server with RADIANCE routes
|
||||
├── asteroid.asd # System definition with dependencies
|
||||
├── asteroid-radio.liq # Liquidsoap streaming configuration
|
||||
├── playlist.m3u # Generated playlist for streaming
|
||||
├── start-asteroid-radio.sh # Launch script for all services
|
||||
├── stop-asteroid-radio.sh # Stop script for all services
|
||||
├── stream-control.lisp # Stream queue management
|
||||
├── user-management.lisp # User administration
|
||||
├── playlist-management.lisp # Playlist operations
|
||||
├── test-server.sh # Automated test suite
|
||||
├── docker/ # Docker infrastructure
|
||||
│ ├── docker-compose.yml # Container orchestration
|
||||
│ ├── asteroid-radio-docker.liq # Liquidsoap config
|
||||
│ ├── icecast.xml # Icecast configuration
|
||||
│ └── music/ # Music library mount
|
||||
├── template/ # CLIP HTML templates
|
||||
│ ├── front-page.chtml # Main page with live stream
|
||||
│ ├── admin.chtml # Admin dashboard
|
||||
│ └── player.chtml # Web player interface
|
||||
│ ├── player.chtml # Web player interface
|
||||
│ └── users.chtml # User management
|
||||
├── static/ # CSS and assets
|
||||
│ └── asteroid.lass # LASS stylesheet
|
||||
└── music/ # Music library
|
||||
├── incoming/ # Upload staging area
|
||||
└── library/ # Processed music files
|
||||
├── docs/ # Comprehensive documentation
|
||||
│ ├── README.org # Documentation index
|
||||
│ ├── PROJECT-OVERVIEW.org # Architecture overview
|
||||
│ ├── PROJECT-HISTORY.org # Development timeline
|
||||
│ ├── INSTALLATION.org # Setup guide
|
||||
│ └── ... # Additional guides
|
||||
└── music/ # Music library (local dev)
|
||||
#+END_SRC
|
||||
|
||||
* Track Upload Workflow
|
||||
* Quick Start
|
||||
|
||||
** Current Implementation (Manual Upload)
|
||||
1. *Copy files to staging*: Place MP3/FLAC files in =music/incoming/=
|
||||
2. *Access admin panel*: Navigate to =http://[IP]:8080/asteroid/admin=
|
||||
3. *Process files*: Click "Copy Files from Incoming" button
|
||||
4. *Database update*: Files are moved to =music/library/= and metadata extracted
|
||||
5. *Automatic playlist*: =playlist.m3u= is regenerated for streaming
|
||||
** Docker Installation (Recommended)
|
||||
#+BEGIN_SRC bash
|
||||
# Clone repository
|
||||
git clone https://github.com/fade/asteroid
|
||||
cd asteroid/docker
|
||||
|
||||
** File Processing Steps
|
||||
1. Files copied from =music/incoming/= to =music/library/=
|
||||
2. Metadata extracted using taglib (title, artist, album, duration, bitrate)
|
||||
3. Database record created with file path and metadata
|
||||
4. Playlist file updated for Liquidsoap streaming
|
||||
5. Files immediately available for on-demand streaming
|
||||
# Start all services
|
||||
docker compose up -d
|
||||
|
||||
# Verify streams are working
|
||||
curl -I http://localhost:8000/asteroid.mp3
|
||||
curl -I http://localhost:8000/asteroid.aac
|
||||
curl -I http://localhost:8000/asteroid-low.mp3
|
||||
#+END_SRC
|
||||
|
||||
** Access Points
|
||||
- *Web Interface*: http://localhost:8080/asteroid/
|
||||
- *Admin Panel*: http://localhost:8080/asteroid/admin
|
||||
- *High Quality MP3*: http://localhost:8000/asteroid.mp3 (128kbps)
|
||||
- *High Quality AAC*: http://localhost:8000/asteroid.aac (96kbps)
|
||||
- *Low Quality MP3*: http://localhost:8000/asteroid-low.mp3 (64kbps)
|
||||
- *Icecast Admin*: http://localhost:8000/admin/ (admin/asteroid_admin_2024)
|
||||
|
||||
* Music Library Management
|
||||
|
||||
** Adding Music
|
||||
1. *Copy files*: Place MP3/FLAC files in =docker/music/= directory
|
||||
2. *Access admin panel*: Navigate to =http://localhost:8080/asteroid/admin=
|
||||
3. *Scan library*: Click "Scan Library" to index new tracks
|
||||
4. *Metadata extraction*: Track information automatically extracted
|
||||
5. *Stream queue*: Optionally add tracks to broadcast queue
|
||||
|
||||
** Library Scanning
|
||||
1. Recursive directory scanning of music folder
|
||||
2. Metadata extracted using taglib (title, artist, album, duration)
|
||||
3. Database records created with file paths and metadata
|
||||
4. Tracks immediately available for playback and streaming
|
||||
5. Supports nested folder structures
|
||||
|
||||
** Supported Formats
|
||||
- *MP3*: Primary format, best compatibility
|
||||
|
|
@ -90,216 +136,259 @@ asteroid/
|
|||
* Icecast2 Integration
|
||||
|
||||
** Configuration
|
||||
- *Server*: localhost:8000
|
||||
- *Mount point*: =/asteroid.mp3=
|
||||
- *Password*: =b3l0wz3r0= (configured in Liquidsoap)
|
||||
- *Format*: MP3 128kbps stereo
|
||||
- *Server*: localhost:8000 (Docker container)
|
||||
- *Mount points*: =/asteroid.mp3=, =/asteroid.aac=, =/asteroid-low.mp3=
|
||||
- *Password*: =H1tn31EhsyLrfRmo= (configured in Docker setup)
|
||||
- *Formats*: MP3 128kbps, AAC 96kbps, MP3 64kbps
|
||||
|
||||
** Docker Setup
|
||||
Icecast2 runs in a Docker container - no manual installation needed.
|
||||
|
||||
** Installation (Ubuntu/Debian)
|
||||
#+BEGIN_SRC bash
|
||||
sudo apt update
|
||||
sudo apt install icecast2
|
||||
sudo systemctl enable icecast2
|
||||
sudo systemctl start icecast2
|
||||
# Managed via docker-compose
|
||||
cd docker
|
||||
docker compose up -d icecast
|
||||
#+END_SRC
|
||||
|
||||
** Stream Access
|
||||
- *Direct URL*: =http://[IP]:8000/asteroid.mp3=
|
||||
- *Admin interface*: =http://[IP]:8000/admin/=
|
||||
- *Statistics*: =http://[IP]:8000/status.xsl=
|
||||
- *High Quality MP3*: =http://localhost:8000/asteroid.mp3= (128kbps)
|
||||
- *High Quality AAC*: =http://localhost:8000/asteroid.aac= (96kbps)
|
||||
- *Low Quality MP3*: =http://localhost:8000/asteroid-low.mp3= (64kbps)
|
||||
- *Admin interface*: =http://localhost:8000/admin/= (admin/asteroid_admin_2024)
|
||||
- *Statistics*: =http://localhost:8000/status.xsl=
|
||||
|
||||
* Liquidsoap Integration
|
||||
|
||||
** Configuration File: =asteroid-radio.liq=
|
||||
#+BEGIN_SRC liquidsoap
|
||||
#!/usr/bin/liquidsoap
|
||||
** Docker Configuration
|
||||
Liquidsoap runs in a Docker container with configuration in =docker/asteroid-radio-docker.liq=
|
||||
|
||||
# Set log level for debugging
|
||||
settings.log.level := 4
|
||||
** Key Features
|
||||
- *Multiple outputs*: Generates 3 simultaneous streams (MP3 128k, AAC 96k, MP3 64k)
|
||||
- *Audio processing*: Crossfading, normalization, ReplayGain
|
||||
- *Stream queue*: Reads from M3U playlist for curated programming
|
||||
- *Telnet control*: Remote control interface on port 1234
|
||||
- *Metadata*: Broadcasts track information to listeners
|
||||
|
||||
# Create playlist from directory
|
||||
radio = playlist(mode="randomize", reload=3600, "/path/to/music/library/")
|
||||
|
||||
# Add audio processing
|
||||
radio = amplify(1.0, radio)
|
||||
|
||||
# Fallback with sine wave for debugging
|
||||
radio = fallback(track_sensitive=false, [radio, sine(440.0)])
|
||||
|
||||
# Output to Icecast2
|
||||
output.icecast(
|
||||
%mp3(bitrate=128),
|
||||
host="localhost",
|
||||
port=8000,
|
||||
password="b3l0wz3r0",
|
||||
mount="asteroid.mp3",
|
||||
name="Asteroid Radio",
|
||||
description="Music for Hackers - Streaming from the Asteroid",
|
||||
genre="Electronic/Alternative",
|
||||
url="http://localhost:8080/asteroid/",
|
||||
radio
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
** Installation (Ubuntu/Debian)
|
||||
** Management
|
||||
#+BEGIN_SRC bash
|
||||
sudo apt update
|
||||
sudo apt install liquidsoap
|
||||
# Start Liquidsoap container
|
||||
cd docker
|
||||
docker compose up -d liquidsoap
|
||||
|
||||
# View logs
|
||||
docker compose logs -f liquidsoap
|
||||
|
||||
# Restart streaming
|
||||
docker compose restart liquidsoap
|
||||
#+END_SRC
|
||||
|
||||
** Features
|
||||
- *Random playlist*: Shuffles music library continuously
|
||||
- *Auto-reload*: Playlist refreshes every hour
|
||||
- *Audio processing*: Amplification and normalization
|
||||
- *Fallback*: Sine tone if no music available (debugging)
|
||||
- *Metadata*: Station info broadcast to listeners
|
||||
|
||||
* Network Access
|
||||
|
||||
** Local Development
|
||||
- *Web Interface*: =http://localhost:8080/asteroid/=
|
||||
- *Live Stream*: =http://localhost:8000/asteroid.mp3=
|
||||
- *Admin Panel*: =http://localhost:8080/asteroid/admin=
|
||||
|
||||
** WSL Network Access
|
||||
- *WSL IP*: Check with =ip addr show eth0=
|
||||
- *Web Interface*: =http://[WSL-IP]:8080/asteroid/=
|
||||
- *Live Stream*: =http://[WSL-IP]:8000/asteroid.mp3=
|
||||
|
||||
** Internal Network Broadcasting
|
||||
- Services bind to all interfaces (0.0.0.0)
|
||||
- Accessible from any device on local network
|
||||
- Compatible with media players (VLC, iTunes, etc.)
|
||||
|
||||
* Usage Instructions
|
||||
|
||||
** Starting the Radio Station
|
||||
** Telnet Control
|
||||
#+BEGIN_SRC bash
|
||||
# Launch all services
|
||||
./start-asteroid-radio.sh
|
||||
# Connect to Liquidsoap
|
||||
telnet localhost 1234
|
||||
|
||||
# Or use netcat for scripting
|
||||
echo "request.queue" | nc localhost 1234
|
||||
echo "request.skip" | nc localhost 1234
|
||||
#+END_SRC
|
||||
|
||||
** Stopping the Radio Station
|
||||
#+BEGIN_SRC bash
|
||||
# Stop all services
|
||||
./stop-asteroid-radio.sh
|
||||
#+END_SRC
|
||||
* User Management
|
||||
|
||||
** Adding Music
|
||||
1. Copy MP3/FLAC files to =music/incoming/=
|
||||
2. Visit admin panel: =http://[IP]:8080/asteroid/admin=
|
||||
3. Click "Copy Files from Incoming"
|
||||
4. Files are processed and added to streaming playlist
|
||||
** Roles
|
||||
- *Admin*: Full system access, user management, stream control
|
||||
- *DJ*: Content management, playlist creation, library access
|
||||
- *Listener*: Basic playback and personal playlists
|
||||
|
||||
** Listening to the Stream
|
||||
- *Web Browser*: Visit main page for embedded player
|
||||
- *Media Player*: Open =http://[IP]:8000/asteroid.mp3=
|
||||
- *Mobile Apps*: Use internet radio apps with stream URL
|
||||
** Default Credentials
|
||||
- Username: =admin=
|
||||
- Password: =asteroid123=
|
||||
- ⚠️ Change default password after first login
|
||||
|
||||
** User Administration
|
||||
- Create/manage users via admin panel
|
||||
- Role-based access control
|
||||
- User profiles and preferences
|
||||
- Session management
|
||||
|
||||
* Player Modes
|
||||
|
||||
** Inline Player
|
||||
- Embedded in web pages
|
||||
- Standard HTML5 audio controls
|
||||
- Queue management
|
||||
|
||||
** Pop-Out Player
|
||||
- Standalone player window
|
||||
- Independent from main browser window
|
||||
- Persistent across page navigation
|
||||
|
||||
** Frameset Player
|
||||
- Bottom-frame persistent player
|
||||
- Audio continues during site navigation
|
||||
- Seamless listening experience
|
||||
|
||||
* API Endpoints
|
||||
|
||||
Asteroid Radio provides a comprehensive REST API with 15+ endpoints.
|
||||
|
||||
** Status & Authentication
|
||||
- =GET /api/asteroid/status= - Server status
|
||||
- =GET /api/asteroid/auth-status= - Authentication status
|
||||
- =GET /api/asteroid/icecast-status= - Streaming status
|
||||
|
||||
** Track Management
|
||||
- =GET /api/tracks= - List all tracks with metadata
|
||||
- =GET /tracks/{id}/stream= - Stream individual track
|
||||
- =POST /api/scan-library= - Scan and update music library
|
||||
- =POST /api/copy-files= - Process files from incoming directory
|
||||
- =GET /api/asteroid/tracks= - List all tracks
|
||||
- =GET /api/asteroid/admin/tracks= - Admin track listing
|
||||
- =POST /api/asteroid/admin/scan-library= - Scan music library
|
||||
|
||||
** Player Control
|
||||
- =POST /api/player/play= - Start playback
|
||||
- =POST /api/player/pause= - Pause playback
|
||||
- =POST /api/player/stop= - Stop playback
|
||||
- =GET /api/status= - Get server status
|
||||
- =GET /api/asteroid/player/status= - Player status
|
||||
- =POST /api/asteroid/player/play= - Play track
|
||||
- =POST /api/asteroid/player/pause= - Pause playback
|
||||
- =POST /api/asteroid/player/stop= - Stop playback
|
||||
- =POST /api/asteroid/player/resume= - Resume playback
|
||||
|
||||
** Search and Filter
|
||||
- =GET /api/tracks?search={query}= - Search tracks
|
||||
- =GET /api/tracks?sort={field}= - Sort by field
|
||||
- =GET /api/tracks?artist={name}= - Filter by artist
|
||||
** Playlist Management
|
||||
- =GET /api/asteroid/playlists= - List user playlists
|
||||
- =POST /api/asteroid/playlists/create= - Create playlist
|
||||
- =GET /api/asteroid/playlists/get= - Get playlist details
|
||||
- =POST /api/asteroid/playlists/add-track= - Add track to playlist
|
||||
|
||||
* Database Schema
|
||||
** Stream Queue Control (Admin)
|
||||
- =GET /api/asteroid/stream/queue= - Get broadcast queue
|
||||
- =POST /api/asteroid/stream/queue/add= - Add track to queue
|
||||
- =POST /api/asteroid/stream/queue/remove= - Remove from queue
|
||||
- =POST /api/asteroid/stream/queue/clear= - Clear queue
|
||||
|
||||
** Tracks Collection
|
||||
#+BEGIN_SRC lisp
|
||||
(db:create "tracks" '((title :text)
|
||||
(artist :text)
|
||||
(album :text)
|
||||
(duration :integer)
|
||||
(file-path :text)
|
||||
(format :text)
|
||||
(bitrate :integer)
|
||||
(added-date :integer)
|
||||
(play-count :integer)))
|
||||
#+END_SRC
|
||||
See =docs/API-ENDPOINTS.org= for complete API documentation.
|
||||
|
||||
** Playlists Collection (Future)
|
||||
#+BEGIN_SRC lisp
|
||||
(db:create "playlists" '((name :text)
|
||||
(description :text)
|
||||
(created-date :integer)
|
||||
(track-ids :text)))
|
||||
#+END_SRC
|
||||
* Database
|
||||
|
||||
** Current: Radiance DB
|
||||
- File-based database abstraction
|
||||
- Tracks, users, playlists, sessions
|
||||
- Suitable for development and small deployments
|
||||
|
||||
** PostgreSQL (Configured)
|
||||
- Docker container ready
|
||||
- Full schema defined
|
||||
- Migration pending
|
||||
- See =docs/POSTGRESQL-SETUP.org= for details
|
||||
|
||||
* Documentation
|
||||
|
||||
Comprehensive documentation available in the =docs/= directory:
|
||||
|
||||
- *README.org* - Documentation index
|
||||
- *PROJECT-OVERVIEW.org* - Architecture and features
|
||||
- *PROJECT-HISTORY.org* - Development timeline and milestones
|
||||
- *INSTALLATION.org* - Complete installation guide
|
||||
- *DEVELOPMENT.org* - Developer setup and guidelines
|
||||
- *DOCKER-STREAMING.org* - Docker streaming infrastructure
|
||||
- *API-ENDPOINTS.org* - REST API reference
|
||||
- *STREAM-CONTROL.org* - Stream queue management
|
||||
- *USER-MANAGEMENT-SYSTEM.org* - User administration
|
||||
- *PLAYLIST-SYSTEM.org* - Playlist functionality
|
||||
- *TESTING.org* - Automated testing guide
|
||||
- *POSTGRESQL-SETUP.org* - Database setup
|
||||
|
||||
* Dependencies
|
||||
|
||||
** Lisp Dependencies (asteroid.asd)
|
||||
- =:radiance= - Web framework
|
||||
- =:r-clip= - Templating system
|
||||
- =:lass= - CSS generation
|
||||
- =:cl-json= - JSON handling
|
||||
- =:alexandria= - Utilities
|
||||
- =:local-time= - Time handling
|
||||
** Lisp Dependencies
|
||||
- =radiance= - Web framework
|
||||
- =r-clip= - CLIP templating
|
||||
- =lass= - CSS preprocessing
|
||||
- =cl-json= - JSON handling
|
||||
- =alexandria= - Common Lisp utilities
|
||||
- =local-time= - Time handling
|
||||
- =taglib= - Audio metadata extraction
|
||||
|
||||
** System Dependencies
|
||||
- =icecast2= - Streaming server
|
||||
- =liquidsoap= - Audio processing
|
||||
- =taglib= - Metadata extraction (via audio-streams)
|
||||
** System Dependencies (Docker)
|
||||
- Docker Engine 20.10+
|
||||
- Docker Compose 2.0+
|
||||
- All streaming components containerized
|
||||
|
||||
* Development Notes
|
||||
* Testing
|
||||
|
||||
** RADIANCE Configuration
|
||||
- Domain: "asteroid"
|
||||
- Routes use =#@= syntax for URL patterns
|
||||
- Database abstraction via =db:= functions
|
||||
- CLIP templates with =data-text= attributes
|
||||
** Automated Test Suite
|
||||
#+BEGIN_SRC bash
|
||||
# Run comprehensive tests
|
||||
./test-server.sh
|
||||
|
||||
** Database Queries
|
||||
- Use quoted symbols for field names: =(:= '_id id)=
|
||||
- RADIANCE returns hash tables with string keys
|
||||
- Primary key is "_id" internally, "id" in JSON responses
|
||||
# Verbose mode
|
||||
./test-server.sh -v
|
||||
#+END_SRC
|
||||
|
||||
** Streaming Considerations
|
||||
- MP3 files with spaces in names require playlist.m3u approach
|
||||
- Liquidsoap fallback prevents stream silence
|
||||
- Icecast2 mount points must match Liquidsoap configuration
|
||||
** Test Coverage
|
||||
- 25+ automated tests
|
||||
- API endpoint validation
|
||||
- HTML page rendering
|
||||
- Static file serving
|
||||
- JSON response format
|
||||
- Authentication flows
|
||||
|
||||
* Future Enhancements
|
||||
* Contributing
|
||||
|
||||
** Planned Features
|
||||
- Playlist creation and management interface
|
||||
- Now-playing status tracking and display
|
||||
- Direct browser file uploads with progress
|
||||
- Listener statistics and analytics
|
||||
- Scheduled programming and automation
|
||||
** Development Workflow
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Run test suite
|
||||
5. Submit pull request
|
||||
|
||||
** Technical Improvements
|
||||
- WebSocket integration for real-time updates
|
||||
- Advanced audio processing options
|
||||
- Multi-bitrate streaming support
|
||||
- Mobile-responsive interface enhancements
|
||||
** Community
|
||||
- *IRC*: #asteroid.music on irc.libera.chat
|
||||
- *Issues*: GitHub issue tracker
|
||||
- *Discussions*: GitHub discussions
|
||||
|
||||
** Core Team
|
||||
- Brian O'Reilly (Fade) - Project founder
|
||||
- Glenn Thompson (glenneth) - Core developer
|
||||
- Luis Pereira - UI/UX
|
||||
|
||||
* Troubleshooting
|
||||
|
||||
** Common Issues
|
||||
- *No audio in stream*: Check Liquidsoap logs, verify MP3 files
|
||||
- *Database errors*: Ensure proper field name quoting in queries
|
||||
- *Network access*: Verify WSL IP and firewall settings
|
||||
- *File upload issues*: Check permissions on music directories
|
||||
** Docker Issues
|
||||
#+BEGIN_SRC bash
|
||||
# Check container status
|
||||
docker compose ps
|
||||
|
||||
** Debugging
|
||||
- Enable Liquidsoap debug logging: =settings.log.level := 4=
|
||||
- Check Icecast admin interface for stream status
|
||||
- Monitor RADIANCE logs for web server issues
|
||||
- Verify database connectivity and collections
|
||||
# View logs
|
||||
docker compose logs icecast
|
||||
docker compose logs liquidsoap
|
||||
|
||||
# Restart services
|
||||
docker compose restart
|
||||
#+END_SRC
|
||||
|
||||
** Stream Not Playing
|
||||
- Verify containers are running
|
||||
- Check music files exist in =docker/music/=
|
||||
- Test stream URLs with curl
|
||||
- Review Liquidsoap logs
|
||||
|
||||
** Database Issues
|
||||
- Check Radiance DB file permissions
|
||||
- Verify database collections exist
|
||||
- Review application logs
|
||||
|
||||
For detailed troubleshooting, see documentation in =docs/= directory.
|
||||
|
||||
* License
|
||||
|
||||
This implementation maintains compatibility with the original Asteroid Radio project license while adding comprehensive streaming capabilities for internet radio broadcasting.
|
||||
See LICENSE file for details.
|
||||
|
||||
* Acknowledgments
|
||||
|
||||
Built with:
|
||||
- Common Lisp (SBCL)
|
||||
- Radiance web framework
|
||||
- Icecast2 streaming server
|
||||
- Liquidsoap audio processing
|
||||
- Docker containerization
|
||||
|
||||
Special thanks to all contributors and the Common Lisp community.
|
||||
|
||||
---
|
||||
|
||||
*Last Updated: 2025-10-26*
|
||||
|
|
|
|||
|
|
@ -1,193 +0,0 @@
|
|||
#+TITLE: Session Notes - Page Flow Feature Implementation
|
||||
#+DATE: 2025-10-12
|
||||
#+AUTHOR: Glenn
|
||||
|
||||
* Session Objective
|
||||
Implement role-based page flow for Asteroid Radio application where:
|
||||
- Admin users are redirected to ~/asteroid/admin~ upon login
|
||||
- Regular users (listener, dj) are redirected to ~/asteroid/profile~ upon login
|
||||
- User registration redirects to ~/asteroid/profile~ page
|
||||
- Navigation links display conditionally based on authentication status and user role
|
||||
|
||||
* What Was Accomplished
|
||||
|
||||
** Core Feature: Role-Based Page Flow ✅
|
||||
- Implemented login redirect logic based on user role
|
||||
- Admin users → ~/asteroid/admin~ dashboard
|
||||
- Regular users → ~/asteroid/profile~ page
|
||||
- Registration flow → ~/asteroid/profile~ for new users
|
||||
- Session persistence across page navigation
|
||||
|
||||
** User Management API Endpoints ✅
|
||||
Converted user management endpoints to use Radiance's ~define-api~ standard:
|
||||
- ~/api/asteroid/users~ - Get all users (admin only)
|
||||
- ~/api/asteroid/user-stats~ - Get user statistics (admin only)
|
||||
- ~/api/asteroid/users/create~ - Create new user (admin only)
|
||||
|
||||
** Profile Page API Endpoints ✅
|
||||
Added new API endpoints for user profile functionality:
|
||||
- ~/api/asteroid/user/profile~ - Get current user profile information
|
||||
- ~/api/asteroid/user/listening-stats~ - Get user listening statistics (placeholder)
|
||||
- ~/api/asteroid/user/recent-tracks~ - Get recently played tracks (placeholder)
|
||||
- ~/api/asteroid/user/top-artists~ - Get top artists (placeholder)
|
||||
|
||||
** Authentication & Authorization Improvements ✅
|
||||
- Fixed ~require-role~ function to properly handle API requests
|
||||
- Added proper JSON error responses for authorization failures
|
||||
- Improved password verification with debug logging
|
||||
- Added ~reset-user-password~ function for admin use
|
||||
|
||||
** JavaScript API Response Handling ✅
|
||||
Fixed all JavaScript files to properly handle Radiance's ~api-output~ wrapper format:
|
||||
- Response structure: ~{status: 200, message: "Ok.", data: {...}}~
|
||||
- Updated all fetch calls to extract ~result.data~ before processing
|
||||
- Added fallback handling: ~const data = result.data || result~
|
||||
|
||||
* Files Modified
|
||||
|
||||
** Backend (Common Lisp)
|
||||
*** ~asteroid.lisp~
|
||||
- Added profile page API endpoints (~user/profile~, ~user/listening-stats~, ~user/recent-tracks~, ~user/top-artists~)
|
||||
- All endpoints use ~define-api~ and ~api-output~ for proper JSON responses
|
||||
- Added ~require-authentication~ checks for protected endpoints
|
||||
|
||||
*** ~auth-routes.lisp~
|
||||
- Fixed user management API endpoints to properly use ~api-output~
|
||||
- Updated ~/api/asteroid/users~ endpoint for proper JSON responses
|
||||
- Updated ~/api/asteroid/user-stats~ endpoint for proper JSON responses
|
||||
- Updated ~/api/asteroid/users/create~ endpoint for proper JSON responses
|
||||
- Added proper error handling with HTTP status codes (400, 404, 500)
|
||||
|
||||
*** ~user-management.lisp~
|
||||
- Modified ~require-role~ function to return ~nil~ for failed API authorization
|
||||
- Removed problematic ~radiance:api-output~ calls
|
||||
- Responsibility for JSON error responses moved to calling endpoints
|
||||
- Added debug logging for authentication flow
|
||||
|
||||
** Frontend (JavaScript)
|
||||
*** ~static/js/users.js~
|
||||
- Fixed ~loadUserStats()~ to handle ~api-output~ wrapper
|
||||
- Fixed ~loadUsers()~ to handle ~api-output~ wrapper
|
||||
- Fixed ~createNewUser()~ to handle ~api-output~ wrapper
|
||||
- Updated to properly extract ~result.data~ before processing
|
||||
|
||||
*** ~static/js/auth-ui.js~
|
||||
- Fixed ~checkAuthStatus()~ to handle ~api-output~ wrapper
|
||||
- Session persistence now working correctly across navigation
|
||||
- Conditional nav links display properly based on auth status
|
||||
|
||||
*** ~static/js/profile.js~
|
||||
- Fixed ~loadProfileData()~ to handle ~api-output~ wrapper
|
||||
- Fixed ~loadListeningStats()~ to handle ~api-output~ wrapper
|
||||
- Fixed ~loadRecentTracks()~ to handle ~api-output~ wrapper
|
||||
- Fixed ~loadTopArtists()~ to handle ~api-output~ wrapper
|
||||
- Added safe handling for empty arrays (no errors when no data)
|
||||
- Used optional chaining (~?.~) for safer DOM queries
|
||||
|
||||
** Documentation
|
||||
*** ~TODO.org~
|
||||
- Marked "Page Flow" section as complete [2/2] ✅
|
||||
- Updated notes to reflect working implementation
|
||||
|
||||
* Technical Details
|
||||
|
||||
** API Response Format
|
||||
All API endpoints now return responses in this format:
|
||||
#+BEGIN_SRC json
|
||||
{
|
||||
"status": 200,
|
||||
"message": "Ok.",
|
||||
"data": {
|
||||
"status": "success",
|
||||
"users": [...]
|
||||
}
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
JavaScript must extract the ~data~ property before processing.
|
||||
|
||||
** Authentication Flow
|
||||
1. User submits login form
|
||||
2. ~authenticate-user~ validates credentials
|
||||
3. Session field "user-id" is set
|
||||
4. User role is checked
|
||||
5. Redirect based on role:
|
||||
- ~:admin~ → ~/asteroid/admin~
|
||||
- ~:listener~ or ~:dj~ → ~/asteroid/profile~
|
||||
|
||||
** Authorization Pattern
|
||||
#+BEGIN_SRC lisp
|
||||
(define-api asteroid/endpoint () ()
|
||||
"API endpoint description"
|
||||
(require-role :admin) ; or (require-authentication)
|
||||
(handler-case
|
||||
(let ((data (get-some-data)))
|
||||
(api-output `(("status" . "success")
|
||||
("data" . ,data))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error: ~a" e)))
|
||||
:status 500))))
|
||||
#+END_SRC
|
||||
|
||||
* Testing Results
|
||||
|
||||
** Successful Tests
|
||||
- ✅ Admin login redirects to ~/asteroid/admin~
|
||||
- ✅ Regular user login redirects to ~/asteroid/profile~
|
||||
- ✅ User registration redirects to ~/asteroid/profile~
|
||||
- ✅ Session persists across page navigation
|
||||
- ✅ Nav links display correctly based on role (Profile/Admin/Logout vs Login/Register)
|
||||
- ✅ User statistics display correctly (3 users, 1 admin, 0 DJs)
|
||||
- ✅ "View All Users" table displays all users
|
||||
- ✅ "Create New User" functionality working
|
||||
- ✅ Profile page loads without errors
|
||||
- ✅ All API endpoints return proper JSON responses
|
||||
|
||||
** Test User Created
|
||||
- Username: ~testuser~
|
||||
- Email: ~test@asteroid123~
|
||||
- Role: ~listener~
|
||||
- Status: Active
|
||||
|
||||
* Git Commits
|
||||
|
||||
Three clean commits on ~feature/user-page-flow~ branch:
|
||||
|
||||
1. ~c6ac876~ - feat: Implement role-based page flow and user management APIs
|
||||
2. ~0b5bde8~ - fix: Complete UI fixes for page flow feature
|
||||
3. ~10bd8b4~ - docs: Mark Page Flow feature as complete in TODO
|
||||
|
||||
* Known Limitations
|
||||
|
||||
** Profile Page Data
|
||||
- Listening statistics return placeholder data (all zeros)
|
||||
- Recent tracks return empty array
|
||||
- Top artists return empty array
|
||||
- These are ready for future implementation when listening history tracking is added
|
||||
|
||||
** Future Enhancements
|
||||
- Implement actual listening history tracking
|
||||
- Add user profile editing functionality
|
||||
- Add user avatar/photo support
|
||||
- Implement password reset via email
|
||||
|
||||
* Notes for Integration
|
||||
|
||||
** For Fade (PostgreSQL Migration)
|
||||
- User management API endpoints are now standardized with ~define-api~
|
||||
- All endpoints use ~api-output~ for consistent JSON responses
|
||||
- Session handling is working correctly
|
||||
- Ready for database migration - just need to update ~find-user-by-id~, ~get-all-users~, etc.
|
||||
|
||||
** For easilokkx (UI Work)
|
||||
- All JavaScript files now properly handle ~api-output~ wrapper format
|
||||
- Pattern: ~const data = result.data || result;~
|
||||
- Profile page has placeholder API endpoints ready for real data
|
||||
- Auth UI system working correctly for conditional display
|
||||
|
||||
* Branch Status
|
||||
- Branch: ~feature/user-page-flow~
|
||||
- Status: Complete and tested
|
||||
- Ready for: Pull Request to upstream/main
|
||||
- Conflicts: None expected (isolated feature work)
|
||||
|
|
@ -33,10 +33,13 @@
|
|||
:pathname "./"
|
||||
:components ((:file "app-utils")
|
||||
(:file "module")
|
||||
(:file "conditions")
|
||||
(:file "database")
|
||||
(:file "template-utils")
|
||||
(:file "stream-media")
|
||||
(:file "user-management")
|
||||
(:file "playlist-management")
|
||||
(:file "stream-control")
|
||||
(:file "auth-routes")
|
||||
(:file "frontend-partials")
|
||||
(:file "asteroid")))
|
||||
|
|
|
|||
332
asteroid.lisp
332
asteroid.lisp
|
|
@ -37,21 +37,18 @@
|
|||
(define-api asteroid/admin/scan-library () ()
|
||||
"API endpoint to scan music library"
|
||||
(require-role :admin)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let ((tracks-added (scan-music-library)))
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Library scan completed")
|
||||
("tracks-added" . ,tracks-added))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Scan failed: ~a" e)))
|
||||
:status 500))))
|
||||
("tracks-added" . ,tracks-added))))))
|
||||
|
||||
(define-api asteroid/admin/tracks () ()
|
||||
"API endpoint to view all tracks in database"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(let ((tracks (db:select "tracks" (db:query :all))))
|
||||
(with-error-handling
|
||||
(let ((tracks (with-db-error-handling "select"
|
||||
(db:select "tracks" (db:query :all)))))
|
||||
(api-output `(("status" . "success")
|
||||
("tracks" . ,(mapcar (lambda (track)
|
||||
`(("id" . ,(gethash "_id" track))
|
||||
|
|
@ -61,23 +58,17 @@
|
|||
("duration" . ,(first (gethash "duration" track)))
|
||||
("format" . ,(first (gethash "format" track)))
|
||||
("bitrate" . ,(first (gethash "bitrate" track)))))
|
||||
tracks)))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error retrieving tracks: ~a" e)))
|
||||
:status 500))))
|
||||
tracks)))))))
|
||||
|
||||
;; Playlist API endpoints
|
||||
(define-api asteroid/playlists () ()
|
||||
"Get all playlists for current user"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((user (get-current-user))
|
||||
(user-id-raw (gethash "_id" user))
|
||||
(user-id (if (listp user-id-raw) (first user-id-raw) user-id-raw))
|
||||
(playlists (get-user-playlists user-id)))
|
||||
(format t "Fetching playlists for user-id: ~a~%" user-id)
|
||||
(format t "Found ~a playlists~%" (length playlists))
|
||||
(api-output `(("status" . "success")
|
||||
("playlists" . ,(mapcar (lambda (playlist)
|
||||
(let ((name-val (gethash "name" playlist))
|
||||
|
|
@ -85,7 +76,6 @@
|
|||
(track-ids-val (gethash "track-ids" playlist))
|
||||
(created-val (gethash "created-date" playlist))
|
||||
(id-val (gethash "_id" playlist)))
|
||||
(format t "Playlist ID: ~a (type: ~a)~%" id-val (type-of id-val))
|
||||
;; Calculate track count from comma-separated string
|
||||
;; Handle nil, empty string, or list containing empty string
|
||||
(let* ((track-ids-str (if (listp track-ids-val)
|
||||
|
|
@ -101,55 +91,37 @@
|
|||
("description" . ,(if (listp desc-val) (first desc-val) desc-val))
|
||||
("track-count" . ,track-count)
|
||||
("created-date" . ,(if (listp created-val) (first created-val) created-val))))))
|
||||
playlists)))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error retrieving playlists: ~a" e)))
|
||||
:status 500))))
|
||||
playlists)))))))
|
||||
|
||||
(define-api asteroid/playlists/create (name &optional description) ()
|
||||
"Create a new playlist"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((user (get-current-user))
|
||||
(user-id-raw (gethash "_id" user))
|
||||
(user-id (if (listp user-id-raw) (first user-id-raw) user-id-raw)))
|
||||
(format t "Creating playlist for user-id: ~a, name: ~a~%" user-id name)
|
||||
(create-playlist user-id name description)
|
||||
(format t "Playlist created successfully~%")
|
||||
(if (string= "true" (post/get "browser"))
|
||||
(redirect "/asteroid/")
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Playlist created successfully")))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error creating playlist: ~a" e)))
|
||||
:status 500))))
|
||||
("message" . "Playlist created successfully")))))))
|
||||
|
||||
(define-api asteroid/playlists/add-track (playlist-id track-id) ()
|
||||
"Add a track to a playlist"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let ((pl-id (parse-integer playlist-id :junk-allowed t))
|
||||
(tr-id (parse-integer track-id :junk-allowed t)))
|
||||
(add-track-to-playlist pl-id tr-id)
|
||||
(if (string= "true" (post/get "browser"))
|
||||
(redirect "/asteroid/")
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Track added to playlist")))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error adding track: ~a" e)))
|
||||
:status 500))))
|
||||
("message" . "Track added to playlist"))))))
|
||||
|
||||
(define-api asteroid/playlists/get (playlist-id) ()
|
||||
"Get playlist details with tracks"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((id (parse-integer playlist-id :junk-allowed t))
|
||||
(playlist (get-playlist-by-id id)))
|
||||
(format t "Looking for playlist ID: ~a~%" id)
|
||||
(format t "Found playlist: ~a~%" (if playlist "YES" "NO"))
|
||||
(if playlist
|
||||
(let* ((track-ids-raw (gethash "tracks" playlist))
|
||||
(track-ids (if (listp track-ids-raw) track-ids-raw (list track-ids-raw)))
|
||||
|
|
@ -171,18 +143,15 @@
|
|||
valid-tracks)))))))
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "Playlist not found"))
|
||||
:status 404)))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error retrieving playlist: ~a" e)))
|
||||
:status 500))))
|
||||
:status 404)))))
|
||||
|
||||
;; API endpoint to get all tracks (for web player)
|
||||
(define-api asteroid/tracks () ()
|
||||
"Get all tracks for web player"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(let ((tracks (db:select "tracks" (db:query :all))))
|
||||
(with-error-handling
|
||||
(let ((tracks (with-db-error-handling "select"
|
||||
(db:select "tracks" (db:query :all)))))
|
||||
(api-output `(("status" . "success")
|
||||
("tracks" . ,(mapcar (lambda (track)
|
||||
`(("id" . ,(gethash "_id" track))
|
||||
|
|
@ -191,30 +160,86 @@
|
|||
("album" . ,(gethash "album" track))
|
||||
("duration" . ,(gethash "duration" track))
|
||||
("format" . ,(gethash "format" track))))
|
||||
tracks)))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error retrieving tracks: ~a" e)))
|
||||
:status 500))))
|
||||
tracks)))))))
|
||||
|
||||
;; Stream Control API Endpoints
|
||||
(define-api asteroid/stream/queue () ()
|
||||
"Get the current stream queue"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((queue (get-stream-queue)))
|
||||
(api-output `(("status" . "success")
|
||||
("queue" . ,(mapcar (lambda (track-id)
|
||||
(let ((track (get-track-by-id track-id)))
|
||||
`(("id" . ,track-id)
|
||||
("title" . ,(gethash "title" track))
|
||||
("artist" . ,(gethash "artist" track))
|
||||
("album" . ,(gethash "album" track)))))
|
||||
queue)))))))
|
||||
|
||||
(define-api asteroid/stream/queue/add (track-id &optional (position "end")) ()
|
||||
"Add a track to the stream queue"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((tr-id (parse-integer track-id :junk-allowed t))
|
||||
(pos (if (string= position "next") :next :end)))
|
||||
(add-to-stream-queue tr-id pos)
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Track added to stream queue"))))))
|
||||
|
||||
(define-api asteroid/stream/queue/remove (track-id) ()
|
||||
"Remove a track from the stream queue"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((tr-id (parse-integer track-id :junk-allowed t)))
|
||||
(remove-from-stream-queue tr-id)
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Track removed from stream queue"))))))
|
||||
|
||||
(define-api asteroid/stream/queue/clear () ()
|
||||
"Clear the entire stream queue"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(clear-stream-queue)
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Stream queue cleared")))))
|
||||
|
||||
(define-api asteroid/stream/queue/add-playlist (playlist-id) ()
|
||||
"Add all tracks from a playlist to the stream queue"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((pl-id (parse-integer playlist-id :junk-allowed t)))
|
||||
(add-playlist-to-stream-queue pl-id)
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Playlist added to stream queue"))))))
|
||||
|
||||
(define-api asteroid/stream/queue/reorder (track-ids) ()
|
||||
"Reorder the stream queue (expects comma-separated track IDs)"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((ids (mapcar (lambda (id-str) (parse-integer id-str :junk-allowed t))
|
||||
(cl-ppcre:split "," track-ids))))
|
||||
(reorder-stream-queue ids)
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Stream queue reordered"))))))
|
||||
|
||||
(define-api asteroid/stream/queue/load-m3u () ()
|
||||
"Load stream queue from stream-queue.m3u file"
|
||||
(require-role :admin)
|
||||
(with-error-handling
|
||||
(let ((count (load-queue-from-m3u-file)))
|
||||
(api-output `(("status" . "success")
|
||||
("message" . "Queue loaded from M3U file")
|
||||
("count" . ,count))))))
|
||||
|
||||
;; API endpoint to get track by ID (for streaming)
|
||||
(define-page api-get-track-by-id #@"/api/tracks/(.*)" (:uri-groups (track-id))
|
||||
"Retrieve track from database by ID"
|
||||
(let* ((id (if (stringp track-id) (parse-integer track-id) track-id))
|
||||
(tracks (db:select "tracks" (db:query (:= '_id id)))))
|
||||
(when tracks (first tracks))))
|
||||
(defun get-track-by-id (track-id)
|
||||
"Get a track by its ID - handles type mismatches"
|
||||
(format t "get-track-by-id called with: ~a (type: ~a)~%" track-id (type-of track-id))
|
||||
;; Try direct query first
|
||||
(let ((tracks (db:select "tracks" (db:query (:= "_id" track-id)))))
|
||||
(if (> (length tracks) 0)
|
||||
(progn
|
||||
(format t "Found via direct query~%")
|
||||
(first tracks))
|
||||
(first tracks)
|
||||
;; If not found, search manually (ID might be stored as list)
|
||||
(let ((all-tracks (db:select "tracks" (db:query :all))))
|
||||
(format t "Searching through ~a tracks manually~%" (length all-tracks))
|
||||
(find-if (lambda (track)
|
||||
(let ((stored-id (gethash "_id" track)))
|
||||
(or (equal stored-id track-id)
|
||||
|
|
@ -232,15 +257,19 @@
|
|||
|
||||
(define-page stream-track #@"/tracks/(.*)/stream" (:uri-groups (track-id))
|
||||
"Stream audio file by track ID"
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((id (parse-integer track-id))
|
||||
(track (get-track-by-id id)))
|
||||
(if track
|
||||
(unless track
|
||||
(signal-not-found "track" id))
|
||||
(let* ((file-path (first (gethash "file-path" track)))
|
||||
(format (first (gethash "format" track)))
|
||||
(file (probe-file file-path)))
|
||||
(if file
|
||||
(progn
|
||||
(unless file
|
||||
(error 'not-found-error
|
||||
:message "Audio file not found on disk"
|
||||
:resource-type "file"
|
||||
:resource-id file-path))
|
||||
;; Set appropriate headers for audio streaming
|
||||
(setf (radiance:header "Content-Type") (get-mime-type-for-format format))
|
||||
(setf (radiance:header "Accept-Ranges") "bytes")
|
||||
|
|
@ -249,22 +278,7 @@
|
|||
(db:update "tracks" (db:query (:= '_id id))
|
||||
`(("play-count" ,(1+ (first (gethash "play-count" track))))))
|
||||
;; Return file contents
|
||||
(alexandria:read-file-into-byte-vector file))
|
||||
(progn
|
||||
(setf (radiance:header "Content-Type") "application/json")
|
||||
(cl-json:encode-json-to-string
|
||||
`(("status" . "error")
|
||||
("message" . "Audio file not found on disk"))))))
|
||||
(progn
|
||||
(setf (radiance:header "Content-Type") "application/json")
|
||||
(cl-json:encode-json-to-string
|
||||
`(("status" . "error")
|
||||
("message" . "Track not found"))))))
|
||||
(error (e)
|
||||
(setf (radiance:header "Content-Type") "application/json")
|
||||
(cl-json:encode-json-to-string
|
||||
`(("status" . "error")
|
||||
("message" . ,(format nil "Streaming error: ~a" e)))))))
|
||||
(alexandria:read-file-into-byte-vector file)))))
|
||||
|
||||
;; Player state management
|
||||
(defvar *current-track* nil "Currently playing track")
|
||||
|
|
@ -307,11 +321,11 @@
|
|||
;; Player control API endpoints
|
||||
(define-api asteroid/player/play (track-id) ()
|
||||
"Start playing a track by ID"
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((id (parse-integer track-id))
|
||||
(track (get-track-by-id id)))
|
||||
(if track
|
||||
(progn
|
||||
(unless track
|
||||
(signal-not-found "track" id))
|
||||
(setf *current-track* id)
|
||||
(setf *player-state* :playing)
|
||||
(setf *current-position* 0)
|
||||
|
|
@ -320,14 +334,7 @@
|
|||
("track" . (("id" . ,id)
|
||||
("title" . ,(first (gethash "title" track)))
|
||||
("artist" . ,(first (gethash "artist" track)))))
|
||||
("player" . ,(get-player-status)))))
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "Track not found"))
|
||||
:status 404)))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Play error: ~a" e)))
|
||||
:status 500))))
|
||||
("player" . ,(get-player-status)))))))
|
||||
|
||||
(define-api asteroid/player/pause () ()
|
||||
"Pause current playback"
|
||||
|
|
@ -433,37 +440,67 @@
|
|||
("message" . "Listening history cleared successfully"))))
|
||||
|#
|
||||
|
||||
;; Front page
|
||||
;; Front page - regular view by default
|
||||
(define-page front-page #@"/" ()
|
||||
"Main front page"
|
||||
(let ((template-path (merge-pathnames "template/front-page.chtml"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
(load-template "front-page")
|
||||
:title "🎵 ASTEROID RADIO 🎵"
|
||||
:station-name "🎵 ASTEROID RADIO 🎵"
|
||||
:status-message "🟢 LIVE - Broadcasting asteroid music for hackers"
|
||||
:listeners "0"
|
||||
:stream-quality "128kbps MP3"
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (concatenate 'string *stream-base-url* "/asteroid.aac")
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*)
|
||||
:default-stream-encoding "audio/aac"
|
||||
:default-stream-encoding-desc "AAC 96kbps Stereo"
|
||||
:now-playing-artist "The Void"
|
||||
:now-playing-track "Silence"
|
||||
:now-playing-album "Startup Sounds"
|
||||
:now-playing-duration "∞")))
|
||||
:now-playing-duration "∞"))
|
||||
|
||||
;; Frameset wrapper for persistent player mode
|
||||
(define-page frameset-wrapper #@"/frameset" ()
|
||||
"Frameset wrapper with persistent audio player"
|
||||
(clip:process-to-string
|
||||
(load-template "frameset-wrapper")
|
||||
:title "🎵 ASTEROID RADIO 🎵"))
|
||||
|
||||
;; Content frame - front page content without player
|
||||
(define-page front-page-content #@"/content" ()
|
||||
"Front page content (displayed in content frame)"
|
||||
(clip:process-to-string
|
||||
(load-template "front-page-content")
|
||||
:title "🎵 ASTEROID RADIO 🎵"
|
||||
:station-name "🎵 ASTEROID RADIO 🎵"
|
||||
:status-message "🟢 LIVE - Broadcasting asteroid music for hackers"
|
||||
:listeners "0"
|
||||
:stream-quality "128kbps MP3"
|
||||
:stream-base-url *stream-base-url*
|
||||
:now-playing-artist "The Void"
|
||||
:now-playing-track "Silence"
|
||||
:now-playing-album "Startup Sounds"
|
||||
:now-playing-duration "∞"))
|
||||
|
||||
;; Persistent audio player frame (bottom frame)
|
||||
(define-page audio-player-frame #@"/audio-player-frame" ()
|
||||
"Persistent audio player frame (bottom of page)"
|
||||
(clip:process-to-string
|
||||
(load-template "audio-player-frame")
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*)
|
||||
:default-stream-encoding "audio/aac"))
|
||||
|
||||
;; Configure static file serving for other files
|
||||
(define-page static #@"/static/(.*)" (:uri-groups (path))
|
||||
(serve-file (merge-pathnames (concatenate 'string "static/" path)
|
||||
(serve-file (merge-pathnames (format nil "static/~a" path)
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
|
||||
;; Status check functions
|
||||
(defun check-icecast-status ()
|
||||
"Check if Icecast server is running and accessible"
|
||||
(handler-case
|
||||
(let ((response (drakma:http-request (concatenate 'string *stream-base-url* "/status-json.xsl")
|
||||
(let ((response (drakma:http-request (format nil "~a/status-json.xsl" *stream-base-url*)
|
||||
:want-stream nil
|
||||
:connection-timeout 2)))
|
||||
(if response "🟢 Running" "🔴 Not Running"))
|
||||
|
|
@ -485,13 +522,11 @@
|
|||
(define-page admin #@"/admin" ()
|
||||
"Admin dashboard"
|
||||
(require-authentication)
|
||||
(let ((template-path (merge-pathnames "template/admin.chtml"
|
||||
(asdf:system-source-directory :asteroid)))
|
||||
(track-count (handler-case
|
||||
(let ((track-count (handler-case
|
||||
(length (db:select "tracks" (db:query :all)))
|
||||
(error () 0))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
(load-template "admin")
|
||||
:title "🎵 ASTEROID RADIO - Admin Dashboard"
|
||||
:server-status "🟢 Running"
|
||||
:database-status (handler-case
|
||||
|
|
@ -500,26 +535,24 @@
|
|||
:liquidsoap-status (check-liquidsoap-status)
|
||||
:icecast-status (check-icecast-status)
|
||||
:track-count (format nil "~d" track-count)
|
||||
:library-path "/home/glenn/Projects/Code/asteroid/music/library/")))
|
||||
:library-path "/home/glenn/Projects/Code/asteroid/music/library/"
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*))))
|
||||
|
||||
;; User Management page (requires authentication)
|
||||
(define-page users-management #@"/admin/user" ()
|
||||
"User Management dashboard"
|
||||
(require-authentication)
|
||||
(let ((template-path (merge-pathnames "template/users.chtml"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
:title "🎵 ASTEROID RADIO - User Management")))
|
||||
(load-template "users")
|
||||
:title "🎵 ASTEROID RADIO - User Management"))
|
||||
|
||||
;; User Profile page (requires authentication)
|
||||
(define-page user-profile #@"/profile" ()
|
||||
"User profile page"
|
||||
(require-authentication)
|
||||
(let ((template-path (merge-pathnames "template/profile.chtml"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
(load-template "profile")
|
||||
:title "🎧 admin - Profile | Asteroid Radio"
|
||||
:username "admin"
|
||||
:user-role "admin"
|
||||
|
|
@ -550,7 +583,7 @@
|
|||
:top-artist-4 ""
|
||||
:top-artist-4-plays ""
|
||||
:top-artist-5 ""
|
||||
:top-artist-5-plays "")))
|
||||
:top-artist-5-plays ""))
|
||||
|
||||
;; Helper functions for profile page - TEMPORARILY COMMENTED OUT
|
||||
#|
|
||||
|
|
@ -587,7 +620,7 @@
|
|||
(require-authentication)
|
||||
(let* ((current-user (auth:current-user))
|
||||
(username (gethash "username" current-user))
|
||||
(template-path (merge-pathnames "template/profile.chtml"
|
||||
(template-path (merge-pathnames "template/profile.ctml"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
|
|
@ -627,7 +660,7 @@
|
|||
;; Auth status API endpoint
|
||||
(define-api asteroid/auth-status () ()
|
||||
"Check if user is logged in and their role"
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((user-id (session:field "user-id"))
|
||||
(user (when user-id (find-user-by-id user-id))))
|
||||
(api-output `(("loggedIn" . ,(if user t nil))
|
||||
|
|
@ -635,18 +668,13 @@
|
|||
("username" . ,(if user
|
||||
(let ((username (gethash "username" user)))
|
||||
(if (listp username) (first username) username))
|
||||
nil)))))
|
||||
(error (e)
|
||||
(api-output `(("loggedIn" . nil)
|
||||
("isAdmin" . nil)
|
||||
("error" . ,(format nil "~a" e)))
|
||||
:status 500))))
|
||||
nil)))))))
|
||||
|
||||
;; User profile API endpoints
|
||||
(define-api asteroid/user/profile () ()
|
||||
"Get current user profile information"
|
||||
(require-authentication)
|
||||
(handler-case
|
||||
(with-error-handling
|
||||
(let* ((user-id (session:field "user-id"))
|
||||
(user (find-user-by-id user-id)))
|
||||
(if user
|
||||
|
|
@ -656,13 +684,7 @@
|
|||
("role" . ,(first (gethash "role" user)))
|
||||
("created_at" . ,(first (gethash "created-date" user)))
|
||||
("last_active" . ,(first (gethash "last-login" user)))))))
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "User not found"))
|
||||
:status 404)))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error loading profile: ~a" e)))
|
||||
:status 500))))
|
||||
(signal-not-found "user" user-id)))))
|
||||
|
||||
(define-api asteroid/user/listening-stats () ()
|
||||
"Get user listening statistics"
|
||||
|
|
@ -739,18 +761,34 @@
|
|||
:success-message ""))))
|
||||
|
||||
(define-page player #@"/player" ()
|
||||
(let ((template-path (merge-pathnames "template/player.chtml"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(clip:process-to-string
|
||||
(plump:parse (alexandria:read-file-into-string template-path))
|
||||
(load-template "player")
|
||||
:title "Asteroid Radio - Web Player"
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (concatenate 'string *stream-base-url* "/asteroid.aac")
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*)
|
||||
:bitrate "128kbps MP3"
|
||||
:now-playing-artist "The Void"
|
||||
:now-playing-track "Silence"
|
||||
:now-playing-album "Startup Sounds"
|
||||
:player-status "Stopped")))
|
||||
:player-status "Stopped"))
|
||||
|
||||
;; Player content frame (for frameset mode)
|
||||
(define-page player-content #@"/player-content" ()
|
||||
"Player page content (displayed in content frame)"
|
||||
(clip:process-to-string
|
||||
(load-template "player-content")
|
||||
:title "Asteroid Radio - Web Player"
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*)
|
||||
:default-stream-encoding "audio/aac"))
|
||||
|
||||
(define-page popout-player #@"/popout-player" ()
|
||||
"Pop-out player window"
|
||||
(clip:process-to-string
|
||||
(load-template "popout-player")
|
||||
:stream-base-url *stream-base-url*
|
||||
:default-stream-url (format nil "~a/asteroid.aac" *stream-base-url*)
|
||||
:default-stream-encoding "audio/aac"))
|
||||
|
||||
(define-api asteroid/status () ()
|
||||
"Get server status"
|
||||
|
|
@ -762,14 +800,14 @@
|
|||
("artist" . "The Void")
|
||||
("album" . "Startup Sounds")))
|
||||
("listeners" . 0)
|
||||
("stream-url" . ,(concatenate 'string *stream-base-url* "/asteroid.mp3"))
|
||||
("stream-url" . ,(format nil "~a/asteroid.mp3" *stream-base-url*))
|
||||
("stream-status" . "live"))))
|
||||
|
||||
;; Live stream status from Icecast
|
||||
(define-api asteroid/icecast-status () ()
|
||||
"Get live status from Icecast server"
|
||||
(handler-case
|
||||
(let* ((icecast-url (concatenate 'string *stream-base-url* "/admin/stats.xml"))
|
||||
(with-error-handling
|
||||
(let* ((icecast-url (format nil "~a/admin/stats.xml" *stream-base-url*))
|
||||
(response (drakma:http-request icecast-url
|
||||
:want-stream nil
|
||||
:basic-authorization '("admin" "asteroid_admin_2024"))))
|
||||
|
|
@ -785,11 +823,13 @@
|
|||
(let* ((source-section (subseq xml-string match-start
|
||||
(or (cl-ppcre:scan "</source>" xml-string :start match-start)
|
||||
(length xml-string))))
|
||||
(title (or (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown"))
|
||||
(listeners (or (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0")))
|
||||
(titlep (cl-ppcre:all-matches "<title>" source-section))
|
||||
(listenersp (cl-ppcre:all-matches "<listeners>" source-section))
|
||||
(title (if titlep (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown"))
|
||||
(listeners (if listenersp (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0")))
|
||||
;; Return JSON in format expected by frontend
|
||||
(api-output
|
||||
`(("icestats" . (("source" . (("listenurl" . ,(concatenate 'string *stream-base-url* "/asteroid.mp3"))
|
||||
`(("icestats" . (("source" . (("listenurl" . ,(format nil "~a/asteroid.mp3" *stream-base-url*))
|
||||
("title" . ,title)
|
||||
("listeners" . ,(parse-integer listeners :junk-allowed t)))))))))
|
||||
;; No source found, return empty
|
||||
|
|
@ -797,11 +837,7 @@
|
|||
`(("icestats" . (("source" . nil))))))))
|
||||
(api-output
|
||||
`(("error" . "Could not connect to Icecast server"))
|
||||
:status 503)))
|
||||
(error (e)
|
||||
(api-output
|
||||
`(("error" . ,(format nil "Icecast connection failed: ~a" e)))
|
||||
:status 500))))
|
||||
:status 503)))))
|
||||
|
||||
|
||||
;; RADIANCE server management functions
|
||||
|
|
|
|||
|
|
@ -0,0 +1,185 @@
|
|||
;;;; conditions.lisp - Custom error conditions for Asteroid Radio
|
||||
;;;; Provides a hierarchy of error conditions for better error handling and debugging
|
||||
|
||||
(in-package :asteroid)
|
||||
|
||||
;;; Base Condition Hierarchy
|
||||
|
||||
(define-condition asteroid-error (error)
|
||||
((message
|
||||
:initarg :message
|
||||
:reader error-message
|
||||
:documentation "Human-readable error message"))
|
||||
(:documentation "Base condition for all Asteroid-specific errors")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Asteroid Error: ~a" (error-message condition)))))
|
||||
|
||||
;;; Specific Error Types
|
||||
|
||||
(define-condition database-error (asteroid-error)
|
||||
((operation
|
||||
:initarg :operation
|
||||
:reader error-operation
|
||||
:initform nil
|
||||
:documentation "Database operation that failed (e.g., 'select', 'insert')"))
|
||||
(:documentation "Signaled when a database operation fails")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Database Error~@[ during ~a~]: ~a"
|
||||
(error-operation condition)
|
||||
(error-message condition)))))
|
||||
|
||||
(define-condition authentication-error (asteroid-error)
|
||||
((user
|
||||
:initarg :user
|
||||
:reader error-user
|
||||
:initform nil
|
||||
:documentation "Username or user ID that failed authentication"))
|
||||
(:documentation "Signaled when authentication fails")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Authentication Error~@[ for user ~a~]: ~a"
|
||||
(error-user condition)
|
||||
(error-message condition)))))
|
||||
|
||||
(define-condition authorization-error (asteroid-error)
|
||||
((required-role
|
||||
:initarg :required-role
|
||||
:reader error-required-role
|
||||
:initform nil
|
||||
:documentation "Role required for the operation"))
|
||||
(:documentation "Signaled when user lacks required permissions")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Authorization Error~@[ (requires ~a)~]: ~a"
|
||||
(error-required-role condition)
|
||||
(error-message condition)))))
|
||||
|
||||
(define-condition not-found-error (asteroid-error)
|
||||
((resource-type
|
||||
:initarg :resource-type
|
||||
:reader error-resource-type
|
||||
:initform nil
|
||||
:documentation "Type of resource that wasn't found (e.g., 'track', 'user')")
|
||||
(resource-id
|
||||
:initarg :resource-id
|
||||
:reader error-resource-id
|
||||
:initform nil
|
||||
:documentation "ID of the resource that wasn't found"))
|
||||
(:documentation "Signaled when a requested resource doesn't exist")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Not Found~@[ (~a~@[ ~a~])~]: ~a"
|
||||
(error-resource-type condition)
|
||||
(error-resource-id condition)
|
||||
(error-message condition)))))
|
||||
|
||||
(define-condition validation-error (asteroid-error)
|
||||
((field
|
||||
:initarg :field
|
||||
:reader error-field
|
||||
:initform nil
|
||||
:documentation "Field that failed validation"))
|
||||
(:documentation "Signaled when input validation fails")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Validation Error~@[ in field ~a~]: ~a"
|
||||
(error-field condition)
|
||||
(error-message condition)))))
|
||||
|
||||
(define-condition asteroid-stream-error (asteroid-error)
|
||||
((stream-type
|
||||
:initarg :stream-type
|
||||
:reader error-stream-type
|
||||
:initform nil
|
||||
:documentation "Type of stream (e.g., 'icecast', 'liquidsoap')"))
|
||||
(:documentation "Signaled when stream operations fail")
|
||||
(:report (lambda (condition stream)
|
||||
(format stream "Stream Error~@[ (~a)~]: ~a"
|
||||
(error-stream-type condition)
|
||||
(error-message condition)))))
|
||||
|
||||
;;; Error Handling Macros
|
||||
|
||||
(defmacro with-error-handling (&body body)
|
||||
"Wrap API endpoint code with standard error handling.
|
||||
Catches specific Asteroid errors and returns appropriate HTTP status codes.
|
||||
|
||||
Usage:
|
||||
(define-api my-endpoint () ()
|
||||
(with-error-handling
|
||||
(do-something-that-might-fail)))"
|
||||
`(handler-case
|
||||
(progn ,@body)
|
||||
(not-found-error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(error-message e)))
|
||||
:status 404))
|
||||
(authentication-error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(error-message e)))
|
||||
:status 401))
|
||||
(authorization-error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(error-message e)))
|
||||
:status 403))
|
||||
(validation-error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(error-message e)))
|
||||
:status 400))
|
||||
(database-error (e)
|
||||
(format t "Database error: ~a~%" e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "Database operation failed"))
|
||||
:status 500))
|
||||
(asteroid-stream-error (e)
|
||||
(format t "Stream error: ~a~%" e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "Stream operation failed"))
|
||||
:status 500))
|
||||
(asteroid-error (e)
|
||||
(format t "Asteroid error: ~a~%" e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(error-message e)))
|
||||
:status 500))
|
||||
(error (e)
|
||||
(format t "Unexpected error: ~a~%" e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . "An unexpected error occurred"))
|
||||
:status 500))))
|
||||
|
||||
(defmacro with-db-error-handling (operation &body body)
|
||||
"Wrap database operations with error handling.
|
||||
Automatically converts database errors to database-error conditions.
|
||||
|
||||
Usage:
|
||||
(with-db-error-handling \"select\"
|
||||
(db:select 'tracks (db:query :all)))"
|
||||
`(handler-case
|
||||
(progn ,@body)
|
||||
(error (e)
|
||||
(error 'database-error
|
||||
:message (format nil "~a" e)
|
||||
:operation ,operation))))
|
||||
|
||||
;;; Helper Functions
|
||||
|
||||
(defun signal-not-found (resource-type resource-id)
|
||||
"Signal a not-found-error with the given resource information."
|
||||
(error 'not-found-error
|
||||
:message (format nil "~a not found" resource-type)
|
||||
:resource-type resource-type
|
||||
:resource-id resource-id))
|
||||
|
||||
(defun signal-validation-error (field message)
|
||||
"Signal a validation-error for the given field."
|
||||
(error 'validation-error
|
||||
:message message
|
||||
:field field))
|
||||
|
||||
(defun signal-auth-error (user message)
|
||||
"Signal an authentication-error for the given user."
|
||||
(error 'authentication-error
|
||||
:message message
|
||||
:user user))
|
||||
|
||||
(defun signal-authz-error (required-role message)
|
||||
"Signal an authorization-error with the required role."
|
||||
(error 'authorization-error
|
||||
:message message
|
||||
:required-role required-role))
|
||||
|
|
@ -9,25 +9,43 @@ set("init.allow_root", true)
|
|||
# Set log level for debugging
|
||||
log.level.set(4)
|
||||
|
||||
# Audio buffering settings to prevent choppiness
|
||||
settings.frame.audio.samplerate.set(44100)
|
||||
settings.frame.audio.channels.set(2)
|
||||
settings.audio.converter.samplerate.libsamplerate.quality.set("best")
|
||||
|
||||
# Enable telnet server for remote control
|
||||
settings.server.telnet.set(true)
|
||||
settings.server.telnet.port.set(1234)
|
||||
settings.server.telnet.bind_addr.set("0.0.0.0")
|
||||
|
||||
# Create playlist source from mounted music directory
|
||||
# Use playlist.safe which starts playing immediately without full scan
|
||||
radio = playlist.safe(
|
||||
# Create playlist source from generated M3U file
|
||||
# This file is managed by Asteroid's stream control system
|
||||
# Falls back to directory scan if playlist file doesn't exist
|
||||
radio = playlist(
|
||||
mode="normal", # Play in order (not randomized)
|
||||
reload=30, # Check for playlist updates every 30 seconds
|
||||
reload_mode="seconds", # Reload every N seconds (prevents running out of tracks)
|
||||
"/app/stream-queue.m3u"
|
||||
)
|
||||
|
||||
# Fallback to directory scan if playlist file is empty/missing
|
||||
radio_fallback = playlist.safe(
|
||||
mode="randomize",
|
||||
reload=3600,
|
||||
"/app/music/"
|
||||
)
|
||||
|
||||
# Add some audio processing
|
||||
radio = amplify(1.0, radio)
|
||||
radio = normalize(radio)
|
||||
# Use main playlist, fall back to directory scan
|
||||
radio = fallback(track_sensitive=false, [radio, radio_fallback])
|
||||
|
||||
# Add crossfade between tracks
|
||||
radio = crossfade(radio)
|
||||
# Simple crossfade for smooth transitions
|
||||
radio = crossfade(
|
||||
duration=3.0, # 3 second crossfade
|
||||
fade_in=2.0, # 2 second fade in
|
||||
fade_out=2.0, # 2 second fade out
|
||||
radio
|
||||
)
|
||||
|
||||
# Create a fallback with emergency content
|
||||
emergency = sine(440.0)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
services:
|
||||
asteroid:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: Dockerfile.asteroid
|
||||
image: asteroid/app
|
||||
container_name: asteroid
|
||||
environment:
|
||||
- ASTEROID_STREAM_URL=${ASTEROID_STREAM_URL:-http://localhost:8000}
|
||||
volumes:
|
||||
- ${MUSIC_LIBRARY:-../music/library}:/app/music/library:ro
|
||||
- ${QUEUE_PLAYLIST:-../stream-queue.m3u}:/app/stream-queue.m3u
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
|
|
@ -24,8 +24,9 @@ services:
|
|||
depends_on:
|
||||
- icecast
|
||||
volumes:
|
||||
- ../music/library:/app/music:ro
|
||||
- ${MUSIC_LIBRARY:-../music/library}:/app/music:ro
|
||||
- ./asteroid-radio-docker.liq:/app/asteroid-radio.liq:ro
|
||||
- ${QUEUE_PLAYLIST:-../stream-queue.m3u}:/app/stream-queue.m3u:ro
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- asteroid-network
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
; meta (:version 1.0 :package "RADIANCE-CORE")
|
||||
((:interfaces (:admin . "r-simple-admin") (:auth . "r-simple-auth")
|
||||
(:ban . "r-simple-ban") (:cache . "r-simple-cache")
|
||||
(:data-model . "r-simple-model") (:database . "i-lambdalite")
|
||||
(:relational-database . "i-sqlite") (:logger . "i-verbose")
|
||||
(:mail . "i-smtp") (:profile . "r-simple-profile") (:rate . "r-simple-rate")
|
||||
(:server . "i-hunchentoot") (:session . "r-simple-sessions")
|
||||
(:user . "r-simple-users"))
|
||||
(:versions
|
||||
. [hash-table equal ("radiance-core" :|2.2.0|) ("i-hunchentoot" :|1.1.0|)
|
||||
("asteroid" :|0.0.0|) ("i-log4cl" :|1.0.0|) ("r-clip" :|1.0.0|)
|
||||
("r-data-model" :|1.0.1|) ("i-lambdalite" :|1.0.0|)
|
||||
("r-simple-users" :|1.0.1|)
|
||||
("r-simple-errors" :|1.0.0|) ("i-verbose" :|1.0.0|)
|
||||
("r-simple-auth" :|1.0.0|) ("r-simple-sessions" :|1.0.1|)
|
||||
("r-ratify" :|1.0.0|) ("r-simple-rate" :|1.0.0|)
|
||||
("r-simple-profile" :|1.0.0|)])
|
||||
(:domains "radiance" "localhost")
|
||||
(:startup :r-simple-errors :r-simple-sessions) (:routes)
|
||||
(:debugger . :if-swank-connected))
|
||||
|
|
@ -23,6 +23,7 @@ docker compose ps
|
|||
|
||||
echo ""
|
||||
echo "🎵 Asteroid Radio is now streaming!"
|
||||
echo "📡 High Quality: http://localhost:8000/asteroid.mp3"
|
||||
echo "📡 Low Quality: http://localhost:8000/asteroid-low.mp3"
|
||||
echo "📡 High Quality MP3: http://localhost:8000/asteroid.mp3"
|
||||
echo "📡 High Quality AAC: http://localhost:8000/asteroid.aac"
|
||||
echo "📡 Low Quality MP3: http://localhost:8000/asteroid-low.mp3"
|
||||
echo "🔧 Admin Panel: http://localhost:8000/admin/"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Asteroid Radio - API Endpoints Reference
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-10
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
|
|
@ -423,51 +423,6 @@ curl -X POST http://localhost:8080/api/asteroid/playlists/create \
|
|||
|
||||
When =browser=true= is passed, endpoints will redirect to appropriate pages instead of returning JSON.
|
||||
|
||||
* Integration Examples
|
||||
|
||||
** JavaScript/Fetch API
|
||||
|
||||
#+BEGIN_SRC javascript
|
||||
// Get tracks
|
||||
fetch('/api/asteroid/tracks')
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Tracks:', data.tracks);
|
||||
});
|
||||
|
||||
// Play a track
|
||||
fetch('/api/asteroid/player/play', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: 'track-id=123'
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Now playing:', data.player.currentTrack);
|
||||
});
|
||||
#+END_SRC
|
||||
|
||||
** Python
|
||||
|
||||
#+BEGIN_SRC python
|
||||
import requests
|
||||
|
||||
# Get server status
|
||||
response = requests.get('http://localhost:8080/api/asteroid/status')
|
||||
print(response.json())
|
||||
|
||||
# Create playlist (with session)
|
||||
session = requests.Session()
|
||||
# ... login first ...
|
||||
response = session.post(
|
||||
'http://localhost:8080/api/asteroid/playlists/create',
|
||||
data={'name': 'My Playlist', 'description': 'Test'}
|
||||
)
|
||||
print(response.json())
|
||||
#+END_SRC
|
||||
|
||||
* Rate Limiting
|
||||
|
||||
API endpoints implement rate limiting to prevent abuse. Excessive requests may result in temporary blocking.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Asteroid Radio - Interface Reference
|
||||
#+TITLE: Asteroid Radio - API Reference
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-10
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Current Interfaces
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
#+TITLE: Asteroid Radio - Development Guide
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-10
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Development Setup
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
*Note on Package Managers*: Examples use =apt= (Debian/Ubuntu). Replace with your distribution's package manager (=dnf=, =pacman=, =zypper=, =apk=, etc.).
|
||||
#+END_QUOTE
|
||||
|
||||
** Prerequisites
|
||||
|
||||
*** System Dependencies
|
||||
|
|
@ -68,7 +72,7 @@ sbcl --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --quit
|
|||
|
||||
*** Clone Repository
|
||||
#+BEGIN_SRC bash
|
||||
git clone <repository-url>
|
||||
git clone https://github.com/fade/asteroid.git
|
||||
cd asteroid
|
||||
#+END_SRC
|
||||
|
||||
|
|
@ -125,9 +129,9 @@ sbcl --eval "(ql:quickload :asteroid)" --eval "(asteroid:start-server)"
|
|||
** Music Library Management
|
||||
|
||||
*** Directory Structure
|
||||
The music directory structure is:
|
||||
The music directory is located directly under the asteroid root directory:
|
||||
#+BEGIN_SRC
|
||||
asteroid/docker/music/ # Host directory (mounted to containers)
|
||||
asteroid/music/ # Music directory (can be symlink)
|
||||
├── artist1/
|
||||
│ ├── album1/
|
||||
│ │ ├── track1.mp3
|
||||
|
|
@ -138,6 +142,11 @@ asteroid/docker/music/ # Host directory (mounted to containers)
|
|||
└── single.wav
|
||||
#+END_SRC
|
||||
|
||||
The =music/= directory can be:
|
||||
- A regular directory with music files
|
||||
- A symlink to your actual music collection
|
||||
- Multiple subdirectories or symlinks within it
|
||||
|
||||
*** Recursive Scanning Capabilities
|
||||
The Asteroid application includes built-in recursive directory scanning:
|
||||
- *Function*: =scan-music-library= in =stream-media.lisp=
|
||||
|
|
@ -149,16 +158,21 @@ The Asteroid application includes built-in recursive directory scanning:
|
|||
*** Adding Music to Development Environment
|
||||
#+BEGIN_SRC bash
|
||||
# Option 1: Copy music files directly
|
||||
cp -r /path/to/your/music/* docker/music/
|
||||
cp -r /path/to/your/music/* music/
|
||||
|
||||
# Option 2: Mount remote directory (for large collections)
|
||||
# Option 2: Symlink entire music directory
|
||||
ln -s /path/to/existing/music music
|
||||
|
||||
# Option 3: Symlink subdirectories within music/
|
||||
mkdir -p music
|
||||
ln -s /path/to/collection1 music/collection1
|
||||
ln -s /path/to/collection2 music/collection2
|
||||
|
||||
# Option 4: Mount remote directory (for large collections)
|
||||
# Edit docker-compose.yml to change volume mount:
|
||||
# volumes:
|
||||
# - /mnt/remote-music:/app/music:ro
|
||||
|
||||
# Option 3: Symlink to existing collection
|
||||
ln -s /path/to/existing/music docker/music/collection
|
||||
|
||||
# Trigger library scan via API
|
||||
curl -X POST http://localhost:8080/api/asteroid/admin/scan-library
|
||||
#+END_SRC
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
#+TITLE: Asteroid Radio - Docker Streaming Setup
|
||||
#+AUTHOR: Docker Team
|
||||
#+DATE: 2025-10-03
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Docker Streaming Overview
|
||||
|
||||
This guide covers the complete Docker-based streaming setup for Asteroid Radio using Icecast2 and Liquidsoap containers. This approach provides a containerized, portable streaming infrastructure that's easy to deploy and maintain.
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
*Note on Package Managers*: Examples use =apt= (Debian/Ubuntu). Replace with your distribution's package manager (=dnf=, =pacman=, =zypper=, =apk=, etc.).
|
||||
#+END_QUOTE
|
||||
|
||||
* Architecture
|
||||
|
||||
** Container Stack
|
||||
|
|
@ -37,7 +41,7 @@ sudo usermod -a -G docker $USER
|
|||
** One-Command Setup
|
||||
#+BEGIN_SRC bash
|
||||
# Clone and start
|
||||
git clone <repository-url> asteroid-radio
|
||||
git clone https://github.com/fade/asteroid asteroid-radio
|
||||
cd asteroid-radio/docker
|
||||
docker compose up -d
|
||||
#+END_SRC
|
||||
|
|
|
|||
|
|
@ -1,11 +1,19 @@
|
|||
#+TITLE: Asteroid Radio - Installation Guide
|
||||
#+AUTHOR: Installation Team
|
||||
#+DATE: 2025-10-03
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Installation Overview
|
||||
|
||||
This guide covers the complete installation and deployment of Asteroid Radio. The **recommended approach** is Docker-based installation for easy deployment and consistency. Native installation is also available for development or custom deployments.
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
*Note on Package Managers*: Examples in this guide use =apt= (Debian/Ubuntu). Replace with your distribution's package manager:
|
||||
- Fedora/RHEL: =dnf= or =yum=
|
||||
- Arch Linux: =pacman=
|
||||
- openSUSE: =zypper=
|
||||
- Alpine: =apk=
|
||||
#+END_QUOTE
|
||||
|
||||
* Quick Start (Docker - Recommended)
|
||||
|
||||
** Prerequisites Check
|
||||
|
|
@ -18,8 +26,8 @@ docker info
|
|||
|
||||
** One-Command Setup
|
||||
#+BEGIN_SRC bash
|
||||
# Clone and setup (replace with actual repository URL)
|
||||
git clone <repository-url> asteroid-radio
|
||||
# Clone and setup
|
||||
git clone https://github.com/fade/asteroid.git asteroid-radio
|
||||
cd asteroid-radio/docker
|
||||
docker compose up -d
|
||||
#+END_SRC
|
||||
|
|
@ -201,8 +209,8 @@ sbcl --load quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(ql:a
|
|||
|
||||
*** Step 5: Clone and Setup Project
|
||||
#+BEGIN_SRC bash
|
||||
# Clone repository (replace with actual URL)
|
||||
git clone <repository-url> /opt/asteroid-radio
|
||||
# Clone repository
|
||||
git clone https://github.com/fade/asteroid /opt/asteroid-radio
|
||||
cd /opt/asteroid-radio
|
||||
|
||||
# Create required directories
|
||||
|
|
@ -380,7 +388,11 @@ sudo systemctl reload nginx
|
|||
|
||||
* Docker Management
|
||||
|
||||
** Container Management
|
||||
** Stream Services
|
||||
|
||||
The stream services can be managed using docker from inside the =docker= folder on this repository.
|
||||
|
||||
*** Container Management
|
||||
#+BEGIN_SRC bash
|
||||
# Start services
|
||||
docker compose up -d
|
||||
|
|
@ -395,11 +407,42 @@ docker compose logs -f
|
|||
docker compose restart
|
||||
#+END_SRC
|
||||
|
||||
** Docker Configuration
|
||||
*** Docker Configuration
|
||||
See =docker/docker-compose.yml= for complete Docker setup with Icecast2 and Liquidsoap containers. The setup includes:
|
||||
- **Icecast2**: Streaming server with three output formats
|
||||
- **Liquidsoap**: Audio processing and stream generation
|
||||
- **Music Volume**: Mounted from =./music/= directory
|
||||
- **Music Volume**: Mounted to the =./music/library= directory (can also be set with the =MUSIC_LIBRARY= environment variable)
|
||||
- *Queue Playlist*: Mounted to the =./stream-queue.m3u= file (can also be set with the =QUEUE_PLAYLIST= environment variable)
|
||||
|
||||
** Asteroid Radio Application
|
||||
|
||||
The asteroid radio application can also be served and managed using docker from inside the =docker= folder on this repository.
|
||||
|
||||
*** Container Management
|
||||
#+BEGIN_SRC bash
|
||||
# Build service
|
||||
docker compose -f docker-compose.asteroid.yml build
|
||||
|
||||
# Start service
|
||||
docker compose -f docker-compose.asteroid.yml up -d
|
||||
|
||||
# Stop service
|
||||
docker compose -f docker-compose.asteroid.yml down
|
||||
|
||||
# View logs
|
||||
docker compose -f docker-compose.asteroid.yml logs -f
|
||||
|
||||
# Restart service
|
||||
docker compose -f docker-compose.asteroid.yml restart
|
||||
#+END_SRC
|
||||
|
||||
*** Docker Configuration
|
||||
See =docker/docker-compose.asteroid.yml= for complete Docker setup, which includes:
|
||||
- Buils the application using the current cloned branch for the repository
|
||||
- Uses the host network for easy access to the stream endpoint
|
||||
- *Stream endpoint* mapped to =http://localhost:8000= (can also be set with the =ASTEROID_STREAM_URL= environment variable)
|
||||
- **Music Volume**: Mounted to the =./music/library= directory (can also be set with the =MUSIC_LIBRARY= environment variable)
|
||||
- *Queue Playlist*: Mounted to the =./stream-queue.m3u= file (can also be set with the =QUEUE_PLAYLIST= environment variable)
|
||||
|
||||
* Initial Configuration
|
||||
|
||||
|
|
@ -537,7 +580,7 @@ chmod +x ~/asteroid-radio/health-check.sh
|
|||
- Test stream connectivity from different networks
|
||||
|
||||
** Getting Support
|
||||
- Check project documentation and FAQ
|
||||
- Check project documentation
|
||||
- Review system logs for error messages
|
||||
- Submit issues with detailed system information
|
||||
- Join our IRC chat room: **#asteroid.music** on **irc.libera.chat**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Playlist System - Complete (MVP)
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-04
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: PostgreSQL Setup for Asteroid Radio
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-04
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,406 @@
|
|||
#+TITLE: Asteroid Radio - Project Development History
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-26
|
||||
#+DESCRIPTION: Comprehensive history of the Asteroid Radio project from inception to present
|
||||
|
||||
* Project Overview
|
||||
|
||||
Asteroid Radio is a web-based internet radio station built with Common Lisp, featuring a hacker-themed terminal aesthetic. The project combines the Radiance web framework with Icecast/Liquidsoap streaming infrastructure to create a full-featured music streaming platform.
|
||||
|
||||
** Technology Stack
|
||||
- *Backend*: Common Lisp (SBCL), Radiance web framework
|
||||
- *Streaming*: Icecast2, Liquidsoap
|
||||
- *Database*: PostgreSQL (configured, ready for migration)
|
||||
- *Frontend*: HTML5, JavaScript, CLIP templating, LASS (CSS in Lisp)
|
||||
- *Infrastructure*: Docker, Docker Compose
|
||||
|
||||
* Project Timeline
|
||||
|
||||
** Phase 1: Project Inception (August 2025)
|
||||
|
||||
*** 2025-08-12: Initial Commit
|
||||
- *Author*: Brian O'Reilly (Fade)
|
||||
- Project founded and initial repository created
|
||||
- Basic project structure established
|
||||
- Core Radiance framework integration begun
|
||||
|
||||
** Phase 2: Foundation Building (September - Early October 2025)
|
||||
|
||||
*** Core Features Established
|
||||
- Basic web server setup with Radiance
|
||||
- Initial music library scanning functionality
|
||||
- Database integration for track metadata
|
||||
- Basic authentication system
|
||||
- Front-end page structure
|
||||
|
||||
*** Key Contributors Join
|
||||
- Glenn Thompson (glenneth) begins major contributions
|
||||
- Luis Pereira joins for UI/UX improvements
|
||||
- Collaborative development model established
|
||||
|
||||
** Phase 3: Template System & UI Overhaul (October 2025)
|
||||
|
||||
*** 2025-10-04 to 2025-10-06: CLIP Template Migration
|
||||
- *Lead*: Luis Pereira, Glenn Thompson
|
||||
- Migrated from inline HTML to CLIP templating system
|
||||
- Established consistent site-wide styling
|
||||
- Implemented VT323 retro terminal font
|
||||
- Created reusable template components
|
||||
|
||||
*** 2025-10-04 to 2025-10-07: User Management System
|
||||
- *Lead*: Glenn Thompson
|
||||
- User profile pages with edit functionality
|
||||
- Registration and authentication UI
|
||||
- Role-based access control (admin, DJ, listener)
|
||||
- User profile management interface
|
||||
|
||||
*** 2025-10-05: Navigation Improvements
|
||||
- *Lead*: Luis Pereira
|
||||
- Unified navigation bar across all pages
|
||||
- Improved responsive design
|
||||
- Better mobile experience
|
||||
|
||||
** Phase 4: API Refactoring & Testing (October 8-10, 2025)
|
||||
|
||||
*** 2025-10-08: Major API Overhaul
|
||||
- *Lead*: Glenn Thompson
|
||||
- Refactored all endpoints to use Radiance's define-api macro
|
||||
- Standardized JSON API responses
|
||||
- API-aware authentication (auto-detects API vs web requests)
|
||||
- Comprehensive automated test suite added
|
||||
|
||||
*** 2025-10-08 to 2025-10-09: Frontend JavaScript Updates
|
||||
- Fixed all frontend code to work with new API endpoints
|
||||
- Improved error handling
|
||||
- Better async/await patterns
|
||||
|
||||
*** 2025-10-10: Documentation Sprint
|
||||
- *Lead*: Glenn Thompson
|
||||
- Major documentation cleanup
|
||||
- Added comprehensive API documentation
|
||||
- Created testing guides
|
||||
- Updated all core documentation files
|
||||
|
||||
** Phase 5: Streaming Infrastructure (October 8-14, 2025)
|
||||
|
||||
*** 2025-10-08: Liquidsoap DJ Controls
|
||||
- *Lead*: Glenn Thompson
|
||||
- Telnet integration with Liquidsoap
|
||||
- Real-time stream control
|
||||
- Skip track functionality
|
||||
- Queue management via telnet commands
|
||||
|
||||
*** 2025-10-10: Dynamic Stream URL Support
|
||||
- *Lead*: Glenn Thompson
|
||||
- Stream base URL as template variable
|
||||
- Support for multiple deployment environments
|
||||
- Preparation for multi-network access
|
||||
|
||||
*** 2025-10-14: Stream Queue System
|
||||
- *Lead*: Brian O'Reilly, Glenn Thompson
|
||||
- M3U playlist queue management
|
||||
- Admin UI for queue control
|
||||
- Add/remove tracks from stream queue
|
||||
- Real-time queue updates
|
||||
|
||||
*** 2025-10-14: Audio Quality Improvements
|
||||
- ReplayGain volume normalization
|
||||
- Reduced buffering
|
||||
- Improved player UI
|
||||
- Better streaming performance
|
||||
|
||||
** Phase 6: Advanced Features (October 12-17, 2025)
|
||||
|
||||
*** 2025-10-12: Role-Based Page Flow
|
||||
- *Lead*: Glenn Thompson
|
||||
- Intelligent page routing based on user role
|
||||
- Admin-specific workflows
|
||||
- DJ control interfaces
|
||||
- Enhanced user experience
|
||||
|
||||
*** 2025-10-13: HTML Partial Hydration
|
||||
- *Lead*: Luis Pereira
|
||||
- Now-playing partial component
|
||||
- Server-side rendering with client updates
|
||||
- Reduced JavaScript complexity
|
||||
- Better performance
|
||||
|
||||
*** 2025-10-15 to 2025-10-16: Configuration System
|
||||
- *Lead*: Brian O'Reilly
|
||||
- Dedicated configuration namespace exploration
|
||||
- Environment-based configuration
|
||||
- Improved deployment flexibility
|
||||
|
||||
*** 2025-10-16: Comprehensive Documentation Update
|
||||
- *Lead*: Glenn Thompson
|
||||
- PROJECT-OVERVIEW updated with all features
|
||||
- Stream queue and ReplayGain documentation
|
||||
- Complete feature documentation
|
||||
|
||||
*** 2025-10-17: Code Quality Improvements
|
||||
- *Lead*: Glenn Thompson
|
||||
- Code consistency refactoring
|
||||
- Bug fixes (track search query variable)
|
||||
- Maintainability improvements
|
||||
- Better code organization
|
||||
|
||||
** Phase 7: Player Evolution (October 19-25, 2025)
|
||||
|
||||
*** 2025-10-19: Pop-Out Player
|
||||
- *Lead*: Glenn Thompson
|
||||
- Standalone pop-out player window
|
||||
- Independent audio playback
|
||||
- Queue management improvements
|
||||
- Multi-window support
|
||||
|
||||
*** 2025-10-19: Persistent Audio Player (Frameset)
|
||||
- *Lead*: Glenn Thompson
|
||||
- Frameset-based persistent player
|
||||
- Audio continues during navigation
|
||||
- Bottom-frame player bar
|
||||
- Seamless listening experience
|
||||
|
||||
*** 2025-10-21: Hybrid Player System
|
||||
- *Lead*: Glenn Thompson
|
||||
- Combined frameset and pop-out options
|
||||
- User preference storage (localStorage)
|
||||
- Flexible playback modes
|
||||
- Enhanced user choice
|
||||
|
||||
*** 2025-10-24: Dynamic Stream URL Detection
|
||||
- *Lead*: Glenn Thompson
|
||||
- Automatic host detection from HTTP headers
|
||||
- Multi-environment support (localhost, Tailscale, LAN)
|
||||
- Fixed remote access issues
|
||||
- No configuration needed for different networks
|
||||
|
||||
*** 2025-10-25: Typography Consistency Fix
|
||||
- *Lead*: Glenn Thompson
|
||||
- Replaced Courier New with VT323 in persistent player
|
||||
- Consistent font usage site-wide
|
||||
- Addressed styling feedback
|
||||
- Improved visual coherence
|
||||
|
||||
** Phase 8: Docker Deployment & Documentation (October 26 - November 1, 2025)
|
||||
|
||||
*** 2025-10-19: User Initialization Retry Logic
|
||||
- *Lead*: Luis Pereira (easilok)
|
||||
- Fixed user initialization retry mechanism
|
||||
- Improved reliability on startup
|
||||
- Better error handling
|
||||
|
||||
*** 2025-10-26: Custom Environment Variables for Streams
|
||||
- *Lead*: Luis Pereira (easilok)
|
||||
- Added MUSIC_LIBRARY environment variable
|
||||
- Added QUEUE_PLAYLIST environment variable
|
||||
- Flexible path configuration for Docker deployments
|
||||
|
||||
*** 2025-10-26: Docker Setup for Asteroid Application
|
||||
- *Lead*: Luis Pereira (easilok)
|
||||
- Created Dockerfile.asteroid for app containerization
|
||||
- Added docker-compose.asteroid.yml
|
||||
- Radiance configuration for containerized deployment
|
||||
- Complete Docker-based deployment solution
|
||||
|
||||
*** 2025-10-26: Docker Deployment Documentation
|
||||
- *Lead*: Luis Pereira (easilok)
|
||||
- Comprehensive Docker deployment guide in INSTALLATION.org
|
||||
- Separate sections for stream services and application
|
||||
- Environment variable documentation
|
||||
- Build and deployment instructions
|
||||
|
||||
*** 2025-10-26: Comprehensive Documentation Update
|
||||
- *Lead*: Glenn Thompson
|
||||
- Created PROJECT-HISTORY.org with complete timeline
|
||||
- Updated all documentation dates to 2025-10-26
|
||||
- Added current features across all docs
|
||||
- Updated repository URLs to GitHub
|
||||
- Documentation version 3.0
|
||||
|
||||
*** 2025-10-28: Documentation Refinements
|
||||
- *Lead*: Glenn Thompson
|
||||
- Fixed music directory location (asteroid/music/ not docker/music/)
|
||||
- Removed redundant Python/JavaScript examples from API docs
|
||||
- Added package manager notes for cross-distribution compatibility
|
||||
- Clarified symlink support for music directories
|
||||
|
||||
*** 2025-11-01: Documentation Merge and Cleanup
|
||||
- *Lead*: Glenn Thompson
|
||||
- Merged upstream Docker deployment documentation
|
||||
- Removed obsolete session notes
|
||||
- Synchronized with upstream/main
|
||||
- Prepared comprehensive documentation PR
|
||||
|
||||
* Development Statistics
|
||||
|
||||
** Contributors (by commit count)
|
||||
1. Glenn Thompson (glenneth/Glenneth) - 135+ commits
|
||||
2. Brian O'Reilly (Fade) - 55+ commits
|
||||
3. Luis Pereira (easilok) - 23+ commits
|
||||
|
||||
** Total Commits: 213+ commits
|
||||
|
||||
** Active Development Period
|
||||
- Start: August 12, 2025
|
||||
- Current: November 1, 2025
|
||||
- Duration: ~2.75 months of active development
|
||||
|
||||
* Major Features Implemented
|
||||
|
||||
** Core Functionality
|
||||
- ✅ Music library scanning and metadata extraction
|
||||
- ✅ PostgreSQL database integration (configured, ready for migration)
|
||||
- ✅ Track search and filtering
|
||||
- ✅ Playlist management
|
||||
- ✅ Stream queue control
|
||||
- ✅ Live streaming via Icecast/Liquidsoap
|
||||
|
||||
** User Management
|
||||
- ✅ User registration and authentication
|
||||
- ✅ Role-based access control (Admin, DJ, Listener)
|
||||
- ✅ User profiles with edit functionality
|
||||
- ✅ Session management
|
||||
- ✅ Role-based page flow
|
||||
|
||||
** Streaming Features
|
||||
- ✅ Multiple quality options (AAC 96k, MP3 128k, MP3 64k)
|
||||
- ✅ ReplayGain volume normalization
|
||||
- ✅ Live now-playing information
|
||||
- ✅ Icecast integration
|
||||
- ✅ Liquidsoap DJ controls
|
||||
- ✅ Stream queue management
|
||||
|
||||
** Player Options
|
||||
- ✅ Inline web player
|
||||
- ✅ Pop-out player window
|
||||
- ✅ Persistent frameset player
|
||||
- ✅ Hybrid player system
|
||||
- ✅ Quality selector
|
||||
- ✅ Auto-reconnect on errors
|
||||
|
||||
** API & Integration
|
||||
- ✅ RESTful JSON API
|
||||
- ✅ API-aware authentication
|
||||
- ✅ Comprehensive test suite
|
||||
- ✅ Telnet integration with Liquidsoap
|
||||
- ✅ Real-time status updates
|
||||
|
||||
** UI/UX
|
||||
- ✅ Retro terminal aesthetic (VT323 font)
|
||||
- ✅ Responsive design
|
||||
- ✅ CLIP templating system
|
||||
- ✅ LASS CSS preprocessing
|
||||
- ✅ Consistent navigation
|
||||
- ✅ HTML partial hydration
|
||||
|
||||
** Infrastructure
|
||||
- ✅ Docker containerization (streams and application)
|
||||
- ✅ Docker Compose orchestration
|
||||
- ✅ Dockerfile for Asteroid application
|
||||
- ✅ Environment variable configuration
|
||||
- ✅ PostgreSQL database (configured)
|
||||
- ✅ Multi-environment support
|
||||
- ✅ Dynamic URL detection
|
||||
|
||||
* Technical Milestones
|
||||
|
||||
** Architecture Evolution
|
||||
1. *Initial*: Monolithic HTML generation
|
||||
2. *Template Migration*: CLIP templating system
|
||||
3. *API Standardization*: Radiance define-api macros
|
||||
4. *Component Architecture*: HTML partials and hydration
|
||||
5. *Multi-Mode Player*: Hybrid player system
|
||||
|
||||
** Code Quality Improvements
|
||||
- Comprehensive test suite
|
||||
- API refactoring for consistency
|
||||
- Code organization and maintainability
|
||||
- Documentation standards
|
||||
- Consistent error handling
|
||||
|
||||
** Performance Optimizations
|
||||
- ReplayGain normalization
|
||||
- Reduced buffering
|
||||
- Efficient database queries
|
||||
- Parallel music scanning
|
||||
- Client-side caching
|
||||
|
||||
* Current State (November 2025)
|
||||
|
||||
** Production Ready Features
|
||||
- Full music streaming platform
|
||||
- User management system
|
||||
- Admin control panel
|
||||
- DJ controls
|
||||
- Multiple player modes
|
||||
- Complete Docker deployment (streams + application)
|
||||
- Multi-environment support with dynamic URLs
|
||||
- Comprehensive documentation
|
||||
|
||||
** Active Development Areas
|
||||
- PostgreSQL migration (configured, ready for data migration)
|
||||
- JavaScript code cleanup and refactoring
|
||||
- Additional UI improvements
|
||||
- Performance optimization
|
||||
- Feature expansion based on user feedback
|
||||
|
||||
** Recent Achievements
|
||||
- ✅ Complete Docker containerization
|
||||
- ✅ Environment variable configuration
|
||||
- ✅ Comprehensive documentation overhaul
|
||||
- ✅ Cross-distribution package manager support
|
||||
- ✅ Streamlined deployment process
|
||||
|
||||
** Known Issues & Future Work
|
||||
- PostgreSQL migration (configured, pending data migration)
|
||||
- Continued UI/UX refinement
|
||||
- Additional streaming features (per design.org)
|
||||
- Enhanced playlist functionality
|
||||
- Live chat and song requests
|
||||
- Mobile app considerations
|
||||
- Scalability improvements
|
||||
|
||||
* Project Philosophy
|
||||
|
||||
** Design Principles
|
||||
- *Hacker Aesthetic*: Terminal-inspired retro design
|
||||
- *User Choice*: Multiple player modes and options
|
||||
- *Simplicity*: Clean, focused interface
|
||||
- *Performance*: Fast, responsive experience
|
||||
- *Flexibility*: Multi-environment support
|
||||
|
||||
** Development Approach
|
||||
- Collaborative development
|
||||
- Iterative improvements
|
||||
- Comprehensive testing
|
||||
- Documentation-first
|
||||
- User feedback driven
|
||||
|
||||
* Acknowledgments
|
||||
|
||||
** Core Team
|
||||
- *Brian O'Reilly (Fade)*: Project founder, architecture, streaming infrastructure
|
||||
- *Glenn Thompson (glenneth)*: Major features, API, player systems, documentation
|
||||
- *Luis Pereira*: UI/UX, templating, frontend improvements
|
||||
|
||||
** Technologies
|
||||
- Radiance web framework
|
||||
- Icecast streaming server
|
||||
- Liquidsoap audio processing
|
||||
- PostgreSQL database
|
||||
- Common Lisp ecosystem
|
||||
|
||||
* Conclusion
|
||||
|
||||
Asteroid Radio has evolved from a simple concept into a full-featured internet radio platform in just 2.75 months of active development. The project demonstrates the power of Common Lisp for web development and the collaborative nature of open-source development.
|
||||
|
||||
With complete Docker deployment, comprehensive documentation, and a growing feature set, Asteroid Radio is ready for production use while continuing to evolve with regular improvements, bug fixes, and new features based on user needs and technical requirements.
|
||||
|
||||
** Project Links
|
||||
- Repository: https://github.com/fade/asteroid
|
||||
- Contributors: https://github.com/fade/asteroid/graphs/contributors
|
||||
- IRC: #asteroid.music on irc.libera.chat
|
||||
|
||||
---
|
||||
|
||||
*Last Updated: 2025-11-01*
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Asteroid Radio - Project Overview
|
||||
#+AUTHOR: Glenn Thompson & Brian O'Reilly (Fade)
|
||||
#+DATE: 2025-10-03
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* 🎯 Mission
|
||||
|
||||
|
|
@ -38,7 +38,8 @@ Asteroid Radio is a modern, web-based music streaming platform designed for hack
|
|||
- **Common Lisp** (SBCL) - Core application language
|
||||
- **Radiance Framework** - Web framework and module system
|
||||
- **LASS** - CSS preprocessing in Lisp
|
||||
- **PostgreSQL** - Database backend for user accounts and metadata
|
||||
- **PostgreSQL** - Database backend (configured, ready for migration)
|
||||
- **Radiance DB** - Current database abstraction layer
|
||||
|
||||
**Frontend:**
|
||||
- **HTML5** with semantic templates
|
||||
|
|
@ -75,26 +76,32 @@ Asteroid Radio is a modern, web-based music streaming platform designed for hack
|
|||
## 🚀 Features
|
||||
|
||||
### Current Features
|
||||
- ✅ **User Authentication** - Registration, login, profiles, role-based access
|
||||
- ✅ **User Authentication** - Registration, login, profiles, role-based access (Admin/DJ/Listener)
|
||||
- ✅ **User Management** - Admin interface for user administration
|
||||
- ✅ **Music Library** - Track management with pagination and search
|
||||
- ✅ **Music Library** - Track management with pagination, search, and filtering
|
||||
- ✅ **User Playlists** - Create, manage, and play personal music collections
|
||||
- ✅ **Web Player** - Browser-based player with queue management
|
||||
- ✅ **Multiple Player Modes** - Inline, pop-out, and persistent frameset players
|
||||
- ✅ **Stream Queue Control** - Admin control over broadcast stream queue (M3U-based)
|
||||
- ✅ **REST API** - Comprehensive JSON API with 15+ endpoints
|
||||
- ✅ **Music Streaming** - Multiple quality formats (MP3, AAC)
|
||||
- ✅ **Music Streaming** - Multiple quality formats (128k MP3, 96k AAC, 64k MP3)
|
||||
- ✅ **Rate Limiting** - Anti-abuse protection
|
||||
- ✅ **Docker Integration** - Icecast2/Liquidsoap streaming infrastructure
|
||||
- ✅ **PostgreSQL Database** - Persistent data storage
|
||||
- ✅ **PostgreSQL Database** - Configured and ready for migration
|
||||
- ✅ **Liquidsoap DJ Controls** - Telnet interface for live control
|
||||
- ✅ **Dynamic Stream URLs** - Automatic host detection for multi-environment support
|
||||
- ✅ **ReplayGain Normalization** - Consistent audio volume across tracks
|
||||
- ✅ **Responsive Design** - Works on desktop and mobile
|
||||
- ✅ **Automated Testing** - Comprehensive test suite
|
||||
|
||||
### Planned Features
|
||||
- 🔄 **PostgreSQL Migration** - Full migration from Radiance DB to PostgreSQL
|
||||
- 🔄 **Enhanced Playlist Management** - Full CRUD operations with PostgreSQL
|
||||
- 🔄 **Social Features** - Playlist sharing and discovery
|
||||
- 🔄 **Advanced Search** - Full-text search and filtering
|
||||
- 🔄 **Mobile App** - Native mobile applications
|
||||
- 🔄 **WebSocket Support** - Real-time updates
|
||||
- 🔄 **Analytics** - Listening statistics and insights
|
||||
- 🔄 **Scheduled Programming** - Time-based queue switching
|
||||
|
||||
|
||||
## 🔮 Vision
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Asteroid Radio - Documentation Index
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-10
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Welcome to Asteroid Radio Documentation
|
||||
|
||||
|
|
@ -19,6 +19,9 @@ For immediate setup, see:
|
|||
*** [[file:PROJECT-OVERVIEW.org][Project Overview]]
|
||||
Complete overview of Asteroid Radio's architecture, technology stack, and vision. Start here to understand what Asteroid Radio is and how it works.
|
||||
|
||||
*** [[file:PROJECT-HISTORY.org][Project History]]
|
||||
Comprehensive development history from inception to present, including timeline, milestones, and contributor information.
|
||||
|
||||
*** [[file:INSTALLATION.org][Installation Guide]]
|
||||
Comprehensive installation instructions for multiple operating systems, including system requirements, dependencies, and production deployment considerations.
|
||||
|
||||
|
|
@ -58,16 +61,19 @@ Pagination system for efficient browsing of large music libraries.
|
|||
** What's Working Now
|
||||
- **Web Application**: Full-featured web interface with authentication
|
||||
- **REST API**: JSON API with 15+ endpoints for programmatic access
|
||||
- **User Management**: Registration, login, roles, and profiles
|
||||
- **Music Library**: Track management with pagination and search
|
||||
- **User Management**: Registration, login, roles (Admin/DJ/Listener), and profiles
|
||||
- **Music Library**: Track management with pagination, search, and filtering
|
||||
- **Playlists**: User playlists with creation and playback
|
||||
- **Web Player**: Browser-based audio player with queue management
|
||||
- **Multiple Player Modes**: Inline, pop-out, and persistent frameset players
|
||||
- **Stream Queue Control**: Admin control over broadcast stream queue
|
||||
- **Docker Streaming Infrastructure**: Icecast2 + Liquidsoap containers
|
||||
- **Three Quality Streams**: 128kbps MP3, 96kbps AAC, 64kbps MP3
|
||||
- **Admin Interface**: Icecast web admin at http://localhost:8000/admin/
|
||||
- **Liquidsoap DJ Controls**: Telnet control via localhost:1234
|
||||
- **Professional Features**: Crossfading, normalization, metadata support
|
||||
- **PostgreSQL Database**: Persistent data storage with full CRUD operations
|
||||
- **Professional Features**: Crossfading, ReplayGain normalization, metadata support
|
||||
- **PostgreSQL Database**: Configured and ready for migration
|
||||
- **Dynamic Stream URLs**: Automatic host detection for multi-environment support
|
||||
- **Responsive Design**: Works on desktop and mobile devices
|
||||
|
||||
** Stream URLs (when running)
|
||||
- **High Quality MP3**: http://localhost:8000/asteroid.mp3 (128kbps)
|
||||
|
|
@ -141,5 +147,5 @@ For detailed technical information, see the **[[file:PROJECT-OVERVIEW.org][Proje
|
|||
|
||||
---
|
||||
|
||||
*Last Updated: 2025-10-10*
|
||||
*Documentation Version: 2.0*
|
||||
*Last Updated: 2025-10-26*
|
||||
*Documentation Version: 3.0*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,209 @@
|
|||
#+TITLE: Stream Queue Control System
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
The stream queue control system allows administrators to manage what plays on the main Asteroid Radio broadcast stream. Instead of random playback from the music library, you can now curate the exact order of tracks.
|
||||
|
||||
* How It Works
|
||||
|
||||
1. *Stream Queue* - An ordered list of track IDs maintained in memory
|
||||
2. *M3U Generation* - The queue is converted to a =stream-queue.m3u= file
|
||||
3. *Liquidsoap Integration* - Liquidsoap reads the M3U file and reloads it every 60 seconds
|
||||
4. *Fallback* - If the queue is empty, Liquidsoap falls back to random directory playback
|
||||
|
||||
* API Endpoints (Admin Only)
|
||||
|
||||
All endpoints require admin authentication.
|
||||
|
||||
** Get Current Queue
|
||||
#+BEGIN_SRC
|
||||
GET /api/asteroid/stream/queue
|
||||
#+END_SRC
|
||||
|
||||
Returns the current stream queue with track details.
|
||||
|
||||
** Add Track to Queue
|
||||
#+BEGIN_SRC
|
||||
POST /api/asteroid/stream/queue/add
|
||||
Parameters:
|
||||
- track_id: ID of track to add
|
||||
- position: "end" (default) or "next"
|
||||
#+END_SRC
|
||||
|
||||
Adds a track to the end of the queue or as the next track to play.
|
||||
|
||||
** Remove Track from Queue
|
||||
#+BEGIN_SRC
|
||||
POST /api/asteroid/stream/queue/remove
|
||||
Parameters:
|
||||
- track_id: ID of track to remove
|
||||
#+END_SRC
|
||||
|
||||
Removes a specific track from the queue.
|
||||
|
||||
** Clear Queue
|
||||
#+BEGIN_SRC
|
||||
POST /api/asteroid/stream/queue/clear
|
||||
#+END_SRC
|
||||
|
||||
Clears the entire queue (will fall back to random playback).
|
||||
|
||||
** Add Playlist to Queue
|
||||
#+BEGIN_SRC
|
||||
POST /api/asteroid/stream/queue/add-playlist
|
||||
Parameters:
|
||||
- playlist_id: ID of playlist to add
|
||||
#+END_SRC
|
||||
|
||||
Adds all tracks from a user playlist to the stream queue.
|
||||
|
||||
** Reorder Queue
|
||||
#+BEGIN_SRC
|
||||
POST /api/asteroid/stream/queue/reorder
|
||||
Parameters:
|
||||
- track_ids: Comma-separated list of track IDs in desired order
|
||||
#+END_SRC
|
||||
|
||||
Completely reorders the queue with a new track order.
|
||||
|
||||
* Usage Examples
|
||||
|
||||
** Building a Stream Queue
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
# Add a specific track to the end
|
||||
curl -X POST http://localhost:8080/api/asteroid/stream/queue/add \
|
||||
-d "track-id=42" \
|
||||
-H "Cookie: radiance-session=..."
|
||||
|
||||
# Add a track to play next
|
||||
curl -X POST http://localhost:8080/api/asteroid/stream/queue/add \
|
||||
-d "track-id=43&position=next" \
|
||||
-H "Cookie: radiance-session=..."
|
||||
|
||||
# Add an entire playlist
|
||||
curl -X POST http://localhost:8080/api/asteroid/stream/queue/add-playlist \
|
||||
-d "playlist-id=5" \
|
||||
-H "Cookie: radiance-session=..."
|
||||
#+END_SRC
|
||||
|
||||
** Managing the Queue
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
# View current queue
|
||||
curl http://localhost:8080/api/asteroid/stream/queue \
|
||||
-H "Cookie: radiance-session=..."
|
||||
|
||||
# Remove a track
|
||||
curl -X POST http://localhost:8080/api/asteroid/stream/queue/remove \
|
||||
-d "track-id=42" \
|
||||
-H "Cookie: radiance-session=..."
|
||||
|
||||
# Clear everything
|
||||
curl -X POST http://localhost:8080/api/asteroid/stream/queue/clear \
|
||||
-H "Cookie: radiance-session=..."
|
||||
#+END_SRC
|
||||
|
||||
* Lisp Functions
|
||||
|
||||
If you're working directly in the Lisp REPL:
|
||||
|
||||
#+BEGIN_SRC lisp
|
||||
;; Add tracks to queue
|
||||
(add-to-stream-queue 42 :end)
|
||||
(add-to-stream-queue 43 :next)
|
||||
|
||||
;; View queue
|
||||
(get-stream-queue)
|
||||
|
||||
;; Add a playlist
|
||||
(add-playlist-to-stream-queue 5)
|
||||
|
||||
;; Remove a track
|
||||
(remove-from-stream-queue 42)
|
||||
|
||||
;; Clear queue
|
||||
(clear-stream-queue)
|
||||
|
||||
;; Reorder queue
|
||||
(reorder-stream-queue '(43 44 45 46))
|
||||
|
||||
;; Build smart queues
|
||||
(build-smart-queue "electronic" 20)
|
||||
(build-queue-from-artist "Nine Inch Nails" 15)
|
||||
|
||||
;; Manually regenerate playlist file
|
||||
(regenerate-stream-playlist)
|
||||
#+END_SRC
|
||||
|
||||
* File Locations
|
||||
|
||||
- *Stream Queue File*: =stream-queue.m3u= (in project root)
|
||||
- *Docker Mount*: =/app/stream-queue.m3u= (inside Liquidsoap container)
|
||||
- *Liquidsoap Config*: =docker/asteroid-radio-docker.liq=
|
||||
|
||||
* How Liquidsoap Reads Updates
|
||||
|
||||
The Liquidsoap configuration reloads the playlist file every 60 seconds:
|
||||
|
||||
#+BEGIN_SRC liquidsoap
|
||||
radio = playlist.safe(
|
||||
mode="normal",
|
||||
reload=60,
|
||||
"/app/stream-queue.m3u"
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
This means changes to the queue will take effect within 1 minute.
|
||||
|
||||
* Stream History
|
||||
|
||||
The system also tracks recently played tracks:
|
||||
|
||||
#+BEGIN_SRC lisp
|
||||
;; Get last 10 played tracks
|
||||
(get-stream-history 10)
|
||||
|
||||
;; Add to history (usually automatic)
|
||||
(add-to-stream-history 42)
|
||||
#+END_SRC
|
||||
|
||||
* Future Enhancements
|
||||
|
||||
- [ ] Web UI for queue management (drag-and-drop reordering)
|
||||
- [ ] Telnet integration for real-time skip/next commands
|
||||
- [ ] Scheduled programming (time-based queue switching)
|
||||
- [ ] Auto-queue filling (automatically add tracks when queue runs low)
|
||||
- [ ] Genre-based smart queues
|
||||
- [ ] Listener request system
|
||||
|
||||
* Troubleshooting
|
||||
|
||||
** Queue changes not taking effect
|
||||
|
||||
- Wait up to 60 seconds for Liquidsoap to reload
|
||||
- Check that =stream-queue.m3u= was generated correctly
|
||||
- Verify Docker volume mount is working: =docker exec asteroid-liquidsoap ls -la /app/stream-queue.m3u=
|
||||
- Check Liquidsoap logs: =docker logs asteroid-liquidsoap=
|
||||
|
||||
** Empty queue falls back to random
|
||||
|
||||
This is expected behavior. The system will play random tracks from the music library when the queue is empty to ensure continuous streaming.
|
||||
|
||||
** Playlist file not updating
|
||||
|
||||
- Ensure Asteroid server has write permissions to the project directory
|
||||
- Check that =regenerate-stream-playlist= is being called after queue modifications
|
||||
- Verify the file exists: =ls -la stream-queue.m3u=
|
||||
|
||||
* Integration with Admin Interface
|
||||
|
||||
The stream control system is designed to be integrated into the admin web interface. Future work will add:
|
||||
|
||||
- Visual queue editor with drag-and-drop
|
||||
- "Add to Stream Queue" buttons on track listings
|
||||
- "Queue Playlist" buttons on playlist pages
|
||||
- Real-time queue display showing what's currently playing
|
||||
- Skip/Next controls for immediate playback changes (via Telnet)
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
#+TITLE: Asteroid Radio Testing Guide
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-08
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
This document describes the automated testing system for Asteroid Radio.
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
*Note on Package Managers*: Examples use =apt= (Debian/Ubuntu). Replace with your distribution's package manager (=dnf=, =pacman=, =zypper=, =apk=, etc.).
|
||||
#+END_QUOTE
|
||||
|
||||
* Test Script
|
||||
|
||||
The =test-server.sh= script provides comprehensive testing of all server endpoints and functionality.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: Track Pagination System - Complete
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-04
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#+TITLE: User Management System - Complete
|
||||
#+AUTHOR: Asteroid Radio Development Team
|
||||
#+DATE: 2025-10-04
|
||||
#+DATE: 2025-10-26
|
||||
|
||||
* Overview
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
(in-package :asteroid)
|
||||
|
||||
(defun icecast-now-playing (icecast-base-url)
|
||||
(let* ((icecast-url (format nil "~a/admin/stats.xml" icecast-base-url))
|
||||
(response (drakma:http-request icecast-url
|
||||
:want-stream nil
|
||||
:basic-authorization '("admin" "asteroid_admin_2024"))))
|
||||
(when response
|
||||
(let ((xml-string (if (stringp response)
|
||||
response
|
||||
(babel:octets-to-string response :encoding :utf-8))))
|
||||
;; Simple XML parsing to extract source information
|
||||
;; Look for <source mount="/asteroid.mp3"> sections and extract title, listeners, etc.
|
||||
(multiple-value-bind (match-start match-end)
|
||||
(cl-ppcre:scan "<source mount=\"/asteroid\\.mp3\">" xml-string)
|
||||
|
||||
(if match-start
|
||||
(let* ((source-section (subseq xml-string match-start
|
||||
(or (cl-ppcre:scan "</source>" xml-string :start match-start)
|
||||
(length xml-string))))
|
||||
(titlep (cl-ppcre:all-matches "<title>" source-section))
|
||||
(listenersp (cl-ppcre:all-matches "<listeners>" source-section))
|
||||
(title (if titlep (cl-ppcre:regex-replace-all ".*<title>(.*?)</title>.*" source-section "\\1") "Unknown"))
|
||||
(listeners (if listenersp (cl-ppcre:regex-replace-all ".*<listeners>(.*?)</listeners>.*" source-section "\\1") "0")))
|
||||
`((:listenurl . ,(format nil "~a/asteroid.mp3" *stream-base-url*))
|
||||
(:title . ,title)
|
||||
(:listeners . ,(parse-integer listeners :junk-allowed t))))
|
||||
`((:listenurl . ,(format nil "~a/asteroid.mp3" *stream-base-url*))
|
||||
(:title . "Unknown")
|
||||
(:listeners . "Unknown"))))))))
|
||||
|
||||
(define-api asteroid/partial/now-playing () ()
|
||||
"Get Partial HTML with live status from Icecast server"
|
||||
(handler-case
|
||||
(let ((now-playing-stats (icecast-now-playing *stream-base-url*)))
|
||||
(if now-playing-stats
|
||||
(progn
|
||||
;; TODO: it should be able to define a custom api-output for this
|
||||
;; (api-output <clip-parser> :format "html"))
|
||||
(setf (header "Content-Type") "text/html")
|
||||
(clip:process-to-string
|
||||
(load-template "partial/now-playing")
|
||||
:stats now-playing-stats))
|
||||
(progn
|
||||
(setf (header "Content-Type") "text/html")
|
||||
(clip:process-to-string
|
||||
(load-template "partial/now-playing")
|
||||
:connection-error t
|
||||
:stats nil))))
|
||||
(error (e)
|
||||
(api-output `(("status" . "error")
|
||||
("message" . ,(format nil "Error loading profile: ~a" e)))
|
||||
:status 500))))
|
||||
|
||||
(define-api asteroid/partial/now-playing-inline () ()
|
||||
"Get inline text with now playing info (for admin dashboard and widgets)"
|
||||
(handler-case
|
||||
(let ((now-playing-stats (icecast-now-playing *stream-base-url*)))
|
||||
(if now-playing-stats
|
||||
(progn
|
||||
(setf (header "Content-Type") "text/plain")
|
||||
(cdr (assoc :title now-playing-stats)))
|
||||
(progn
|
||||
(setf (header "Content-Type") "text/plain")
|
||||
"Stream Offline")))
|
||||
(error (e)
|
||||
(setf (header "Content-Type") "text/plain")
|
||||
"Error loading stream info")))
|
||||
|
|
@ -8,7 +8,7 @@ body{
|
|||
color: #00ffff;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
box-sizing: boder-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body .container{
|
||||
|
|
@ -136,7 +136,7 @@ body .now-playing{
|
|||
margin: 20px 0;
|
||||
font-size: 1.5em;
|
||||
color: #4488ff;
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
body .back{
|
||||
|
|
@ -175,7 +175,7 @@ body .player-section{
|
|||
}
|
||||
|
||||
body .player-section .live-stream{
|
||||
overflow: scroll;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -393,6 +393,7 @@ body .playlist-input{
|
|||
color: #00ffff;
|
||||
border: 1px solid #2a3441;
|
||||
font-family: Courier New, monospace;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body .playlist-list{
|
||||
|
|
@ -431,6 +432,89 @@ body .queue-item:last-child{
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
body .queue-position{
|
||||
background: #00ff00;
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
border-radius: 3px;
|
||||
font-weight: bold;
|
||||
margin-right: 10px;
|
||||
min-width: 30px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
body .queue-track-info{
|
||||
flex: 1;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
body .queue-track-info.track-title{
|
||||
font-weight: bold;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
body .queue-track-info.track-artist{
|
||||
font-size: 0.9em;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
body .queue-actions{
|
||||
margin-top: 20px;
|
||||
padding: 15px;
|
||||
background: #0a0a0a;
|
||||
border: 1px solid #2a3441;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
body .queue-list{
|
||||
border: 1px solid #2a3441;
|
||||
background: #0a0a0a;
|
||||
min-height: 200px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
body .search-results{
|
||||
margin-top: 10px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
body .search-result-item{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border: 1px solid #2a3441;
|
||||
margin-bottom: 5px;
|
||||
background: #0a0a0a;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
body .search-result-item:hover{
|
||||
background: #1a1a1a;
|
||||
border-color: #00ff00;
|
||||
}
|
||||
|
||||
body .search-result-item.track-info{
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
body .search-result-item.track-actions{
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
body .empty-state{
|
||||
text-align: center;
|
||||
color: #666;
|
||||
padding: 30px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
body .empty-queue{
|
||||
text-align: center;
|
||||
color: #666;
|
||||
|
|
@ -929,3 +1013,16 @@ body .stat-card .stat-label{
|
|||
font-size: 0.875rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
@media (max-width: 576px){
|
||||
body .playlist-controls{
|
||||
display: block;
|
||||
}
|
||||
body .playlist-controls >*{
|
||||
width: 100%;
|
||||
}
|
||||
body .playlist-controls button{
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
:color "#00ffff"
|
||||
:margin 0
|
||||
:padding "20px"
|
||||
:box-sizing "boder-box"
|
||||
:box-sizing "border-box"
|
||||
|
||||
(.container
|
||||
:max-width "1200px"
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
:margin "20px 0"
|
||||
:font-size "1.5em"
|
||||
:color "#4488ff"
|
||||
:overflow "scroll")
|
||||
:overflow auto)
|
||||
|
||||
(.back
|
||||
:color "#00ffff"
|
||||
|
|
@ -150,7 +150,7 @@
|
|||
:margin "20px 0"
|
||||
:border-radius "5px"
|
||||
(.live-stream
|
||||
:overflow "scroll") )
|
||||
:overflow auto) )
|
||||
|
||||
(.live-stream
|
||||
(.live-stream-quality
|
||||
|
|
@ -315,7 +315,8 @@
|
|||
:background "#0a0a0a"
|
||||
:color "#00ffff"
|
||||
:border "1px solid #2a3441"
|
||||
:font-family "Courier New, monospace")
|
||||
:font-family "Courier New, monospace"
|
||||
:box-sizing "border-box")
|
||||
|
||||
(.playlist-list
|
||||
:border "1px solid #2a3441"
|
||||
|
|
@ -347,6 +348,77 @@
|
|||
:border-bottom none
|
||||
:margin-bottom 0)
|
||||
|
||||
(.queue-position
|
||||
:background "#00ff00"
|
||||
:color "#000"
|
||||
:padding "4px 8px"
|
||||
:border-radius "3px"
|
||||
:font-weight bold
|
||||
:margin-right "10px"
|
||||
:min-width "30px"
|
||||
:text-align center
|
||||
:display inline-block)
|
||||
|
||||
(.queue-track-info
|
||||
:flex 1
|
||||
:margin-right "10px")
|
||||
|
||||
((:and .queue-track-info .track-title)
|
||||
:font-weight bold
|
||||
:margin-bottom "2px")
|
||||
|
||||
((:and .queue-track-info .track-artist)
|
||||
:font-size "0.9em"
|
||||
:color "#888")
|
||||
|
||||
(.queue-actions
|
||||
:margin-top "20px"
|
||||
:padding "15px"
|
||||
:background "#0a0a0a"
|
||||
:border "1px solid #2a3441"
|
||||
:border-radius "4px")
|
||||
|
||||
(.queue-list
|
||||
:border "1px solid #2a3441"
|
||||
:background "#0a0a0a"
|
||||
:min-height "200px"
|
||||
:max-height "400px"
|
||||
:overflow-y auto
|
||||
:padding "10px"
|
||||
:margin-bottom "20px")
|
||||
|
||||
(.search-results
|
||||
:margin-top "10px"
|
||||
:max-height "300px"
|
||||
:overflow-y auto)
|
||||
|
||||
(.search-result-item
|
||||
:display flex
|
||||
:justify-content space-between
|
||||
:align-items center
|
||||
:padding "10px"
|
||||
:border "1px solid #2a3441"
|
||||
:margin-bottom "5px"
|
||||
:background "#0a0a0a"
|
||||
:border-radius "3px")
|
||||
|
||||
((:and .search-result-item :hover)
|
||||
:background "#1a1a1a"
|
||||
:border-color "#00ff00")
|
||||
|
||||
((:and .search-result-item .track-info)
|
||||
:flex 1)
|
||||
|
||||
((:and .search-result-item .track-actions)
|
||||
:display flex
|
||||
:gap "5px")
|
||||
|
||||
(.empty-state
|
||||
:text-align center
|
||||
:color "#666"
|
||||
:padding "30px"
|
||||
:font-style italic)
|
||||
|
||||
(.empty-queue
|
||||
:text-align center
|
||||
:color "#666"
|
||||
|
|
@ -740,4 +812,14 @@
|
|||
;; :text-align center)
|
||||
|
||||
) ;; Close main body block
|
||||
|
||||
;; media queries for reponsiveness
|
||||
(:media "(max-width: 576px)"
|
||||
(body
|
||||
(.playlist-controls
|
||||
:display block
|
||||
;;:width "100%"
|
||||
(>* :width "100%")
|
||||
(button :margin-left 0
|
||||
:margin-right 0))))
|
||||
) ;; End of let block
|
||||
|
|
|
|||
|
|
@ -25,6 +25,32 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
document.getElementById('player-pause').addEventListener('click', pausePlayer);
|
||||
document.getElementById('player-stop').addEventListener('click', stopPlayer);
|
||||
document.getElementById('player-resume').addEventListener('click', resumePlayer);
|
||||
|
||||
// Queue controls
|
||||
const refreshQueueBtn = document.getElementById('refresh-queue');
|
||||
const loadFromM3uBtn = document.getElementById('load-from-m3u');
|
||||
const clearQueueBtn = document.getElementById('clear-queue-btn');
|
||||
const addRandomBtn = document.getElementById('add-random-tracks');
|
||||
const queueSearchInput = document.getElementById('queue-track-search');
|
||||
|
||||
if (refreshQueueBtn) refreshQueueBtn.addEventListener('click', loadStreamQueue);
|
||||
if (loadFromM3uBtn) loadFromM3uBtn.addEventListener('click', loadQueueFromM3U);
|
||||
if (clearQueueBtn) clearQueueBtn.addEventListener('click', clearStreamQueue);
|
||||
if (addRandomBtn) addRandomBtn.addEventListener('click', addRandomTracks);
|
||||
if (queueSearchInput) queueSearchInput.addEventListener('input', searchTracksForQueue);
|
||||
|
||||
// Load initial queue
|
||||
loadStreamQueue();
|
||||
|
||||
// Setup live stream monitor
|
||||
const liveAudio = document.getElementById('live-stream-audio');
|
||||
if (liveAudio) {
|
||||
liveAudio.preload = 'none';
|
||||
}
|
||||
|
||||
// Update live stream info
|
||||
updateLiveStreamInfo();
|
||||
setInterval(updateLiveStreamInfo, 10000); // Every 10 seconds
|
||||
});
|
||||
|
||||
// Load tracks from API
|
||||
|
|
@ -79,8 +105,7 @@ function renderPage() {
|
|||
<div class="track-album">${track.album || 'Unknown Album'}</div>
|
||||
</div>
|
||||
<div class="track-actions">
|
||||
<button onclick="playTrack(${track.id})" class="btn btn-sm btn-success">▶️ Play</button>
|
||||
<button onclick="streamTrack(${track.id})" class="btn btn-sm btn-info">🎵 Stream</button>
|
||||
<button onclick="addToQueue(${track.id}, 'end')" class="btn btn-sm btn-primary">➕ Add to Queue</button>
|
||||
<button onclick="deleteTrack(${track.id})" class="btn btn-sm btn-danger">🗑️ Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -160,6 +185,7 @@ async function scanLibrary() {
|
|||
|
||||
// Filter tracks based on search
|
||||
function filterTracks() {
|
||||
const query = document.getElementById('track-search').value.toLowerCase();
|
||||
const filtered = tracks.filter(track =>
|
||||
(track.title || '').toLowerCase().includes(query) ||
|
||||
(track.artist || '').toLowerCase().includes(query) ||
|
||||
|
|
@ -304,3 +330,331 @@ function openIncomingFolder() {
|
|||
|
||||
// Update player status every 5 seconds
|
||||
setInterval(updatePlayerStatus, 5000);
|
||||
|
||||
// ========================================
|
||||
// Stream Queue Management
|
||||
// ========================================
|
||||
|
||||
let streamQueue = [];
|
||||
let queueSearchTimeout = null;
|
||||
|
||||
// Load current stream queue
|
||||
async function loadStreamQueue() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/stream/queue');
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
streamQueue = data.queue || [];
|
||||
displayStreamQueue();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading stream queue:', error);
|
||||
document.getElementById('stream-queue-container').innerHTML =
|
||||
'<div class="error">Error loading queue</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Display stream queue
|
||||
function displayStreamQueue() {
|
||||
const container = document.getElementById('stream-queue-container');
|
||||
|
||||
if (streamQueue.length === 0) {
|
||||
container.innerHTML = '<div class="empty-state">Queue is empty. Add tracks below.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = '<div class="queue-items">';
|
||||
streamQueue.forEach((item, index) => {
|
||||
if (item) {
|
||||
const isFirst = index === 0;
|
||||
const isLast = index === streamQueue.length - 1;
|
||||
html += `
|
||||
<div class="queue-item" data-track-id="${item.id}" data-index="${index}">
|
||||
<span class="queue-position">${index + 1}</span>
|
||||
<div class="queue-track-info">
|
||||
<div class="track-title">${item.title || 'Unknown'}</div>
|
||||
<div class="track-artist">${item.artist || 'Unknown Artist'}</div>
|
||||
</div>
|
||||
<div class="queue-actions">
|
||||
<button class="btn btn-sm btn-secondary" onclick="moveTrackUp(${index})" ${isFirst ? 'disabled' : ''}>⬆️</button>
|
||||
<button class="btn btn-sm btn-secondary" onclick="moveTrackDown(${index})" ${isLast ? 'disabled' : ''}>⬇️</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="removeFromQueue(${item.id})">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
// Clear stream queue
|
||||
async function clearStreamQueue() {
|
||||
if (!confirm('Clear the entire stream queue? This will stop playback until new tracks are added.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/stream/queue/clear', {
|
||||
method: 'POST'
|
||||
});
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
alert('Queue cleared successfully');
|
||||
loadStreamQueue();
|
||||
} else {
|
||||
alert('Error clearing queue: ' + (data.message || 'Unknown error'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error clearing queue:', error);
|
||||
alert('Error clearing queue');
|
||||
}
|
||||
}
|
||||
|
||||
// Load queue from M3U file
|
||||
async function loadQueueFromM3U() {
|
||||
if (!confirm('Load queue from stream-queue.m3u file? This will replace the current queue.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/stream/queue/load-m3u', {
|
||||
method: 'POST'
|
||||
});
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
alert(`Successfully loaded ${data.count} tracks from M3U file!`);
|
||||
loadStreamQueue();
|
||||
} else {
|
||||
alert('Error loading from M3U: ' + (data.message || 'Unknown error'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading from M3U:', error);
|
||||
alert('Error loading from M3U: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Move track up in queue
|
||||
async function moveTrackUp(index) {
|
||||
if (index === 0) return;
|
||||
|
||||
// Swap with previous track
|
||||
const newQueue = [...streamQueue];
|
||||
[newQueue[index - 1], newQueue[index]] = [newQueue[index], newQueue[index - 1]];
|
||||
|
||||
await reorderQueue(newQueue);
|
||||
}
|
||||
|
||||
// Move track down in queue
|
||||
async function moveTrackDown(index) {
|
||||
if (index === streamQueue.length - 1) return;
|
||||
|
||||
// Swap with next track
|
||||
const newQueue = [...streamQueue];
|
||||
[newQueue[index], newQueue[index + 1]] = [newQueue[index + 1], newQueue[index]];
|
||||
|
||||
await reorderQueue(newQueue);
|
||||
}
|
||||
|
||||
// Reorder the queue
|
||||
async function reorderQueue(newQueue) {
|
||||
try {
|
||||
const trackIds = newQueue.map(track => track.id).join(',');
|
||||
const response = await fetch('/api/asteroid/stream/queue/reorder?track-ids=' + trackIds, {
|
||||
method: 'POST'
|
||||
});
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
loadStreamQueue();
|
||||
} else {
|
||||
alert('Error reordering queue: ' + (data.message || 'Unknown error'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error reordering queue:', error);
|
||||
alert('Error reordering queue');
|
||||
}
|
||||
}
|
||||
|
||||
// Remove track from queue
|
||||
async function removeFromQueue(trackId) {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/stream/queue/remove', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: `track-id=${trackId}`
|
||||
});
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
loadStreamQueue();
|
||||
} else {
|
||||
alert('Error removing track: ' + (data.message || 'Unknown error'));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error removing track:', error);
|
||||
alert('Error removing track');
|
||||
}
|
||||
}
|
||||
|
||||
// Add track to queue
|
||||
async function addToQueue(trackId, position = 'end', showNotification = true) {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/stream/queue/add', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: `track-id=${trackId}&position=${position}`
|
||||
});
|
||||
const result = await response.json();
|
||||
const data = result.data || result;
|
||||
|
||||
if (data.status === 'success') {
|
||||
// Only reload queue if we're in the queue management section
|
||||
const queueContainer = document.getElementById('stream-queue-container');
|
||||
if (queueContainer && queueContainer.offsetParent !== null) {
|
||||
loadStreamQueue();
|
||||
}
|
||||
|
||||
// Show brief success notification
|
||||
if (showNotification) {
|
||||
showToast('✓ Added to queue');
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
alert('Error adding track: ' + (data.message || 'Unknown error'));
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error adding track:', error);
|
||||
alert('Error adding track');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple toast notification
|
||||
function showToast(message) {
|
||||
const toast = document.createElement('div');
|
||||
toast.textContent = message;
|
||||
toast.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
background: #00ff00;
|
||||
color: #000;
|
||||
padding: 12px 20px;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
z-index: 10000;
|
||||
animation: slideIn 0.3s ease-out;
|
||||
`;
|
||||
document.body.appendChild(toast);
|
||||
|
||||
setTimeout(() => {
|
||||
toast.style.opacity = '0';
|
||||
toast.style.transition = 'opacity 0.3s';
|
||||
setTimeout(() => toast.remove(), 300);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Add random tracks to queue
|
||||
async function addRandomTracks() {
|
||||
if (tracks.length === 0) {
|
||||
alert('No tracks available. Please scan the library first.');
|
||||
return;
|
||||
}
|
||||
|
||||
const count = 10;
|
||||
const shuffled = [...tracks].sort(() => Math.random() - 0.5);
|
||||
const selected = shuffled.slice(0, Math.min(count, tracks.length));
|
||||
|
||||
for (const track of selected) {
|
||||
await addToQueue(track.id, 'end', false); // Don't show toast for each track
|
||||
}
|
||||
|
||||
showToast(`✓ Added ${selected.length} random tracks to queue`);
|
||||
}
|
||||
|
||||
// Search tracks for adding to queue
|
||||
function searchTracksForQueue(event) {
|
||||
clearTimeout(queueSearchTimeout);
|
||||
const query = event.target.value.toLowerCase();
|
||||
|
||||
if (query.length < 2) {
|
||||
document.getElementById('queue-track-results').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
queueSearchTimeout = setTimeout(() => {
|
||||
const results = tracks.filter(track =>
|
||||
(track.title && track.title.toLowerCase().includes(query)) ||
|
||||
(track.artist && track.artist.toLowerCase().includes(query)) ||
|
||||
(track.album && track.album.toLowerCase().includes(query))
|
||||
).slice(0, 20); // Limit to 20 results
|
||||
|
||||
displayQueueSearchResults(results);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
// Display search results for queue
|
||||
function displayQueueSearchResults(results) {
|
||||
const container = document.getElementById('queue-track-results');
|
||||
|
||||
if (results.length === 0) {
|
||||
container.innerHTML = '<div class="empty-state">No tracks found</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = '<div class="search-results">';
|
||||
results.forEach(track => {
|
||||
html += `
|
||||
<div class="search-result-item">
|
||||
<div class="track-info">
|
||||
<div class="track-title">${track.title || 'Unknown'}</div>
|
||||
<div class="track-artist">${track.artist || 'Unknown'} - ${track.album || 'Unknown Album'}</div>
|
||||
</div>
|
||||
<div class="track-actions">
|
||||
<button class="btn btn-sm btn-primary" onclick="addToQueue(${track.id}, 'end')">Add to End</button>
|
||||
<button class="btn btn-sm btn-success" onclick="addToQueue(${track.id}, 'next')">Play Next</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
html += '</div>';
|
||||
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
// Live stream info update
|
||||
async function updateLiveStreamInfo() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/partial/now-playing-inline');
|
||||
const contentType = response.headers.get("content-type");
|
||||
|
||||
if (!contentType.includes('text/plain')) {
|
||||
console.error('Unexpected content type:', contentType);
|
||||
return;
|
||||
}
|
||||
|
||||
const nowPlayingText = await response.text();
|
||||
const nowPlayingEl = document.getElementById('live-now-playing');
|
||||
|
||||
if (nowPlayingEl) {
|
||||
nowPlayingEl.textContent = nowPlayingText;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Could not fetch stream info:', error);
|
||||
const nowPlayingEl = document.getElementById('live-now-playing');
|
||||
if (nowPlayingEl) {
|
||||
nowPlayingEl.textContent = 'Error loading stream info';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,33 +60,15 @@ function changeStreamQuality() {
|
|||
// Update now playing info from Icecast
|
||||
async function updateNowPlaying() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/icecast-status')
|
||||
const data = await response.json()
|
||||
// Handle RADIANCE API wrapper format
|
||||
const icecastData = data.data || data;
|
||||
if (icecastData.icestats && icecastData.icestats.source) {
|
||||
// Find the high quality stream (asteroid.mp3)
|
||||
const sources = Array.isArray(icecastData.icestats.source) ? icecastData.icestats.source : [icecastData.icestats.source];
|
||||
const mainStream = sources.find(s => s.listenurl && s.listenurl.includes('asteroid.mp3'));
|
||||
|
||||
if (mainStream && mainStream.title) {
|
||||
// Parse "Artist - Track" format
|
||||
const titleParts = mainStream.title.split(' - ');
|
||||
const artist = titleParts.length > 1 ? titleParts[0] : 'Unknown Artist';
|
||||
const track = titleParts.length > 1 ? titleParts.slice(1).join(' - ') : mainStream.title;
|
||||
|
||||
document.querySelector('[data-text="now-playing-artist"]').textContent = artist;
|
||||
document.querySelector('[data-text="now-playing-track"]').textContent = track;
|
||||
document.querySelector('[data-text="listeners"]').textContent = mainStream.listeners || '0';
|
||||
|
||||
// Update stream status
|
||||
const statusElement = document.querySelector('.live-stream p:nth-child(3) span');
|
||||
if (statusElement) {
|
||||
statusElement.textContent = '● LIVE - ' + track;
|
||||
statusElement.style.color = '#00ff00';
|
||||
}
|
||||
}
|
||||
const response = await fetch('/api/asteroid/partial/now-playing')
|
||||
const contentType = response.headers.get("content-type")
|
||||
if (!contentType.includes('text/html')) {
|
||||
throw new Error('Error connecting to stream')
|
||||
}
|
||||
|
||||
const data = await response.text()
|
||||
document.getElementById('now-playing').innerHTML = data
|
||||
|
||||
} catch(error) {
|
||||
console.log('Could not fetch stream status:', error);
|
||||
}
|
||||
|
|
@ -107,7 +89,110 @@ window.addEventListener('DOMContentLoaded', function() {
|
|||
}
|
||||
// Update playing information right after load
|
||||
updateNowPlaying();
|
||||
|
||||
// Auto-reconnect on stream errors
|
||||
const audioElement = document.getElementById('live-audio');
|
||||
if (audioElement) {
|
||||
audioElement.addEventListener('error', function(e) {
|
||||
console.log('Stream error, attempting reconnect in 3 seconds...');
|
||||
setTimeout(function() {
|
||||
audioElement.load();
|
||||
audioElement.play().catch(err => console.log('Reconnect failed:', err));
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
audioElement.addEventListener('stalled', function() {
|
||||
console.log('Stream stalled, reloading...');
|
||||
audioElement.load();
|
||||
audioElement.play().catch(err => console.log('Reload failed:', err));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Update every 10 seconds
|
||||
setInterval(updateNowPlaying, 10000);
|
||||
|
||||
// Pop-out player functionality
|
||||
let popoutWindow = null;
|
||||
|
||||
function openPopoutPlayer() {
|
||||
// Check if popout is already open
|
||||
if (popoutWindow && !popoutWindow.closed) {
|
||||
popoutWindow.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate centered position
|
||||
const width = 420;
|
||||
const height = 300;
|
||||
const left = (screen.width - width) / 2;
|
||||
const top = (screen.height - height) / 2;
|
||||
|
||||
// Open popout window
|
||||
const features = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=no,status=no,menubar=no,toolbar=no,location=no`;
|
||||
|
||||
popoutWindow = window.open('/asteroid/popout-player', 'AsteroidPlayer', features);
|
||||
|
||||
// Update button state
|
||||
updatePopoutButton(true);
|
||||
}
|
||||
|
||||
function updatePopoutButton(isOpen) {
|
||||
const btn = document.getElementById('popout-btn');
|
||||
if (btn) {
|
||||
if (isOpen) {
|
||||
btn.textContent = '✓ Player Open';
|
||||
btn.classList.remove('btn-info');
|
||||
btn.classList.add('btn-success');
|
||||
} else {
|
||||
btn.textContent = '🗗 Pop Out Player';
|
||||
btn.classList.remove('btn-success');
|
||||
btn.classList.add('btn-info');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for messages from popout window
|
||||
window.addEventListener('message', function(event) {
|
||||
if (event.data.type === 'popout-opened') {
|
||||
updatePopoutButton(true);
|
||||
} else if (event.data.type === 'popout-closed') {
|
||||
updatePopoutButton(false);
|
||||
popoutWindow = null;
|
||||
}
|
||||
});
|
||||
|
||||
// Check if popout is still open periodically
|
||||
setInterval(function() {
|
||||
if (popoutWindow && popoutWindow.closed) {
|
||||
updatePopoutButton(false);
|
||||
popoutWindow = null;
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// Frameset mode functionality
|
||||
function enableFramesetMode() {
|
||||
// Save preference
|
||||
localStorage.setItem('useFrameset', 'true');
|
||||
// Redirect to frameset wrapper
|
||||
window.location.href = '/asteroid/frameset';
|
||||
}
|
||||
|
||||
function disableFramesetMode() {
|
||||
// Clear preference
|
||||
localStorage.removeItem('useFrameset');
|
||||
// Redirect to regular view
|
||||
window.location.href = '/asteroid/';
|
||||
}
|
||||
|
||||
// Check if user prefers frameset mode on page load
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
const path = window.location.pathname;
|
||||
const isFramesetPage = path.includes('/frameset') || path.includes('/content') ||
|
||||
path.includes('/audio-player-frame') || path.includes('/player-content');
|
||||
|
||||
if (localStorage.getItem('useFrameset') === 'true' && !isFramesetPage && path === '/asteroid/') {
|
||||
// User wants frameset but is on regular front page, redirect
|
||||
window.location.href = '/asteroid/frameset';
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
loadPlaylists();
|
||||
setupEventListeners();
|
||||
updatePlayerDisplay();
|
||||
updateVolume()
|
||||
updateVolume();
|
||||
|
||||
// Setup live stream with reduced buffering
|
||||
const liveAudio = document.getElementById('live-stream-audio');
|
||||
if (liveAudio) {
|
||||
// Reduce buffer to minimize delay
|
||||
liveAudio.preload = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
function setupEventListeners() {
|
||||
|
|
@ -338,7 +345,6 @@ async function createPlaylist() {
|
|||
});
|
||||
|
||||
const result = await response.json();
|
||||
console.log('Create playlist result:', result);
|
||||
|
||||
if (result.status === 'success') {
|
||||
alert(`Playlist "${name}" created successfully!`);
|
||||
|
|
@ -377,7 +383,6 @@ async function saveQueueAsPlaylist() {
|
|||
});
|
||||
|
||||
const createResult = await createResponse.json();
|
||||
console.log('Create playlist result:', createResult);
|
||||
|
||||
if (createResult.status === 'success') {
|
||||
// Wait a moment for database to update
|
||||
|
|
@ -386,20 +391,16 @@ async function saveQueueAsPlaylist() {
|
|||
// Get the new playlist ID by fetching playlists
|
||||
const playlistsResponse = await fetch('/api/asteroid/playlists');
|
||||
const playlistsResult = await playlistsResponse.json();
|
||||
console.log('Playlists result:', playlistsResult);
|
||||
|
||||
if (playlistsResult.status === 'success' && playlistsResult.playlists.length > 0) {
|
||||
// Find the playlist with matching name (most recent)
|
||||
const newPlaylist = playlistsResult.playlists.find(p => p.name === name) ||
|
||||
playlistsResult.playlists[playlistsResult.playlists.length - 1];
|
||||
|
||||
console.log('Found playlist:', newPlaylist);
|
||||
|
||||
// Add all tracks from queue to playlist
|
||||
let addedCount = 0;
|
||||
for (const track of playQueue) {
|
||||
const trackId = track.id || (Array.isArray(track.id) ? track.id[0] : null);
|
||||
console.log('Adding track to playlist:', track, 'ID:', trackId);
|
||||
|
||||
if (trackId) {
|
||||
const addFormData = new FormData();
|
||||
|
|
@ -412,7 +413,6 @@ async function saveQueueAsPlaylist() {
|
|||
});
|
||||
|
||||
const addResult = await addResponse.json();
|
||||
console.log('Add track result:', addResult);
|
||||
|
||||
if (addResult.status === 'success') {
|
||||
addedCount++;
|
||||
|
|
@ -441,12 +441,11 @@ async function loadPlaylists() {
|
|||
const response = await fetch('/api/asteroid/playlists');
|
||||
const result = await response.json();
|
||||
|
||||
console.log('Load playlists result:', result);
|
||||
|
||||
if (result.status === 'success') {
|
||||
if (result.data && result.data.status === 'success') {
|
||||
displayPlaylists(result.data.playlists || []);
|
||||
} else if (result.status === 'success') {
|
||||
displayPlaylists(result.playlists || []);
|
||||
} else {
|
||||
console.error('Error loading playlists:', result.message);
|
||||
displayPlaylists([]);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -483,8 +482,6 @@ async function loadPlaylist(playlistId) {
|
|||
const response = await fetch(`/api/asteroid/playlists/get?playlist-id=${playlistId}`);
|
||||
const result = await response.json();
|
||||
|
||||
console.log('Load playlist result:', result);
|
||||
|
||||
if (result.status === 'success' && result.playlist) {
|
||||
const playlist = result.playlist;
|
||||
|
||||
|
|
@ -569,47 +566,24 @@ function changeLiveStreamQuality() {
|
|||
}
|
||||
}
|
||||
|
||||
// Live stream functionality
|
||||
async function updateLiveStream() {
|
||||
// Live stream informatio update
|
||||
async function updateNowPlaying() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/icecast-status')
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
const response = await fetch('/api/asteroid/partial/now-playing')
|
||||
const contentType = response.headers.get("content-type")
|
||||
if (!contentType.includes('text/html')) {
|
||||
throw new Error('Error connecting to stream')
|
||||
}
|
||||
const result = await response.json();
|
||||
console.log('Live stream data:', result); // Debug log
|
||||
|
||||
// Handle RADIANCE API wrapper format
|
||||
const data = result.data || result;
|
||||
if (data.icestats && data.icestats.source) {
|
||||
const sources = Array.isArray(data.icestats.source) ? data.icestats.source : [data.icestats.source];
|
||||
const mainStream = sources.find(s => s.listenurl && s.listenurl.includes('asteroid.mp3'));
|
||||
const data = await response.text()
|
||||
document.getElementById('now-playing').innerHTML = data
|
||||
|
||||
if (mainStream && mainStream.title) {
|
||||
const titleParts = mainStream.title.split(' - ');
|
||||
const artist = titleParts.length > 1 ? titleParts[0] : 'Unknown Artist';
|
||||
const track = titleParts.length > 1 ? titleParts.slice(1).join(' - ') : mainStream.title;
|
||||
|
||||
const nowPlayingEl = document.getElementById('live-now-playing');
|
||||
const listenersEl = document.getElementById('live-listeners');
|
||||
|
||||
if (nowPlayingEl) nowPlayingEl.textContent = `${artist} - ${track}`;
|
||||
if (listenersEl) listenersEl.textContent = mainStream.listeners || '0';
|
||||
|
||||
console.log('Updated live stream info:', `${artist} - ${track}`, 'Listeners:', mainStream.listeners);
|
||||
} else {
|
||||
console.log('No main stream found or no title');
|
||||
}
|
||||
} else {
|
||||
console.log('No icestats or source in response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Live stream update error:', error);
|
||||
const nowPlayingEl = document.getElementById('live-now-playing');
|
||||
if (nowPlayingEl) nowPlayingEl.textContent = 'Stream unavailable';
|
||||
} catch(error) {
|
||||
console.log('Could not fetch stream status:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Initial update after 1 second
|
||||
setTimeout(updateNowPlaying, 1000);
|
||||
// Update live stream info every 10 seconds
|
||||
setTimeout(updateLiveStream, 1000); // Initial update after 1 second
|
||||
setInterval(updateLiveStream, 10000);
|
||||
setInterval(updateNowPlaying, 10000);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,222 @@
|
|||
;;;; stream-control.lisp - Stream Queue and Playlist Control for Asteroid Radio
|
||||
;;;; Manages the main broadcast stream queue and generates M3U playlists for Liquidsoap
|
||||
|
||||
(in-package :asteroid)
|
||||
|
||||
;;; Stream Queue Management
|
||||
;;; The stream queue represents what will play on the main broadcast
|
||||
|
||||
(defvar *stream-queue* '() "List of track IDs queued for streaming")
|
||||
(defvar *stream-history* '() "List of recently played track IDs")
|
||||
(defvar *max-history-size* 50 "Maximum number of tracks to keep in history")
|
||||
|
||||
(defun get-stream-queue ()
|
||||
"Get the current stream queue"
|
||||
*stream-queue*)
|
||||
|
||||
(defun add-to-stream-queue (track-id &optional (position :end))
|
||||
"Add a track to the stream queue at specified position (:end or :next)"
|
||||
(case position
|
||||
(:next (push track-id *stream-queue*))
|
||||
(:end (setf *stream-queue* (append *stream-queue* (list track-id))))
|
||||
(t (error "Position must be :next or :end")))
|
||||
(regenerate-stream-playlist)
|
||||
t)
|
||||
|
||||
(defun remove-from-stream-queue (track-id)
|
||||
"Remove a track from the stream queue"
|
||||
(setf *stream-queue* (remove track-id *stream-queue* :test #'equal))
|
||||
(regenerate-stream-playlist)
|
||||
t)
|
||||
|
||||
(defun clear-stream-queue ()
|
||||
"Clear the entire stream queue"
|
||||
(setf *stream-queue* '())
|
||||
(regenerate-stream-playlist)
|
||||
t)
|
||||
|
||||
(defun reorder-stream-queue (track-ids)
|
||||
"Reorder the stream queue with a new list of track IDs"
|
||||
(setf *stream-queue* track-ids)
|
||||
(regenerate-stream-playlist)
|
||||
t)
|
||||
|
||||
(defun add-playlist-to-stream-queue (playlist-id)
|
||||
"Add all tracks from a playlist to the stream queue"
|
||||
(let ((playlist (get-playlist-by-id playlist-id)))
|
||||
(when playlist
|
||||
(let* ((track-ids-raw (gethash "track-ids" playlist))
|
||||
(track-ids-str (if (listp track-ids-raw)
|
||||
(first track-ids-raw)
|
||||
track-ids-raw))
|
||||
(track-ids (if (and track-ids-str
|
||||
(stringp track-ids-str)
|
||||
(not (string= track-ids-str "")))
|
||||
(mapcar #'parse-integer
|
||||
(cl-ppcre:split "," track-ids-str))
|
||||
nil)))
|
||||
(dolist (track-id track-ids)
|
||||
(add-to-stream-queue track-id :end))
|
||||
t))))
|
||||
|
||||
;;; M3U Playlist Generation
|
||||
|
||||
(defun get-track-file-path (track-id)
|
||||
"Get the file path for a track by ID"
|
||||
(let ((track (get-track-by-id track-id)))
|
||||
(when track
|
||||
(let ((file-path (gethash "file-path" track)))
|
||||
(if (listp file-path)
|
||||
(first file-path)
|
||||
file-path)))))
|
||||
|
||||
(defun convert-to-docker-path (host-path)
|
||||
"Convert host file path to Docker container path"
|
||||
;; Replace the music library path with /app/music/
|
||||
(let ((library-prefix (namestring *music-library-path*)))
|
||||
(if (and (stringp host-path)
|
||||
(>= (length host-path) (length library-prefix))
|
||||
(string= host-path library-prefix :end1 (length library-prefix)))
|
||||
(concatenate 'string "/app/music/"
|
||||
(subseq host-path (length library-prefix)))
|
||||
host-path)))
|
||||
|
||||
(defun generate-m3u-playlist (track-ids output-path)
|
||||
"Generate an M3U playlist file from a list of track IDs"
|
||||
(with-open-file (stream output-path
|
||||
:direction :output
|
||||
:if-exists :supersede
|
||||
:if-does-not-exist :create)
|
||||
(format stream "#EXTM3U~%")
|
||||
(dolist (track-id track-ids)
|
||||
(let ((file-path (get-track-file-path track-id)))
|
||||
(when file-path
|
||||
(let ((docker-path (convert-to-docker-path file-path)))
|
||||
(format stream "#EXTINF:0,~%")
|
||||
(format stream "~a~%" docker-path))))))
|
||||
t)
|
||||
|
||||
(defun regenerate-stream-playlist ()
|
||||
"Regenerate the main stream playlist from the current queue"
|
||||
(let ((playlist-path (merge-pathnames "stream-queue.m3u"
|
||||
(asdf:system-source-directory :asteroid))))
|
||||
(if (null *stream-queue*)
|
||||
;; If queue is empty, generate from all tracks (fallback)
|
||||
(let ((all-tracks (db:select "tracks" (db:query :all))))
|
||||
(generate-m3u-playlist
|
||||
(mapcar (lambda (track)
|
||||
(let ((id (gethash "_id" track)))
|
||||
(if (listp id) (first id) id)))
|
||||
all-tracks)
|
||||
playlist-path))
|
||||
;; Generate from queue
|
||||
(generate-m3u-playlist *stream-queue* playlist-path))))
|
||||
|
||||
(defun export-playlist-to-m3u (playlist-id output-path)
|
||||
"Export a user playlist to an M3U file"
|
||||
(let ((playlist (get-playlist-by-id playlist-id)))
|
||||
(when playlist
|
||||
(let* ((track-ids-raw (gethash "track-ids" playlist))
|
||||
(track-ids-str (if (listp track-ids-raw)
|
||||
(first track-ids-raw)
|
||||
track-ids-raw))
|
||||
(track-ids (if (and track-ids-str
|
||||
(stringp track-ids-str)
|
||||
(not (string= track-ids-str "")))
|
||||
(mapcar #'parse-integer
|
||||
(cl-ppcre:split "," track-ids-str))
|
||||
nil)))
|
||||
(generate-m3u-playlist track-ids output-path)))))
|
||||
|
||||
;;; Stream History Management
|
||||
|
||||
(defun add-to-stream-history (track-id)
|
||||
"Add a track to the stream history"
|
||||
(push track-id *stream-history*)
|
||||
;; Keep history size limited
|
||||
(when (> (length *stream-history*) *max-history-size*)
|
||||
(setf *stream-history* (subseq *stream-history* 0 *max-history-size*)))
|
||||
t)
|
||||
|
||||
(defun get-stream-history (&optional (count 10))
|
||||
"Get recent stream history (default 10 tracks)"
|
||||
(subseq *stream-history* 0 (min count (length *stream-history*))))
|
||||
|
||||
;;; Smart Queue Building
|
||||
|
||||
(defun build-smart-queue (genre &optional (count 20))
|
||||
"Build a smart queue based on genre"
|
||||
(let ((tracks (db:select "tracks" (db:query :all))))
|
||||
;; For now, just add random tracks
|
||||
;; TODO: Implement genre filtering when we have genre metadata
|
||||
(let ((track-ids (mapcar (lambda (track)
|
||||
(let ((id (gethash "_id" track)))
|
||||
(if (listp id) (first id) id)))
|
||||
tracks)))
|
||||
(setf *stream-queue* (subseq (alexandria:shuffle track-ids)
|
||||
0
|
||||
(min count (length track-ids))))
|
||||
(regenerate-stream-playlist)
|
||||
*stream-queue*)))
|
||||
|
||||
(defun build-queue-from-artist (artist-name &optional (count 20))
|
||||
"Build a queue from tracks by a specific artist"
|
||||
(let ((tracks (db:select "tracks" (db:query :all))))
|
||||
(let ((matching-tracks
|
||||
(remove-if-not
|
||||
(lambda (track)
|
||||
(let ((artist (gethash "artist" track)))
|
||||
(when artist
|
||||
(let ((artist-str (if (listp artist) (first artist) artist)))
|
||||
(search artist-name artist-str :test #'char-equal)))))
|
||||
tracks)))
|
||||
(let ((track-ids (mapcar (lambda (track)
|
||||
(let ((id (gethash "_id" track)))
|
||||
(if (listp id) (first id) id)))
|
||||
matching-tracks)))
|
||||
(setf *stream-queue* (subseq track-ids 0 (min count (length track-ids))))
|
||||
(regenerate-stream-playlist)
|
||||
*stream-queue*))))
|
||||
|
||||
(defun convert-from-docker-path (docker-path)
|
||||
"Convert Docker container path back to host file path"
|
||||
(if (and (stringp docker-path)
|
||||
(>= (length docker-path) 11)
|
||||
(string= docker-path "/app/music/" :end1 11))
|
||||
(concatenate 'string
|
||||
(namestring *music-library-path*)
|
||||
(subseq docker-path 11))
|
||||
docker-path))
|
||||
|
||||
(defun load-queue-from-m3u-file ()
|
||||
"Load the stream queue from the stream-queue.m3u file"
|
||||
(let* ((m3u-path (merge-pathnames "stream-queue.m3u"
|
||||
(asdf:system-source-directory :asteroid)))
|
||||
(track-ids '())
|
||||
(all-tracks (db:select "tracks" (db:query :all))))
|
||||
|
||||
(when (probe-file m3u-path)
|
||||
(with-open-file (stream m3u-path :direction :input)
|
||||
(loop for line = (read-line stream nil)
|
||||
while line
|
||||
do (unless (or (string= line "")
|
||||
(char= (char line 0) #\#))
|
||||
;; This is a file path line
|
||||
(let* ((docker-path (string-trim '(#\Space #\Tab #\Return #\Newline) line))
|
||||
(host-path (convert-from-docker-path docker-path)))
|
||||
;; Find track by file path
|
||||
(let ((track (find-if
|
||||
(lambda (trk)
|
||||
(let ((fp (gethash "file-path" trk)))
|
||||
(let ((file-path (if (listp fp) (first fp) fp)))
|
||||
(string= file-path host-path))))
|
||||
all-tracks)))
|
||||
(when track
|
||||
(let ((id (gethash "_id" track)))
|
||||
(push (if (listp id) (first id) id) track-ids)))))))))
|
||||
|
||||
;; Reverse to maintain order from file
|
||||
(setf track-ids (nreverse track-ids))
|
||||
(setf *stream-queue* track-ids)
|
||||
(regenerate-stream-playlist)
|
||||
(length track-ids)))
|
||||
|
|
@ -61,8 +61,17 @@
|
|||
|
||||
(defun track-exists-p (file-path)
|
||||
"Check if a track with the given file path already exists in the database"
|
||||
;; Try direct query first
|
||||
(let ((existing (db:select "tracks" (db:query (:= "file-path" file-path)))))
|
||||
(> (length existing) 0)))
|
||||
(if (> (length existing) 0)
|
||||
t
|
||||
;; If not found, search manually (file-path might be stored as list)
|
||||
(let ((all-tracks (db:select "tracks" (db:query :all))))
|
||||
(some (lambda (track)
|
||||
(let ((stored-path (gethash "file-path" track)))
|
||||
(or (equal stored-path file-path)
|
||||
(and (listp stored-path) (equal (first stored-path) file-path)))))
|
||||
all-tracks)))))
|
||||
|
||||
(defun insert-track-to-database (metadata)
|
||||
"Insert track metadata into database if it doesn't already exist"
|
||||
|
|
@ -73,9 +82,7 @@
|
|||
;; Check if track already exists
|
||||
(let ((file-path (getf metadata :file-path)))
|
||||
(if (track-exists-p file-path)
|
||||
(progn
|
||||
(format t "Track already exists, skipping: ~a~%" file-path)
|
||||
nil)
|
||||
nil
|
||||
(progn
|
||||
(db:insert "tracks"
|
||||
(list (list "title" (getf metadata :title))
|
||||
|
|
@ -91,34 +98,27 @@
|
|||
|
||||
(defun scan-music-library (&optional (directory *music-library-path*))
|
||||
"Scan music library directory and add tracks to database"
|
||||
(format t "Scanning music library: ~a~%" directory)
|
||||
(let ((audio-files (scan-directory-for-music-recursively directory))
|
||||
(added-count 0)
|
||||
(skipped-count 0))
|
||||
(format t "Found ~a audio files to process~%" (length audio-files))
|
||||
(dolist (file audio-files)
|
||||
(let ((metadata (extract-metadata-with-taglib file)))
|
||||
(when metadata
|
||||
(handler-case
|
||||
(if (insert-track-to-database metadata)
|
||||
(progn
|
||||
(incf added-count)
|
||||
(format t "Added: ~a~%" (getf metadata :file-path)))
|
||||
(incf skipped-count))
|
||||
(error (e)
|
||||
(format t "Error adding ~a: ~a~%" file e))))))
|
||||
(format t "Library scan complete. Added ~a new tracks, skipped ~a existing tracks.~%"
|
||||
added-count skipped-count)
|
||||
added-count))
|
||||
|
||||
;; Initialize music directory structure
|
||||
(defun ensure-music-directories ()
|
||||
"Create music directory structure if it doesn't exist"
|
||||
(let ((base-dir (merge-pathnames "music/" (asdf:system-source-directory :asteroid))))
|
||||
(defun initialize-music-directories (&optional (base-dir *music-library-path*))
|
||||
"Create necessary music directories if they don't exist"
|
||||
(progn
|
||||
(ensure-directories-exist (merge-pathnames "library/" base-dir))
|
||||
(ensure-directories-exist (merge-pathnames "incoming/" base-dir))
|
||||
(ensure-directories-exist (merge-pathnames "temp/" base-dir))
|
||||
(format t "Music directories initialized at ~a~%" base-dir)))
|
||||
(ensure-directories-exist (merge-pathnames "temp/" base-dir))))
|
||||
|
||||
;; Simple file copy endpoint for manual uploads
|
||||
(define-page copy-files #@"/admin/copy-files" ()
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
#EXTM3U
|
||||
|
|
@ -3,17 +3,32 @@
|
|||
|
||||
(in-package :asteroid)
|
||||
|
||||
;; Template directory configuration
|
||||
(defparameter *template-directory*
|
||||
(merge-pathnames "template/" (asdf:system-source-directory :asteroid))
|
||||
"Base directory for all CLIP templates")
|
||||
|
||||
;; Template cache for parsed templates
|
||||
(defvar *template-cache* (make-hash-table :test 'equal)
|
||||
"Cache for parsed template DOMs")
|
||||
|
||||
(defun template-path (name)
|
||||
"Build full path to template file.
|
||||
NAME can be either:
|
||||
- Simple name: 'front-page' -> 'template/front-page.ctml'
|
||||
- Path with subdirs: 'partial/now-playing' -> 'template/partial/now-playing.ctml'"
|
||||
(merge-pathnames (format nil "~a.ctml" name) *template-directory*))
|
||||
|
||||
(defun load-template (name)
|
||||
"Load and parse a template by name without caching.
|
||||
Use this for templates that change frequently during development."
|
||||
(plump:parse (alexandria:read-file-into-string (template-path name))))
|
||||
|
||||
(defun get-template (template-name)
|
||||
"Load and cache a template file"
|
||||
"Load and cache a template file.
|
||||
Use this for production - templates are cached after first load."
|
||||
(or (gethash template-name *template-cache*)
|
||||
(let* ((template-path (merge-pathnames
|
||||
(format nil "template/~a.chtml" template-name)
|
||||
(asdf:system-source-directory :asteroid)))
|
||||
(parsed (plump:parse (alexandria:read-file-into-string template-path))))
|
||||
(let ((parsed (load-template template-name)))
|
||||
(setf (gethash template-name *template-cache*) parsed)
|
||||
parsed)))
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
<div class="container">
|
||||
<h1>🎛️ ADMIN DASHBOARD</h1>
|
||||
<div class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/player/">Player</a>
|
||||
<a href="/asteroid/profile">Profile</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/player-content" target="content-frame">Player</a>
|
||||
<a href="/asteroid/profile" target="content-frame">Profile</a>
|
||||
<a href="/asteroid/admin/users">👥 Users</a>
|
||||
<a href="/asteroid/logout" class="btn-logout">Logout</a>
|
||||
</div>
|
||||
|
|
@ -107,6 +107,42 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Live Stream Monitor -->
|
||||
<div class="admin-section">
|
||||
<h2>📻 Live Stream Monitor</h2>
|
||||
<div class="live-stream-monitor">
|
||||
<input type="hidden" id="stream-base-url" lquery="(val stream-base-url)">
|
||||
<p><strong>Now Playing:</strong> <span id="live-now-playing">Loading...</span></p>
|
||||
<audio id="live-stream-audio" controls style="width: 100%; max-width: 600px;">
|
||||
<source id="live-stream-source" lquery="(attr :src default-stream-url)" type="audio/aac">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stream Queue Management -->
|
||||
<div class="admin-section">
|
||||
<h2>🎵 Stream Queue Management</h2>
|
||||
<p>Manage the live stream playback queue. Changes take effect within 5-10 seconds.</p>
|
||||
|
||||
<div class="queue-controls">
|
||||
<button id="refresh-queue" class="btn btn-secondary">🔄 Refresh Queue</button>
|
||||
<button id="load-from-m3u" class="btn btn-success">📂 Load Queue from M3U</button>
|
||||
<button id="clear-queue-btn" class="btn btn-warning">🗑️ Clear Queue</button>
|
||||
<button id="add-random-tracks" class="btn btn-info">🎲 Add 10 Random Tracks</button>
|
||||
</div>
|
||||
|
||||
<div id="stream-queue-container" class="queue-list">
|
||||
<div class="loading">Loading queue...</div>
|
||||
</div>
|
||||
|
||||
<div class="queue-actions">
|
||||
<h3>Add Tracks to Queue</h3>
|
||||
<input type="text" id="queue-track-search" placeholder="Search tracks to add..." class="search-input">
|
||||
<div id="queue-track-results" class="track-results"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Player Control -->
|
||||
<div class="admin-section">
|
||||
<h2>Player Control</h2>
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
background: #1a1a1a;
|
||||
font-family: 'VT323', monospace;
|
||||
}
|
||||
.persistent-player {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
max-width: 100%;
|
||||
}
|
||||
.player-label {
|
||||
color: #00ff00;
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.quality-selector {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
.quality-selector label {
|
||||
color: #00ff00;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.quality-selector select {
|
||||
background: #2a2a2a;
|
||||
color: #00ff00;
|
||||
border: 1px solid #00ff00;
|
||||
padding: 3px 8px;
|
||||
font-family: 'VT323', monospace;
|
||||
}
|
||||
audio {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
.now-playing-mini {
|
||||
color: #00ff00;
|
||||
font-size: 0.9em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
min-width: 300px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="persistent-player">
|
||||
<span class="player-label">🟢 LIVE:</span>
|
||||
|
||||
<div class="quality-selector">
|
||||
<input type="hidden" id="stream-base-url" lquery="(val stream-base-url)">
|
||||
<label for="stream-quality">Quality:</label>
|
||||
<select id="stream-quality" onchange="changeStreamQuality()">
|
||||
<option value="aac">AAC 96k</option>
|
||||
<option value="mp3">MP3 128k</option>
|
||||
<option value="low">MP3 64k</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<audio id="persistent-audio" controls preload="metadata">
|
||||
<source id="audio-source" lquery="(attr :src default-stream-url :type default-stream-encoding)">
|
||||
</audio>
|
||||
|
||||
<span class="now-playing-mini" id="mini-now-playing">Loading...</span>
|
||||
|
||||
<button onclick="disableFramesetMode()" style="background: #2a2a2a; color: #00ff00; border: 1px solid #00ff00; padding: 5px 10px; cursor: pointer; font-family: 'VT323', monospace; font-size: 0.85em; white-space: nowrap;">
|
||||
✕ Disable
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Configure audio element for better streaming
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const audioElement = document.getElementById('persistent-audio');
|
||||
|
||||
// Try to enable low-latency mode if supported
|
||||
if ('mediaSession' in navigator) {
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: 'Asteroid Radio Live Stream',
|
||||
artist: 'Asteroid Radio',
|
||||
album: 'Live Broadcast'
|
||||
});
|
||||
}
|
||||
|
||||
// Add event listeners for debugging
|
||||
audioElement.addEventListener('waiting', function() {
|
||||
console.log('Audio buffering...');
|
||||
});
|
||||
|
||||
audioElement.addEventListener('playing', function() {
|
||||
console.log('Audio playing');
|
||||
});
|
||||
|
||||
audioElement.addEventListener('error', function(e) {
|
||||
console.error('Audio error:', e);
|
||||
});
|
||||
});
|
||||
|
||||
// Stream quality configuration
|
||||
function getStreamConfig(streamBaseUrl, encoding) {
|
||||
const config = {
|
||||
aac: {
|
||||
url: streamBaseUrl + '/asteroid.aac',
|
||||
type: 'audio/aac'
|
||||
},
|
||||
mp3: {
|
||||
url: streamBaseUrl + '/asteroid.mp3',
|
||||
type: 'audio/mpeg'
|
||||
},
|
||||
low: {
|
||||
url: streamBaseUrl + '/asteroid-low.mp3',
|
||||
type: 'audio/mpeg'
|
||||
}
|
||||
};
|
||||
return config[encoding];
|
||||
}
|
||||
|
||||
// Change stream quality
|
||||
function changeStreamQuality() {
|
||||
const selector = document.getElementById('stream-quality');
|
||||
const streamBaseUrl = document.getElementById('stream-base-url').value;
|
||||
const config = getStreamConfig(streamBaseUrl, selector.value);
|
||||
|
||||
const audioElement = document.getElementById('persistent-audio');
|
||||
const sourceElement = document.getElementById('audio-source');
|
||||
|
||||
const wasPlaying = !audioElement.paused;
|
||||
|
||||
sourceElement.src = config.url;
|
||||
sourceElement.type = config.type;
|
||||
audioElement.load();
|
||||
|
||||
if (wasPlaying) {
|
||||
audioElement.play().catch(e => console.log('Autoplay prevented:', e));
|
||||
}
|
||||
}
|
||||
|
||||
// Update mini now playing display
|
||||
async function updateMiniNowPlaying() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/partial/now-playing-inline');
|
||||
if (response.ok) {
|
||||
const text = await response.text();
|
||||
document.getElementById('mini-now-playing').textContent = text;
|
||||
}
|
||||
} catch(error) {
|
||||
console.log('Could not fetch now playing:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Update every 10 seconds
|
||||
setTimeout(updateMiniNowPlaying, 1000);
|
||||
setInterval(updateMiniNowPlaying, 10000);
|
||||
|
||||
// Disable frameset mode function
|
||||
function disableFramesetMode() {
|
||||
// Clear preference
|
||||
localStorage.removeItem('useFrameset');
|
||||
// Redirect parent window to regular view
|
||||
window.parent.location.href = '/asteroid/';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title lquery="(text title)">🎵 ASTEROID RADIO 🎵</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script>
|
||||
// Prevent nested framesets - break out if we're already in a frame
|
||||
if (window.self !== window.top) {
|
||||
window.top.location.href = window.self.location.href;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<frameset rows="*,80" frameborder="0" border="0" framespacing="0">
|
||||
<frame src="/asteroid/content" name="content-frame" noresize>
|
||||
<frame src="/asteroid/audio-player-frame" name="player-frame" noresize scrolling="no">
|
||||
<noframes>
|
||||
<body>
|
||||
<p>Your browser does not support frames. Please use a modern browser or visit <a href="/asteroid/content">the main site</a>.</p>
|
||||
</body>
|
||||
</noframes>
|
||||
</frameset>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title data-text="title">🎵 ASTEROID RADIO 🎵</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
||||
<script src="/asteroid/static/js/auth-ui.js"></script>
|
||||
<script src="/asteroid/static/js/front-page.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1 data-text="station-name">🎵 ASTEROID RADIO 🎵</h1>
|
||||
<nav class="nav">
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/player-content" target="content-frame">Player</a>
|
||||
<a href="/asteroid/status" target="content-frame">Status</a>
|
||||
<a href="/asteroid/profile" target="content-frame" data-show-if-logged-in>Profile</a>
|
||||
<a href="/asteroid/admin" target="content-frame" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/login" target="content-frame" data-show-if-logged-out>Login</a>
|
||||
<a href="/asteroid/register" target="content-frame" data-show-if-logged-out>Register</a>
|
||||
<a href="/asteroid/logout" data-show-if-logged-in class="btn-logout">Logout</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div class="status">
|
||||
<h2>Station Status</h2>
|
||||
<p data-text="status-message">🟢 LIVE - Broadcasting asteroid music for hackers</p>
|
||||
<p>Current listeners: <span data-text="listeners">0</span></p>
|
||||
<p>Stream quality: <span data-text="stream-quality">AAC 96kbps Stereo</span></p>
|
||||
</div>
|
||||
|
||||
<div class="live-stream">
|
||||
<h2 style="color: #00ff00;">🟢 LIVE STREAM</h2>
|
||||
<p><em>The live stream player is now in the persistent bar at the bottom of the page.</em></p>
|
||||
<p><strong>Stream URL:</strong> <code id="stream-url" lquery="(text default-stream-url)"></code></p>
|
||||
<p><strong>Format:</strong> <span id="stream-format" lquery="(text default-stream-encoding-desc)"></span></p>
|
||||
<p><strong>Status:</strong> <span id="stream-status" style="color: #00ff00;">● BROADCASTING</span></p>
|
||||
</div>
|
||||
|
||||
<div id="now-playing" class="now-playing"></div>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -33,7 +33,17 @@
|
|||
</div>
|
||||
|
||||
<div class="live-stream">
|
||||
<h2 style="color: #00ff00;">🟢 LIVE STREAM</h2>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
|
||||
<h2 style="color: #00ff00; margin: 0;">🟢 LIVE STREAM</h2>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<button id="popout-btn" class="btn btn-info" onclick="openPopoutPlayer()" style="font-size: 0.9em;">
|
||||
🗗 Pop Out Player
|
||||
</button>
|
||||
<button id="frameset-btn" class="btn btn-secondary" onclick="enableFramesetMode()" style="font-size: 0.9em;">
|
||||
🖼️ Enable Persistent Player
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Stream Quality Selector -->
|
||||
<div class="live-stream-quality">
|
||||
|
|
@ -56,12 +66,7 @@
|
|||
</audio>
|
||||
</div>
|
||||
|
||||
<div class="now-playing">
|
||||
<h2>Now Playing</h2>
|
||||
<p>Artist: <span data-text="now-playing-artist">The Void</span></p>
|
||||
<p>Track: <span data-text="now-playing-track">Silence</span></p>
|
||||
<p>Listeners: <span data-text="listeners">0</span></p>
|
||||
</div>
|
||||
<div id="now-playing" class="now-playing"></div>
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
|
|
@ -11,9 +11,9 @@
|
|||
<header>
|
||||
<h1>🎵 ASTEROID RADIO - LOGIN</h1>
|
||||
<nav class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/player">Player</a>
|
||||
<a href="/asteroid/status">Status</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/player-content" target="content-frame">Player</a>
|
||||
<a href="/asteroid/status" target="content-frame">Status</a>
|
||||
<a href="/asteroid/register">Register</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<h2>Now Playing</h2>
|
||||
<c:if test="stats">
|
||||
<c:then>
|
||||
<c:using value="stats">
|
||||
<!--<p>Artist: <span>The Void</span></p>-->
|
||||
<p>Track: <span lquery="(text title)">The Void - Silence</span></p>
|
||||
<p>Listeners: <span lquery="(text listeners)">1</span></p>
|
||||
</c:using>
|
||||
</c:then>
|
||||
<c:else>
|
||||
<c:if test="connection-error">
|
||||
<c:then>
|
||||
<div class="message error">
|
||||
<span>There was an error trying to get information from stream.</span>
|
||||
</div>
|
||||
</c:then>
|
||||
</c:if>
|
||||
<p>Track: <span>NA</span></p>
|
||||
<p>Listeners: <span>NA</span></p>
|
||||
</c:else>
|
||||
</c:if>
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title data-text="title">Asteroid Radio - Web Player</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
||||
<script src="/asteroid/static/js/auth-ui.js"></script>
|
||||
<script src="/asteroid/static/js/player.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🎵 WEB PLAYER</h1>
|
||||
<div class="nav">
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/profile" target="content-frame" data-show-if-logged-in>Profile</a>
|
||||
<a href="/asteroid/admin" target="content-frame" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/login" target="content-frame" data-show-if-logged-out>Login</a>
|
||||
<a href="/asteroid/register" target="content-frame" data-show-if-logged-out>Register</a>
|
||||
<a href="/asteroid/logout" data-show-if-logged-in class="btn-logout">Logout</a>
|
||||
</div>
|
||||
|
||||
<!-- Live Stream Section - Note about persistent player -->
|
||||
<div class="player-section">
|
||||
<h2 style="color: #00ff00;">🟢 Live Radio Stream</h2>
|
||||
<p><em>The live stream player is now in the persistent bar at the bottom of the page. It will continue playing as you navigate between pages!</em></p>
|
||||
</div>
|
||||
|
||||
<div id="now-playing" class="now-playing"></div>
|
||||
|
||||
<!-- Track Browser -->
|
||||
<div class="player-section">
|
||||
<h2>Personal Track Library</h2>
|
||||
<div class="track-browser">
|
||||
<input type="text" id="search-tracks" placeholder="Search tracks..." class="search-input">
|
||||
<select id="library-tracks-per-page" class="sort-select" onchange="changeLibraryTracksPerPage()" style="margin: 10px 0px;">
|
||||
<option value="10">10 per page</option>
|
||||
<option value="20" selected>20 per page</option>
|
||||
<option value="50">50 per page</option>
|
||||
</select>
|
||||
<div id="track-list" class="track-list">
|
||||
<div class="loading">Loading tracks...</div>
|
||||
</div>
|
||||
<!-- Pagination Controls -->
|
||||
<div id="library-pagination-controls" style="display: none; margin-top: 20px; text-align: center;">
|
||||
<button onclick="libraryGoToPage(1)" class="btn btn-secondary">« First</button>
|
||||
<button onclick="libraryPreviousPage()" class="btn btn-secondary">‹ Prev</button>
|
||||
<span id="library-page-info" style="margin: 0 15px; font-weight: bold;">Page 1 of 1</span>
|
||||
<button onclick="libraryNextPage()" class="btn btn-secondary">Next ›</button>
|
||||
<button onclick="libraryGoToLastPage()" class="btn btn-secondary">Last »</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Audio Player Widget -->
|
||||
<div class="player-section">
|
||||
<h2>Audio Player</h2>
|
||||
<div class="audio-player">
|
||||
<div class="now-playing">
|
||||
<div class="track-art">🎵</div>
|
||||
<div class="track-details">
|
||||
<div class="track-title" id="current-title">No track selected</div>
|
||||
<div class="track-artist" id="current-artist">Unknown Artist</div>
|
||||
<div class="track-album" id="current-album">Unknown Album</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<audio id="audio-player" controls preload="none" style="width: 100%; margin: 20px 0;">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
|
||||
<div class="player-controls">
|
||||
<button id="prev-btn" class="btn btn-secondary">⏮️ Previous</button>
|
||||
<button id="play-pause-btn" class="btn btn-primary">▶️ Play</button>
|
||||
<button id="next-btn" class="btn btn-secondary">⏭️ Next</button>
|
||||
<button id="shuffle-btn" class="btn btn-info">🔀 Shuffle</button>
|
||||
<button id="repeat-btn" class="btn btn-warning">🔁 Repeat</button>
|
||||
</div>
|
||||
|
||||
<div class="player-info">
|
||||
<div class="time-display">
|
||||
<span id="current-time">0:00</span> / <span id="total-time">0:00</span>
|
||||
</div>
|
||||
<div class="volume-control">
|
||||
<label for="volume-slider">🔊</label>
|
||||
<input type="range" id="volume-slider" min="0" max="100" value="50" class="volume-slider">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Playlist Management -->
|
||||
<div class="player-section">
|
||||
<h2>Playlists</h2>
|
||||
<div class="playlist-controls">
|
||||
<input type="text" id="new-playlist-name" placeholder="New playlist name..." class="playlist-input">
|
||||
<button id="create-playlist" class="btn btn-success">➕ Create Playlist</button>
|
||||
</div>
|
||||
|
||||
<div class="playlist-list">
|
||||
<div id="playlists-container">
|
||||
<div class="no-playlists">No playlists created yet.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Queue -->
|
||||
<div class="player-section">
|
||||
<h2>Play Queue</h2>
|
||||
<div class="queue-controls">
|
||||
<button id="clear-queue" class="btn btn-danger">🗑️ Clear Queue</button>
|
||||
<button id="save-queue" class="btn btn-info">💾 Save as Playlist</button>
|
||||
</div>
|
||||
<div id="play-queue" class="play-queue">
|
||||
<div class="empty-queue">Queue is empty</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
<div class="container">
|
||||
<h1>🎵 WEB PLAYER</h1>
|
||||
<div class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/profile" data-show-if-logged-in>Profile</a>
|
||||
<a href="/asteroid/admin" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/profile" target="content-frame" data-show-if-logged-in>Profile</a>
|
||||
<a href="/asteroid/admin" target="content-frame" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/login" data-show-if-logged-out>Login</a>
|
||||
<a href="/asteroid/register" data-show-if-logged-out>Register</a>
|
||||
<a href="/asteroid/logout" data-show-if-logged-in class="btn-logout">Logout</a>
|
||||
|
|
@ -25,8 +25,6 @@
|
|||
<h2 style="color: #00ff00;">🟢 Live Radio Stream</h2>
|
||||
<div class="live-stream">
|
||||
<input type="hidden" id="stream-base-url" lquery="(val stream-base-url)">
|
||||
<p><strong>Now Playing:</strong> <span id="live-now-playing">Loading...</span></p>
|
||||
<p><strong>Listeners:</strong> <span id="live-listeners">0</span></p>
|
||||
<!-- Stream Quality Selector -->
|
||||
<div class="live-stream-quality">
|
||||
<label for="live-stream-quality"><strong>Quality:</strong></label>
|
||||
|
|
@ -45,6 +43,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="now-playing" class="now-playing"></div>
|
||||
|
||||
<!-- Track Browser -->
|
||||
<div class="player-section">
|
||||
<h2>Personal Track Library</h2>
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>🎵 Asteroid Radio - Player</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
background: #0a0a0a;
|
||||
overflow: hidden;
|
||||
}
|
||||
.popout-container {
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.popout-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #2a3441;
|
||||
}
|
||||
.popout-title {
|
||||
font-size: 1.2em;
|
||||
color: #00ff00;
|
||||
}
|
||||
.close-btn {
|
||||
background: #ff4444;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.close-btn:hover {
|
||||
background: #ff6666;
|
||||
}
|
||||
.now-playing-mini {
|
||||
background: #1a1a1a;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #2a3441;
|
||||
}
|
||||
.track-info-mini {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.track-title-mini {
|
||||
color: #00ff00;
|
||||
font-weight: bold;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.track-artist-mini {
|
||||
color: #4488ff;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.quality-selector {
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
background: #1a1a1a;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #2a3441;
|
||||
}
|
||||
.quality-selector label {
|
||||
color: #00ff00;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.quality-selector select {
|
||||
background: #0a0a0a;
|
||||
color: #00ff00;
|
||||
border: 1px solid #2a3441;
|
||||
padding: 5px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
audio {
|
||||
width: 100%;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.status-mini {
|
||||
text-align: center;
|
||||
color: #888;
|
||||
font-size: 0.85em;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
<script src="/asteroid/static/js/front-page.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="popout-container">
|
||||
<div class="popout-header">
|
||||
<div class="popout-title">🎵 Asteroid Radio</div>
|
||||
<button class="close-btn" onclick="window.close()">✖ Close</button>
|
||||
</div>
|
||||
|
||||
<div class="now-playing-mini">
|
||||
<div class="track-info-mini">
|
||||
<div class="track-title-mini" id="popout-track-title">Loading...</div>
|
||||
<div class="track-artist-mini" id="popout-track-artist">Please wait</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="quality-selector">
|
||||
<input type="hidden" id="stream-base-url" lquery="(val stream-base-url)">
|
||||
<label for="popout-stream-quality"><strong>Quality:</strong></label>
|
||||
<select id="popout-stream-quality" onchange="changeStreamQuality()">
|
||||
<option value="aac">AAC 96kbps</option>
|
||||
<option value="mp3">MP3 128kbps</option>
|
||||
<option value="low">MP3 64kbps</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<audio id="live-audio" controls autoplay style="width: 100%;">
|
||||
<source id="audio-source" lquery="(attr :src default-stream-url :type default-stream-encoding)">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
|
||||
<div class="status-mini">
|
||||
<span style="color: #00ff00;">● LIVE</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Stream quality configuration for popout
|
||||
function getStreamConfig(streamBaseUrl, encoding) {
|
||||
const config = {
|
||||
aac: {
|
||||
url: `${streamBaseUrl}/asteroid.aac`,
|
||||
format: 'AAC 96kbps Stereo',
|
||||
type: 'audio/aac',
|
||||
mount: 'asteroid.aac'
|
||||
},
|
||||
mp3: {
|
||||
url: `${streamBaseUrl}/asteroid.mp3`,
|
||||
format: 'MP3 128kbps Stereo',
|
||||
type: 'audio/mpeg',
|
||||
mount: 'asteroid.mp3'
|
||||
},
|
||||
low: {
|
||||
url: `${streamBaseUrl}/asteroid-low.mp3`,
|
||||
format: 'MP3 64kbps Stereo',
|
||||
type: 'audio/mpeg',
|
||||
mount: 'asteroid-low.mp3'
|
||||
}
|
||||
};
|
||||
return config[encoding];
|
||||
}
|
||||
|
||||
// Change stream quality in popout
|
||||
function changeStreamQuality() {
|
||||
const selector = document.getElementById('popout-stream-quality');
|
||||
const streamBaseUrl = document.getElementById('stream-base-url');
|
||||
const config = getStreamConfig(streamBaseUrl.value, selector.value);
|
||||
|
||||
// Update audio player
|
||||
const audioElement = document.getElementById('live-audio');
|
||||
const sourceElement = document.getElementById('audio-source');
|
||||
|
||||
const wasPlaying = !audioElement.paused;
|
||||
|
||||
sourceElement.src = config.url;
|
||||
sourceElement.type = config.type;
|
||||
audioElement.load();
|
||||
|
||||
// Resume playback if it was playing
|
||||
if (wasPlaying) {
|
||||
audioElement.play().catch(e => console.log('Autoplay prevented:', e));
|
||||
}
|
||||
}
|
||||
|
||||
// Update now playing info for popout
|
||||
async function updatePopoutNowPlaying() {
|
||||
try {
|
||||
const response = await fetch('/api/asteroid/partial/now-playing-inline');
|
||||
const html = await response.text();
|
||||
|
||||
// Parse the HTML to extract track info
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
const trackText = doc.body.textContent || doc.body.innerText || '';
|
||||
|
||||
// Try to split artist - title format
|
||||
const parts = trackText.split(' - ');
|
||||
if (parts.length >= 2) {
|
||||
document.getElementById('popout-track-artist').textContent = parts[0].trim();
|
||||
document.getElementById('popout-track-title').textContent = parts.slice(1).join(' - ').trim();
|
||||
} else {
|
||||
document.getElementById('popout-track-title').textContent = trackText.trim();
|
||||
document.getElementById('popout-track-artist').textContent = 'Asteroid Radio';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating now playing:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Update every 10 seconds
|
||||
setInterval(updatePopoutNowPlaying, 10000);
|
||||
// Initial update
|
||||
updatePopoutNowPlaying();
|
||||
|
||||
// Auto-reconnect on stream errors
|
||||
const audioElement = document.getElementById('live-audio');
|
||||
audioElement.addEventListener('error', function(e) {
|
||||
console.log('Stream error, attempting reconnect in 3 seconds...');
|
||||
setTimeout(function() {
|
||||
audioElement.load();
|
||||
audioElement.play().catch(err => console.log('Reconnect failed:', err));
|
||||
}, 3000);
|
||||
});
|
||||
|
||||
audioElement.addEventListener('stalled', function() {
|
||||
console.log('Stream stalled, reloading...');
|
||||
audioElement.load();
|
||||
audioElement.play().catch(err => console.log('Reload failed:', err));
|
||||
});
|
||||
|
||||
// Notify parent window that popout is open
|
||||
if (window.opener && !window.opener.closed) {
|
||||
window.opener.postMessage({ type: 'popout-opened' }, '*');
|
||||
}
|
||||
|
||||
// Notify parent when closing
|
||||
window.addEventListener('beforeunload', function() {
|
||||
if (window.opener && !window.opener.closed) {
|
||||
window.opener.postMessage({ type: 'popout-closed' }, '*');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
<div class="container">
|
||||
<h1>👤 USER PROFILE</h1>
|
||||
<div class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/player/">Player</a>
|
||||
<a href="/asteroid/admin/" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/player-content" target="content-frame">Player</a>
|
||||
<a href="/asteroid/admin" target="content-frame" data-show-if-admin>Admin</a>
|
||||
<a href="/asteroid/logout" class="btn-logout">Logout</a>
|
||||
</div>
|
||||
|
||||
|
|
@ -11,9 +11,9 @@
|
|||
<header>
|
||||
<h1>🎵 ASTEROID RADIO - REGISTER</h1>
|
||||
<nav class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/player">Player</a>
|
||||
<a href="/asteroid/status">Status</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/player-content" target="content-frame">Player</a>
|
||||
<a href="/asteroid/status" target="content-frame">Status</a>
|
||||
<a href="/asteroid/login">Login</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
|
@ -11,8 +11,8 @@
|
|||
<div class="container">
|
||||
<h1>👥 USER MANAGEMENT</h1>
|
||||
<div class="nav">
|
||||
<a href="/asteroid/">Home</a>
|
||||
<a href="/asteroid/admin">Admin</a>
|
||||
<a href="/asteroid/content" target="content-frame">Home</a>
|
||||
<a href="/asteroid/admin" target="content-frame">Admin</a>
|
||||
<a href="/asteroid/logout" class="btn-logout">Logout</a>
|
||||
</div>
|
||||
|
||||
|
|
@ -282,12 +282,15 @@
|
|||
;; Fallback to delayed initialization
|
||||
(bt:make-thread
|
||||
(lambda ()
|
||||
(sleep 3) ; Give database more time to initialize
|
||||
(dotimes (a 5)
|
||||
(unless (db:connected-p)
|
||||
(sleep 3)) ; Give database more time to initialize
|
||||
(handler-case
|
||||
(progn
|
||||
(format t "Retrying user management setup...~%")
|
||||
(create-default-admin)
|
||||
(format t "User management initialization complete.~%"))
|
||||
(format t "User management initialization complete.~%")
|
||||
(return))
|
||||
(error (e)
|
||||
(format t "Error initializing user system: ~a~%" e))))
|
||||
(format t "Error initializing user system: ~a~%" e)))))
|
||||
:name "user-init"))))
|
||||
|
|
|
|||
Loading…
Reference in New Issue