update
This commit is contained in:
parent
636ad0bf34
commit
edac4b1394
8 changed files with 61 additions and 18 deletions
|
@ -30,6 +30,7 @@ jobs:
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64,linux/arm64
|
# platforms: linux/amd64,linux/arm64
|
||||||
|
platforms: linux/amd64
|
||||||
push: true
|
push: true
|
||||||
tags: git.hydrar.de/synthwrld/synthwave:latest
|
tags: git.hydrar.de/synthwrld/synthwave:latest
|
||||||
|
|
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -1150,8 +1150,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mongod"
|
name = "mongod"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
source = "git+https://git.hydrar.de/jmarya/mongod#37cca40192d6e08e122c1e3c23f674d01e260ab3"
|
source = "git+https://git.hydrar.de/jmarya/mongod#228f113dbf04b04396f504685c7590b9a239e5a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
|
@ -1167,7 +1167,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mongod_derive"
|
name = "mongod_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.hydrar.de/jmarya/mongod#37cca40192d6e08e122c1e3c23f674d01e260ab3"
|
source = "git+https://git.hydrar.de/jmarya/mongod#228f113dbf04b04396f504685c7590b9a239e5a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"case",
|
"case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
|
|
@ -34,7 +34,9 @@ impl Album {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_tracks_of_album(album: &str) -> Vec<Track> {
|
pub async fn get_tracks_of_album(album: &str) -> Vec<Track> {
|
||||||
Track::find(doc! { "album_id": album}, None).await.unwrap()
|
Track::find(doc! { "album_id": album}, None, None)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the cover image of an album, or `None` if it doesn't exist.
|
/// Returns the cover image of an album, or `None` if it doesn't exist.
|
||||||
|
|
|
@ -141,6 +141,7 @@ impl Libary {
|
||||||
Album::find(
|
Album::find(
|
||||||
doc! { "artist_id": reference_of!(Artist, artist).unwrap()},
|
doc! { "artist_id": reference_of!(Artist, artist).unwrap()},
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -153,6 +154,7 @@ impl Libary {
|
||||||
"artist_id": reference_of!(Artist, artist).unwrap()
|
"artist_id": reference_of!(Artist, artist).unwrap()
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -240,7 +242,7 @@ impl Libary {
|
||||||
|
|
||||||
pub async fn clean_lost_files(&self) {
|
pub async fn clean_lost_files(&self) {
|
||||||
// tracks
|
// tracks
|
||||||
for track in Track::find_partial(doc! {}, json!({"path": 1}), None)
|
for track in Track::find_partial(doc! {}, json!({"path": 1}), None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
|
@ -250,11 +252,16 @@ impl Libary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// albums
|
// albums
|
||||||
for album in Album::find_partial(doc! {}, json!({"title": 1}), None)
|
for album in Album::find_partial(doc! {}, json!({"title": 1}), None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
if Track::find_partial(doc! { "album_id": album.reference() }, json!({}), None)
|
if Track::find_partial(
|
||||||
|
doc! { "album_id": album.reference() },
|
||||||
|
json!({}),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
|
@ -267,15 +274,15 @@ impl Libary {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// artists
|
// artists
|
||||||
for artist in Artist::find_partial(doc! {}, json!({"name": 1}), None)
|
for artist in Artist::find_partial(doc! {}, json!({"name": 1}), None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
if Track::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None)
|
if Track::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
&& Album::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None)
|
&& Album::find_partial(doc! { "artist_id": artist.reference()}, json!({}), None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl Track {
|
||||||
|
|
||||||
/// Transcode audio to AAC with `bitrate`
|
/// Transcode audio to AAC with `bitrate`
|
||||||
pub fn get_aac(&self, bitrate: u32) -> Option<String> {
|
pub fn get_aac(&self, bitrate: u32) -> Option<String> {
|
||||||
self.transcode("aac", bitrate, "m4a")
|
self.transcode("aac", bitrate, "aac")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transcode audio
|
/// Transcode audio
|
||||||
|
@ -90,6 +90,7 @@ impl Track {
|
||||||
"album_id": None::<String>
|
"album_id": None::<String>
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
|
None
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -33,7 +33,7 @@ async fn rocket() -> _ {
|
||||||
lib.rescan(&cache).await;
|
lib.rescan(&cache).await;
|
||||||
|
|
||||||
// create initial admin user
|
// create initial admin user
|
||||||
if User::find(doc! { "username": "admin" }, None)
|
if User::find(doc! { "username": "admin" }, None, None)
|
||||||
.await
|
.await
|
||||||
.is_none()
|
.is_none()
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub async fn get_singles_route(u: User) -> FallibleApiResponse {
|
||||||
let singles = Track::find(
|
let singles = Track::find(
|
||||||
doc! { "album_id": None::<String>, "artist_id": {"$ne": None::<String> }},
|
doc! { "album_id": None::<String>, "artist_id": {"$ne": None::<String> }},
|
||||||
None,
|
None,
|
||||||
|
None
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -21,7 +21,7 @@ use super::ToAPI;
|
||||||
pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
||||||
let mut playlists = vec![json!({"id": "recent", "name": "Recently Played"})];
|
let mut playlists = vec![json!({"id": "recent", "name": "Recently Played"})];
|
||||||
|
|
||||||
let own_playlists = Playlist::find(doc! { "owner": u.reference()}, None)
|
let own_playlists = Playlist::find(doc! { "owner": u.reference()}, None, None)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -35,10 +35,37 @@ pub async fn playlists_route(u: User) -> FallibleApiResponse {
|
||||||
Ok(json!(playlists))
|
Ok(json!(playlists))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn recently_added_playlist() -> FallibleApiResponse {
|
||||||
|
let tracks = Track::find(doc! {}, Some(90), Some(doc! { "added": 1 }))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
Ok(json!(to_api(&tracks).await))
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/playlist/<id>")]
|
#[get("/playlist/<id>")]
|
||||||
pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
||||||
if id == "recents" {
|
if id == "recents" {
|
||||||
// todo : recently played
|
return Ok(Playlist {
|
||||||
|
_id: "recents".to_string(),
|
||||||
|
owner: u.reference(),
|
||||||
|
title: "Recently Played".to_string(),
|
||||||
|
visibility: Visibility::Public,
|
||||||
|
tracks: vec![],
|
||||||
|
}
|
||||||
|
.api()
|
||||||
|
.await);
|
||||||
|
}
|
||||||
|
|
||||||
|
if id == "recentlyAdded" {
|
||||||
|
return Ok(Playlist {
|
||||||
|
_id: "recentlyAdded".to_string(),
|
||||||
|
owner: u.reference(),
|
||||||
|
title: "Recently Added".to_string(),
|
||||||
|
visibility: Visibility::Public,
|
||||||
|
tracks: vec![],
|
||||||
|
}
|
||||||
|
.api()
|
||||||
|
.await);
|
||||||
}
|
}
|
||||||
|
|
||||||
let playlist = Playlist::get(id)
|
let playlist = Playlist::get(id)
|
||||||
|
@ -60,6 +87,10 @@ pub async fn playlist_tracks_route(id: &str, u: User) -> FallibleApiResponse {
|
||||||
// todo : recently played
|
// todo : recently played
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if id == "recentlyAdded" {
|
||||||
|
return recently_added_playlist().await;
|
||||||
|
}
|
||||||
|
|
||||||
let playlist = Playlist::get(id)
|
let playlist = Playlist::get(id)
|
||||||
.await
|
.await
|
||||||
.ok_or_else(|| api_error("No playlist with that ID found"))?;
|
.ok_or_else(|| api_error("No playlist with that ID found"))?;
|
||||||
|
|
Loading…
Reference in a new issue