Skip to content

Commit

Permalink
Merge pull request #63 from tsirysndr/feat/mpd-commands
Browse files Browse the repository at this point in the history
mpd: handle more MPD commands
  • Loading branch information
tsirysndr authored Nov 13, 2024
2 parents 3bd2bbb + c0d9163 commit d734293
Show file tree
Hide file tree
Showing 17 changed files with 1,570 additions and 211 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MacOS, currently not supported, but you can run in a docker container.

## 📦 Downloads

- `Linux`: intel: [rockbox_2024.11.10_x86_64-linux.tar.gz](https://github.com/tsirysndr/rockbox-zig/releases/download/2024.11.10/rockbox_2024.11.10_x86_64-linux.tar.gz) arm64: [rockbox_2024.11.10_aarch64-linux.tar.gz](https://github.com/tsirysndr/rockbox-zig/releases/download/2024.11.10/rockbox_2024.11.10_aarch64-linux.tar.gz)
- `Linux`: intel: [rockbox_2024.11.13_x86_64-linux.tar.gz](https://github.com/tsirysndr/rockbox-zig/releases/download/2024.11.13/rockbox_2024.11.13_x86_64-linux.tar.gz) arm64: [rockbox_2024.11.13_aarch64-linux.tar.gz](https://github.com/tsirysndr/rockbox-zig/releases/download/2024.11.13/rockbox_2024.11.13_aarch64-linux.tar.gz)


## ✨ Features
Expand Down
53 changes: 53 additions & 0 deletions crates/library/src/repo/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,56 @@ pub async fn all(pool: Pool<Sqlite>) -> Result<Vec<Track>, Error> {
.await?;
Ok(result)
}

pub async fn find_by_artist(pool: Pool<Sqlite>, artist: &str) -> Result<Vec<Track>, Error> {
let result: Vec<Track> =
sqlx::query_as("SELECT * FROM track WHERE artist = $1 ORDER BY title ASC")
.bind(artist)
.fetch_all(&pool)
.await?;
Ok(result)
}

pub async fn find_by_album(pool: Pool<Sqlite>, album: &str) -> Result<Vec<Track>, Error> {
let result: Vec<Track> =
sqlx::query_as("SELECT * FROM track WHERE album = $1 ORDER BY title ASC")
.bind(album)
.fetch_all(&pool)
.await?;
Ok(result)
}

pub async fn find_by_title(pool: Pool<Sqlite>, title: &str) -> Result<Vec<Track>, Error> {
let result: Vec<Track> =
sqlx::query_as("SELECT * FROM track WHERE title = $1 ORDER BY title ASC")
.bind(title)
.fetch_all(&pool)
.await?;
Ok(result)
}

pub async fn find_by_filename(pool: Pool<Sqlite>, filename: &str) -> Result<Vec<Track>, Error> {
let result: Vec<Track> =
sqlx::query_as("SELECT * FROM track WHERE path = $1 ORDER BY title ASC")
.bind(filename)
.fetch_all(&pool)
.await?;
Ok(result)
}

pub async fn find_by_artist_album_date(
pool: Pool<Sqlite>,
artist: &str,
album: &str,
date: &str,
) -> Result<Vec<Track>, Error> {
let result: Vec<Track> = sqlx::query_as(
"SELECT * FROM track WHERE artist = $1 AND album = $2 AND year_string = $3 ORDER BY title ASC",
)
.bind(artist)
.bind(album)
.bind(date)
.fetch_all(&pool)
.await?;
Ok(result)
}
7 changes: 7 additions & 0 deletions crates/mpd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ version = "0.1.0"

[dependencies]
anyhow = "1.0.93"
chrono = "0.4.38"
regex = "1.11.1"
rockbox-graphql = {path = "../graphql"}
rockbox-library = {path = "../library"}
rockbox-rpc = {path = "../rpc"}
rockbox-settings = {path = "../settings"}
rockbox-sys = {path = "../sys"}
sqlx = {version = "0.8.2", features = ["runtime-tokio", "tls-rustls", "sqlite", "chrono", "derive", "macros"]}
tokio = {version = "1.36.0", features = ["full"]}
tokio-stream = "0.1"
tonic = "0.12.2"
Loading

0 comments on commit d734293

Please sign in to comment.