Update to support latest navidrome version
This commit is contained in:
15
.idea/workspace.xml
generated
15
.idea/workspace.xml
generated
@@ -18,9 +18,13 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="52900e09-9584-4b6c-95ff-fbd4ed5d8b2c" name="Changes" comment="Add interface package. Start adding auth stuff for refreshing tokens.">
|
<list default="true" id="52900e09-9584-4b6c-95ff-fbd4ed5d8b2c" name="Changes" comment="Add interface package. Start adding auth stuff for refreshing tokens.">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/daemon/create_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/create_playlists.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/daemon/update_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/update_playlists.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/daemon/update_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/update_playlists.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/listenbrainz.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/listenbrainz.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/models.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/models.rs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/subsonic.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/subsonic.rs" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -30,6 +34,10 @@
|
|||||||
<component name="ClangdSettings">
|
<component name="ClangdSettings">
|
||||||
<option name="formatViaClangd" value="false" />
|
<option name="formatViaClangd" value="false" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="EmbeddingIndexingInfo">
|
||||||
|
<option name="cachedIndexableFilesCount" value="48" />
|
||||||
|
<option name="fileBasedEmbeddingIndicesEnabled" value="true" />
|
||||||
|
</component>
|
||||||
<component name="ExecutionTargetManager" SELECTED_TARGET="RsBuildProfile:dev" />
|
<component name="ExecutionTargetManager" SELECTED_TARGET="RsBuildProfile:dev" />
|
||||||
<component name="FileTemplateManagerImpl">
|
<component name="FileTemplateManagerImpl">
|
||||||
<option name="RECENT_TEMPLATES">
|
<option name="RECENT_TEMPLATES">
|
||||||
@@ -67,9 +75,11 @@
|
|||||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||||
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"cf.first.check.clang-format": "false",
|
"cf.first.check.clang-format": "false",
|
||||||
"cidr.known.project.marker": "true",
|
"cidr.known.project.marker": "true",
|
||||||
|
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"junie.onboarding.icon.badge.shown": "true",
|
"junie.onboarding.icon.badge.shown": "true",
|
||||||
"last_opened_file_path": "/home/jude/Documents/navidrome-playlists",
|
"last_opened_file_path": "/home/jude/Documents/navidrome-playlists",
|
||||||
@@ -178,7 +188,8 @@
|
|||||||
<workItem from="1716642009543" duration="1546000" />
|
<workItem from="1716642009543" duration="1546000" />
|
||||||
<workItem from="1716650511971" duration="14000" />
|
<workItem from="1716650511971" duration="14000" />
|
||||||
<workItem from="1723834879628" duration="4208000" />
|
<workItem from="1723834879628" duration="4208000" />
|
||||||
<workItem from="1758303664979" duration="1155000" />
|
<workItem from="1758303664979" duration="1688000" />
|
||||||
|
<workItem from="1768333949616" duration="1109000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Structure">
|
<task id="LOCAL-00001" summary="Structure">
|
||||||
<created>1692008860369</created>
|
<created>1692008860369</created>
|
||||||
|
|||||||
616
Cargo.lock
generated
616
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
11
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "playlistd"
|
name = "playlistd"
|
||||||
version = "0.2.5"
|
version = "0.2.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Jude Southworth (judesouthworth@pm.me)"]
|
authors = ["Jude Southworth (judesouthworth@pm.me)"]
|
||||||
license = "AGPL-3.0 only"
|
license = "AGPL-3.0 only"
|
||||||
@@ -9,14 +9,13 @@ description = "Subsonic playlist daemon"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = { version = "0.5.0", features = ["json"] }
|
rocket = { version = "0.5.0", features = ["json"] }
|
||||||
tokio = { version = "1.0", features = ["full"] }
|
tokio = { version = "1.0", features = ["full"] }
|
||||||
sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "uuid"] }
|
sqlx = { version = "0.8.6", features = ["runtime-tokio", "postgres", "uuid"] }
|
||||||
reqwest = { version = "0.11", features = ["json"] }
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
uuid = { version = "1.7", features = ["v4", "serde"] }
|
uuid = { version = "1.7", features = ["v4", "serde"] }
|
||||||
md5 = "0.7.0"
|
md5 = "0.8.0"
|
||||||
getrandom = "0.2.12"
|
thiserror = "2.0.17"
|
||||||
thiserror = "1.0.58"
|
config = "0.15.19"
|
||||||
config = "0.14.0"
|
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
chrono = "0.4.38"
|
chrono = "0.4.38"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE "tracked_playlist" ALTER COLUMN playlist_id TYPE VARCHAR(250) USING playlist_id::VARCHAR(250);
|
||||||
@@ -3,7 +3,6 @@ use crate::subsonic::Subsonic;
|
|||||||
use crate::CONFIG;
|
use crate::CONFIG;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use sqlx::postgres::PgPool;
|
use sqlx::postgres::PgPool;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::time::{interval, MissedTickBehavior};
|
use tokio::time::{interval, MissedTickBehavior};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@@ -67,7 +66,6 @@ async fn create_playlist(
|
|||||||
// Create playlist
|
// Create playlist
|
||||||
let playlist = media_client.as_ref().create_playlist(&new_name).await?;
|
let playlist = media_client.as_ref().create_playlist(&new_name).await?;
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
let playlist_uuid = Uuid::from_str(&playlist.id)?;
|
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
@@ -75,7 +73,7 @@ async fn create_playlist(
|
|||||||
VALUES ($1, $2, $3, $4, $5)
|
VALUES ($1, $2, $3, $4, $5)
|
||||||
"#,
|
"#,
|
||||||
uuid,
|
uuid,
|
||||||
playlist_uuid,
|
playlist.id,
|
||||||
playlist_rule.playlist_size,
|
playlist_rule.playlist_size,
|
||||||
playlist_rule.tracking_user,
|
playlist_rule.tracking_user,
|
||||||
playlist_rule.tracking_type,
|
playlist_rule.tracking_type,
|
||||||
|
|||||||
@@ -124,17 +124,10 @@ async fn update_playlist(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let playlist = media_client
|
let playlist = media_client.as_ref().get_playlist(&playlist_id).await?;
|
||||||
.as_ref()
|
|
||||||
.get_playlist(playlist_id.to_string())
|
|
||||||
.await?;
|
|
||||||
media_client
|
media_client
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.update_playlist(
|
.update_playlist(playlist_id, tracks, (0..playlist.song_count).collect())
|
||||||
playlist_id.to_string(),
|
|
||||||
tracks,
|
|
||||||
(0..playlist.song_count).collect(),
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
28
src/main.rs
28
src/main.rs
@@ -15,9 +15,7 @@ use rocket::serde::json::{json, Json};
|
|||||||
use rocket::{get, post, routes, serde::json::Value as JsonValue, State};
|
use rocket::{get, post, routes, serde::json::Value as JsonValue, State};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::postgres::PgPool;
|
use sqlx::postgres::PgPool;
|
||||||
use std::str::FromStr;
|
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
pub static CONFIG: OnceLock<Config> = OnceLock::new();
|
pub static CONFIG: OnceLock<Config> = OnceLock::new();
|
||||||
|
|
||||||
@@ -140,23 +138,19 @@ async fn create_tracking_playlist(
|
|||||||
.create_playlist(create_playlist.playlist_name.clone())
|
.create_playlist(create_playlist.playlist_name.clone())
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(created_playlist) => match Uuid::from_str(&created_playlist.id) {
|
Ok(created_playlist) => {
|
||||||
Ok(playlist_id) => {
|
let partial = PartialTrackedPlaylist {
|
||||||
let partial = PartialTrackedPlaylist {
|
playlist_id: created_playlist.id,
|
||||||
playlist_id,
|
playlist_size: create_playlist.playlist_size,
|
||||||
playlist_size: create_playlist.playlist_size,
|
tracking_user: create_playlist.tracking_user.clone(),
|
||||||
tracking_user: create_playlist.tracking_user.clone(),
|
tracking_type: create_playlist.tracking_type.clone(),
|
||||||
tracking_type: create_playlist.tracking_type.clone(),
|
};
|
||||||
};
|
|
||||||
|
|
||||||
match partial.record(pool.inner()).await {
|
match partial.record(pool.inner()).await {
|
||||||
Ok(playlist) => Json(Response::Success(playlist)),
|
Ok(playlist) => Json(Response::Success(playlist)),
|
||||||
Err(e) => Json(Response::Error(e.into())),
|
Err(e) => Json(Response::Error(e.into())),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Err(e) => Json(Response::Error(e.into())),
|
|
||||||
},
|
|
||||||
|
|
||||||
Err(_) => Json(Response::Error(JsonError {
|
Err(_) => Json(Response::Error(JsonError {
|
||||||
error: "Couldn't create Subsonic playlist".to_string(),
|
error: "Couldn't create Subsonic playlist".to_string(),
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::error::Error;
|
use sqlx::error::Error;
|
||||||
use sqlx::types::Uuid as UuidType;
|
|
||||||
use sqlx::{Executor, Postgres};
|
use sqlx::{Executor, Postgres};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct PartialTrackedPlaylist {
|
pub struct PartialTrackedPlaylist {
|
||||||
pub playlist_id: Uuid,
|
pub playlist_id: String,
|
||||||
pub playlist_size: i32,
|
pub playlist_size: i32,
|
||||||
pub tracking_user: Option<String>,
|
pub tracking_user: Option<String>,
|
||||||
pub tracking_type: Option<String>,
|
pub tracking_type: Option<String>,
|
||||||
@@ -41,7 +40,7 @@ impl PartialTrackedPlaylist {
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct TrackedPlaylist {
|
pub struct TrackedPlaylist {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub playlist_id: Option<UuidType>,
|
pub playlist_id: Option<String>,
|
||||||
pub playlist_size: i32,
|
pub playlist_size: i32,
|
||||||
pub tracking_user: String,
|
pub tracking_user: String,
|
||||||
pub tracking_type: String,
|
pub tracking_type: String,
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ impl Subsonic {
|
|||||||
.song)
|
.song)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_playlist(&self, playlist_id: String) -> Result<Playlist, SubsonicError> {
|
pub async fn get_playlist(
|
||||||
|
&self,
|
||||||
|
playlist_id: impl ToString,
|
||||||
|
) -> Result<Playlist, SubsonicError> {
|
||||||
let auth_params = self.auth_params();
|
let auth_params = self.auth_params();
|
||||||
|
|
||||||
let get_params = [
|
let get_params = [
|
||||||
@@ -109,7 +112,7 @@ impl Subsonic {
|
|||||||
("v", String::from("16")),
|
("v", String::from("16")),
|
||||||
("c", String::from("playlistd")),
|
("c", String::from("playlistd")),
|
||||||
("f", String::from("json")),
|
("f", String::from("json")),
|
||||||
("id", playlist_id),
|
("id", playlist_id.to_string()),
|
||||||
];
|
];
|
||||||
|
|
||||||
Ok(self
|
Ok(self
|
||||||
|
|||||||
Reference in New Issue
Block a user