Compare commits
No commits in common. "63a365d11d277537e77203d3d50b0694db2cdb4d" and "f610171d7d7ce20bf4f3d830cff94ff34bd18509" have entirely different histories.
63a365d11d
...
f610171d7d
5 changed files with 18 additions and 20 deletions
24
src/mpd.rs
24
src/mpd.rs
|
@ -5,13 +5,13 @@ use async_std::{
|
||||||
};
|
};
|
||||||
use mpdrs::lsinfo::LsInfoResponse;
|
use mpdrs::lsinfo::LsInfoResponse;
|
||||||
|
|
||||||
pub fn host() -> String {
|
pub(crate) fn host() -> String {
|
||||||
let host = std::env::var("MPD_HOST").unwrap_or("localhost".to_string());
|
let host = std::env::var("MPD_HOST").unwrap_or("localhost".to_string());
|
||||||
let port = std::env::var("MPD_PORT").unwrap_or("6600".to_string());
|
let port = std::env::var("MPD_PORT").unwrap_or("6600".to_string());
|
||||||
format!("{host}:{port}")
|
format!("{host}:{port}")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn connect() -> Result<mpdrs::Client, mpdrs::error::Error> {
|
pub(crate) fn connect() -> Result<mpdrs::Client, mpdrs::error::Error> {
|
||||||
let mut client = mpdrs::Client::connect(host())?;
|
let mut client = mpdrs::Client::connect(host())?;
|
||||||
|
|
||||||
let password = std::env::var("MPD_PASSWORD").unwrap_or(String::new());
|
let password = std::env::var("MPD_PASSWORD").unwrap_or(String::new());
|
||||||
|
@ -22,7 +22,7 @@ pub fn connect() -> Result<mpdrs::Client, mpdrs::error::Error> {
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ls(path: &str) -> anyhow::Result<Vec<Entry>> {
|
pub(crate) fn ls(path: &str) -> anyhow::Result<Vec<Entry>> {
|
||||||
let info = connect()?.lsinfo(path)?;
|
let info = connect()?.lsinfo(path)?;
|
||||||
|
|
||||||
fn filename(path: &str) -> String {
|
fn filename(path: &str) -> String {
|
||||||
|
@ -54,14 +54,14 @@ pub fn ls(path: &str) -> anyhow::Result<Vec<Entry>> {
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct QueueItem {
|
pub(crate) struct QueueItem {
|
||||||
pub file: String,
|
pub(crate) file: String,
|
||||||
pub title: String,
|
pub(crate) title: String,
|
||||||
pub artist: Option<String>,
|
pub(crate) artist: Option<String>,
|
||||||
pub playing: bool,
|
pub(crate) playing: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn playlist() -> anyhow::Result<Vec<QueueItem>> {
|
pub(crate) fn playlist() -> anyhow::Result<Vec<QueueItem>> {
|
||||||
let mut client = connect()?;
|
let mut client = connect()?;
|
||||||
|
|
||||||
let current = client.status()?.song;
|
let current = client.status()?.song;
|
||||||
|
@ -80,7 +80,7 @@ pub fn playlist() -> anyhow::Result<Vec<QueueItem>> {
|
||||||
Ok(queue)
|
Ok(queue)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Entry {
|
pub(crate) enum Entry {
|
||||||
Song {
|
Song {
|
||||||
name: String,
|
name: String,
|
||||||
artist: String,
|
artist: String,
|
||||||
|
@ -96,7 +96,7 @@ pub enum Entry {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Mpd {
|
pub(crate) struct Mpd {
|
||||||
stream: TcpStream,
|
stream: TcpStream,
|
||||||
reader: BufReader<TcpStream>,
|
reader: BufReader<TcpStream>,
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ impl Mpd {
|
||||||
self.command("play").await
|
self.command("play").await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn idle(&mut self, systems: &[&str]) -> anyhow::Result<Vec<String>> {
|
pub(crate) async fn idle(&mut self, systems: &[&str]) -> anyhow::Result<Vec<String>> {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
|
|
||||||
let systems = systems.join(" ");
|
let systems = systems.join(" ");
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB |
|
@ -58,11 +58,7 @@
|
||||||
>
|
>
|
||||||
<span class="material-symbols-outlined" title="Song">music_note</span>
|
<span class="material-symbols-outlined" title="Song">music_note</span>
|
||||||
<div class="albumart">
|
<div class="albumart">
|
||||||
<img
|
<img src="/art?path={{ path|urlencode }}" onerror="this.style.visibility = 'hidden'">
|
||||||
src="/art?path={{ path|urlencode }}"
|
|
||||||
onload="this.style.visibility = 'visible'"
|
|
||||||
alt="Album art"
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="song">
|
<div class="song">
|
||||||
<div class="song__name">{{ name }}</div>
|
<div class="song__name">{{ name }}</div>
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
{% if let Some(song) = song %}
|
{% if let Some(song) = song %}
|
||||||
<div class="albumart">
|
<div class="albumart">
|
||||||
<a href="/art?path={{ song.file|urlencode }}" target="_blank">
|
<a href="/art?path={{ song.file|urlencode }}" target="_blank">
|
||||||
<img
|
<img
|
||||||
src="/art?path={{ song.file|urlencode }}"
|
src="/art?path={{ song.file|urlencode }}"
|
||||||
onload="this.style.visibility = 'visible'"
|
onerror="this.style.opacity = 0"
|
||||||
alt="Album art"
|
alt="Album art"
|
||||||
|
title="Album art"
|
||||||
>
|
>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
<div class="albumart">
|
<div class="albumart">
|
||||||
<img
|
<img
|
||||||
src="/art?path={{ item.file|urlencode }}"
|
src="/art?path={{ item.file|urlencode }}"
|
||||||
onload="this.style.visibility = 'visible'"
|
onerror="this.style.opacity = 0"
|
||||||
alt="Album art"
|
alt="Album art"
|
||||||
|
title="Album art"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="metadata">
|
<div class="metadata">
|
||||||
|
|
Loading…
Reference in a new issue