Initial Commit
* Daemon Implementation - In-Progress * Initial MPC Event Captures * POST music title on daemon is loaded * POST music title on song change - TODO
This commit is contained in:
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*.cr]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/docs/
|
||||
/lib/
|
||||
/bin/
|
||||
/.shards/
|
||||
*.dwarf
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Indrajith K L <indrajith@indrajith.dev>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
16
README.md
Normal file
16
README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# [W]hat [I] [A]m [L]istening [T]o Daemon
|
||||
|
||||
A Daemon written in Crystal Lang which is part of WIALT Project. This is a daemon which should be installed in the system where mpc player is running. This will send music data and mpc state to server to display music data in indrajith.dev website.
|
||||
|
||||
## Installation
|
||||
|
||||
* Install Crystal
|
||||
* `shards install`
|
||||
|
||||
## Usage
|
||||
|
||||
* `crystal run src/wialt_daemon.cr`
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Indrajith K L](https://github.com/cooljith91112) - creator and maintainer
|
||||
18
shard.lock
Normal file
18
shard.lock
Normal file
@@ -0,0 +1,18 @@
|
||||
version: 2.0
|
||||
shards:
|
||||
crest:
|
||||
git: https://github.com/mamantoha/crest.git
|
||||
version: 1.3.12
|
||||
|
||||
crystal_mpd:
|
||||
git: https://github.com/mamantoha/crystal_mpd.git
|
||||
version: 0.15.1
|
||||
|
||||
http-client-digest_auth:
|
||||
git: https://github.com/mamantoha/http-client-digest_auth.git
|
||||
version: 0.6.0
|
||||
|
||||
http_proxy:
|
||||
git: https://github.com/mamantoha/http_proxy.git
|
||||
version: 0.10.1
|
||||
|
||||
19
shard.yml
Normal file
19
shard.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
name: wialt_daemon
|
||||
version: 0.1.0
|
||||
|
||||
authors:
|
||||
- Indrajith K L <indrajith@indrajith.dev>
|
||||
|
||||
dependencies:
|
||||
crystal_mpd:
|
||||
github: mamantoha/crystal_mpd
|
||||
crest:
|
||||
github: mamantoha/crest
|
||||
|
||||
targets:
|
||||
wialt_daemon:
|
||||
main: src/wialt_daemon.cr
|
||||
|
||||
crystal: '>= 1.10.1'
|
||||
|
||||
license: MIT
|
||||
2
spec/spec_helper.cr
Normal file
2
spec/spec_helper.cr
Normal file
@@ -0,0 +1,2 @@
|
||||
require "spec"
|
||||
require "../src/wialt_daemon"
|
||||
9
spec/wialt_daemon_spec.cr
Normal file
9
spec/wialt_daemon_spec.cr
Normal file
@@ -0,0 +1,9 @@
|
||||
require "./spec_helper"
|
||||
|
||||
describe WialtDaemon do
|
||||
# TODO: Write tests
|
||||
|
||||
it "works" do
|
||||
false.should eq(true)
|
||||
end
|
||||
end
|
||||
40
src/wialt_daemon.cr
Normal file
40
src/wialt_daemon.cr
Normal file
@@ -0,0 +1,40 @@
|
||||
# TODO: Write documentation for `WialtDaemon`
|
||||
require "crystal_mpd"
|
||||
require "concurrent"
|
||||
require "crest"
|
||||
|
||||
module WialtDaemon
|
||||
VERSION = "0.1.0"
|
||||
|
||||
client = MPD::Client.new(with_callbacks: true)
|
||||
client.callbacks_timeout = 2.seconds
|
||||
# status : Concurrent::Hash(String, String) = Concurrent::Hash(String, String).new
|
||||
# status = client.stats
|
||||
if(client.connected?)
|
||||
# puts "#{status["uptime"]}"
|
||||
if(currentsong=client.currentsong)
|
||||
puts "#{currentsong["Title"]}"
|
||||
Crest.post(
|
||||
"http://0.0.0.0:3000/music_changed",
|
||||
{:title => currentsong["Title"]},
|
||||
json: true
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
client.on :state do |state|
|
||||
puts "[#{Time.local}] State was change to #{state}"
|
||||
end
|
||||
|
||||
client.on :nextsong do
|
||||
puts "#{client}"
|
||||
end
|
||||
|
||||
client.on :song do
|
||||
if (current_song = client.currentsong)
|
||||
puts "[#{Time.local}] 🎵 #{current_song["Artist"]} - #{current_song["Title"]}"
|
||||
end
|
||||
end
|
||||
|
||||
loop { sleep 1 }
|
||||
end
|
||||
Reference in New Issue
Block a user