Initial commit for git.lain.church
This commit is contained in:
commit
e5ff8adc29
3
build.lisp
Normal file
3
build.lisp
Normal file
@ -0,0 +1,3 @@
|
||||
(load "cl-mpd-runner.asd")
|
||||
(asdf:load-system :cl-mpd-runner)
|
||||
(asdf:make 'cl-mpd-runner)
|
18
cl-mpd-runner.asd
Normal file
18
cl-mpd-runner.asd
Normal file
@ -0,0 +1,18 @@
|
||||
(in-package #:cl-user)
|
||||
|
||||
(defparameter +cl-mpd-directory+
|
||||
"/var/www/html/cgi/cl-mpd-runner/cl-mpd/")
|
||||
(require 'asdf)
|
||||
(pushnew +cl-mpd-directory+ asdf:*central-registry*)
|
||||
|
||||
(asdf:defsystem :cl-mpd-runner
|
||||
:version "0.0.1"
|
||||
:author "Charlie Svitlik <staticsunn@gmail.com>"
|
||||
:description "CL-MPD-RUNNER: Music Player Daemon runner."
|
||||
:defsystem-depends-on (:deploy) ;; so you need to quickload deploy sometime before.
|
||||
:build-operation "deploy-op" ;; instead of program-op for asdf:make
|
||||
:build-pathname "cl-mpd-runner"
|
||||
:entry-point "cl-mpd-runner::main"
|
||||
:depends-on (:mpd)
|
||||
:components
|
||||
((:file "runner")))
|
131
cl-mpd.diff
Normal file
131
cl-mpd.diff
Normal file
@ -0,0 +1,131 @@
|
||||
diff --git a/mpdclient.lisp b/mpdclient.lisp
|
||||
index 8398ff8..408ae44 100644
|
||||
--- a/mpdclient.lisp
|
||||
+++ b/mpdclient.lisp
|
||||
@@ -25,8 +25,8 @@
|
||||
(eval-when (:compile-toplevel :load-toplevel)
|
||||
(declaim (optimize (speed 0) (space 0) (safety 1) (debug 3) (compilation-speed 0))))
|
||||
|
||||
-(defpackage #:mpd
|
||||
- (:use #:cl))
|
||||
+;; (defpackage #:mpd
|
||||
+;; (:use #:cl))
|
||||
|
||||
(in-package #:mpd)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#+sbcl (require :sb-bsd-sockets)
|
||||
#+lispworks (require "comm"))
|
||||
|
||||
-(defconstant +mpd-welcome-message+ "OK MPD ")
|
||||
+(defvar +mpd-welcome-message+ "OK MPD ")
|
||||
;;; These aren't used yet, but will be soon.
|
||||
(defconstant +mpd-error-not-list+ 1)
|
||||
(defconstant +mpd-error-arg+ 2)
|
||||
@@ -578,13 +578,11 @@
|
||||
|
||||
(defclass mpd-client ()
|
||||
((iostream
|
||||
- :initform nil
|
||||
:initarg :iostream
|
||||
:accessor mpd-iostream
|
||||
:type iostream
|
||||
:documentation "The input/output stream to MPD.")
|
||||
(socket
|
||||
- :initform nil
|
||||
:initarg :socket
|
||||
:accessor mpd-socket
|
||||
:type socket
|
||||
@@ -790,7 +788,6 @@
|
||||
:type integer
|
||||
:documentation "Current song stopped on or playing, playlist songid.")
|
||||
(time
|
||||
- :initform 0
|
||||
:initarg :time
|
||||
:accessor mpd-status-time
|
||||
:type string
|
||||
@@ -808,7 +805,6 @@
|
||||
:type integer
|
||||
:documentation "Crossfade in seconds.")
|
||||
(audio
|
||||
- :initform nil
|
||||
:initarg :audio
|
||||
:accessor mpd-status-audio
|
||||
:type string
|
||||
@@ -881,55 +877,47 @@
|
||||
|
||||
(defclass mpd-song ()
|
||||
((file
|
||||
- :initform nil
|
||||
:initarg :file
|
||||
:accessor mpd-song-file
|
||||
:type string
|
||||
:documentation "Relative pathname of the the current playing/paused song.")
|
||||
(artist
|
||||
- :initform nil
|
||||
:initarg :artist
|
||||
:accessor mpd-song-artist
|
||||
:type string
|
||||
:documentation "Song artist, may be nil.")
|
||||
(title
|
||||
- :initform nil
|
||||
:initarg :title
|
||||
:accessor mpd-song-title
|
||||
:type string
|
||||
:documentation "Song title, may be nil.")
|
||||
(album
|
||||
- :initform nil
|
||||
:initarg :album
|
||||
:accessor mpd-song-album
|
||||
:type string
|
||||
:documentation "Song album, may be nil.")
|
||||
(track
|
||||
- :initform nil
|
||||
:initarg :track
|
||||
:accessor mpd-song-track
|
||||
:type string
|
||||
:documentation "Song track, may be nil.")
|
||||
(name
|
||||
- :initform nil
|
||||
+ :initform ""
|
||||
:initarg :name
|
||||
:accessor mpd-song-name
|
||||
:type string
|
||||
:documentation "Song name, may be nil.")
|
||||
(date
|
||||
- :initform nil
|
||||
:initarg :date
|
||||
:accessor mpd-song-date
|
||||
:type string
|
||||
:documentation "I'm not sure wtf this is here for...?")
|
||||
(genre
|
||||
- :initform nil
|
||||
:initarg :genre
|
||||
:accessor mpd-song-genre
|
||||
:type string
|
||||
:documentation "Song's genre.")
|
||||
(composer
|
||||
- :initform nil
|
||||
:initarg :composer
|
||||
:accessor mpd-song-composer
|
||||
:type string
|
||||
@@ -941,7 +929,6 @@
|
||||
:type integer
|
||||
:documentation "Song length in seconds.")
|
||||
(position
|
||||
- :initform nil
|
||||
:initarg :position
|
||||
:accessor mpd-song-position
|
||||
:type integer
|
||||
@@ -953,7 +940,7 @@
|
||||
:type integer
|
||||
:documentation "Song ID for a song in the playlist.")
|
||||
(initialized
|
||||
- :initform nil
|
||||
+ :initform 0
|
||||
:accessor mpd-song-initialized
|
||||
:type integer
|
||||
:documentation "0 or 1: Keeps tabs on if this object has been initialized.")))
|
||||
diff --git a/systems.csv b/systems.csv
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
14
makefile
Normal file
14
makefile
Normal file
@ -0,0 +1,14 @@
|
||||
all: install
|
||||
|
||||
install: ../cl-mpd-runner.bin
|
||||
|
||||
bin/cl-mpd-runner: build.lisp cl-mpd-runner.asd runner.lisp test-client.lisp
|
||||
sbcl --load $^
|
||||
|
||||
../cl-mpd-runner.bin: bin/cl-mpd-runner
|
||||
mv $< $@
|
||||
|
||||
clean:
|
||||
$(RM) -rf *~ bin
|
||||
|
||||
.PHONY: all install
|
37
runner.lisp
Normal file
37
runner.lisp
Normal file
@ -0,0 +1,37 @@
|
||||
(in-package #:cl-user)
|
||||
|
||||
(defpackage #:cl-mpd-runner
|
||||
(:use #:cl)
|
||||
(:export #:main))
|
||||
|
||||
(in-package #:cl-mpd-runner)
|
||||
|
||||
(load #P"test-client.lisp")
|
||||
|
||||
(defun content-type (type)
|
||||
(format t "Content-Type:~a~%~%" type))
|
||||
|
||||
(defun setup-mpd-environment (&key (host "localhost") (port "6600"))
|
||||
(setf (uiop:getenv "MPD_HOST") host
|
||||
(uiop:getenv "MPD_PORT") port))
|
||||
|
||||
;; Excuse the mess.
|
||||
(defun html-header ()
|
||||
(format t "<!DOCTYPE html>
|
||||
<html lang='en'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bulma/1.0.2/css/bulma.min.css' integrity='sha512-RpeJZX3aH5oZN3U3JhE7Sd+HG8XQsqmP3clIbu4G28p668yNsRNj3zMASKe1ATjl/W80wuEtCx2dFA8xaebG5w==' crossorigin='anonymous' referrerpolicy='no-referrer'><script src='https://cdnjs.cloudflare.com/ajax/libs/anchor-js/5.0.0/anchor.min.js' integrity='sha512-byAcNWVEzFfu+tZItctr+WIMUJvpzT2kokkqcBq+VsrM3OrC5Aj9E2gh+hHpU0XNA3wDmX4sDbV5/nkhvTrj4w==' crossorigin='anonymous' referrerpolicy='no-referrer'></script>
|
||||
<title>Now Playing - MPD Status</title>
|
||||
</head><body><section class='section'><div class='container'><div class='content'>"))
|
||||
|
||||
(defun html-footer ()
|
||||
(format t "</div></div></section></body></html>"))
|
||||
|
||||
(defun main ()
|
||||
(setup-mpd-environment :host "10.99.99.2")
|
||||
(content-type "text/html; charset=utf-8")
|
||||
(html-header)
|
||||
(mpd::clos-client)
|
||||
(html-footer))
|
||||
;; (format t "~{~a~^~%~}~%" (sb-ext:posix-environ)))
|
||||
;; (format t "~a~%" (probe-file "/var/www/html/cgi/cl-mpd/"))
|
||||
;; (format t "~a~%" asdf:*central-registry*)
|
||||
;; (format t "~a" (sb-unix::posix-getenv "HTTP_USER_AGENT")))
|
52
test-client.lisp
Normal file
52
test-client.lisp
Normal file
@ -0,0 +1,52 @@
|
||||
(in-package #:mpd)
|
||||
|
||||
(defparameter mpd::*debug-on* nil)
|
||||
|
||||
(defun clos-client ()
|
||||
(let ((client (make-instance 'mpd-client))
|
||||
(status (make-instance 'mpd-status))
|
||||
(song (make-instance 'mpd-song :position 1))
|
||||
(maybe-song-in-playlist-index 0))
|
||||
(format t "~&<h1 class='title'>Now Playing</h1>")
|
||||
(format t "~&<p class='subtitle'>Created with <a href='https://cl-mpd.common-lisp.dev/'>CL-MPD</a></p>")
|
||||
(with-mpd-client-slots (client)
|
||||
;; L56
|
||||
(with-mpd-status-slots (status)
|
||||
(mpd-update-status client status)
|
||||
(format t "~&<p>Slot values for STATUS contains...<p>")
|
||||
(format t "~&<code>volume: ~S ~%repeat: ~S ~%random: ~S ~%playlist: ~S</code>"
|
||||
volume repeat random playlist)
|
||||
(format t "~%<code>playlistlength: ~S ~%xfade: ~S ~%state: ~S ~%song: ~S ~%songid: ~S</code>"
|
||||
playlist-length xfade state song songid)
|
||||
(setf maybe-song-in-playlist-index song)
|
||||
(format t "~%<code>time: ~S ~%bitrate: ~S ~%audio: ~S ~%updating_db: ~S ~%error: ~S</code>"
|
||||
time bitrate audio updating-db error))
|
||||
|
||||
;; L87
|
||||
(let* ((cnt (mpd-status-playlist-length status))
|
||||
(table (make-hash-table :size cnt))
|
||||
(current-song-index 0))
|
||||
(flet ((maybe-its-the-song ()
|
||||
(if (= current-song-index maybe-song-in-playlist-index)
|
||||
"> "
|
||||
" ")
|
||||
(incf current-song-index)))
|
||||
(dotimes (i cnt)
|
||||
(let ((obj (make-instance 'mpd-song :position i)))
|
||||
(mpd-update-song client obj)
|
||||
(setf (gethash i table) obj)))
|
||||
(format t "~&<h2>Playlist</h2><ul>~%")
|
||||
(maphash #'(lambda (key value)
|
||||
(format t "<li>~&~a~S ~A</li>" (maybe-its-the-song) key (mpd-song-file value)))
|
||||
table)))
|
||||
(format t "</ul>")
|
||||
;; L116
|
||||
(with-mpd-song-slots (song)
|
||||
(mpd-update-song client song)
|
||||
(format t "~&<code>Artist:~A~A~%~&Title:~A~A~%Album:~A~A~%~%</code>"
|
||||
#\Tab artist #\Tab title #\Tab album))
|
||||
(mpd-client-disconnect client))))
|
||||
|
||||
(defun my-source ()
|
||||
(let ((content (uiop:read-file-string #P"test-client.lisp")))
|
||||
(format t "~a~%" content)))
|
Loading…
Reference in New Issue
Block a user