Skip to content
Extraits de code Groupes Projets
Valider 6252aaa3 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

KURISU_API: update playlists structures/endpoints to align with kurisu

parent a4a308ce
Branches
Aucune étiquette associée trouvée
1 requête de fusion!207Draft: Add playlist sync
......@@ -457,14 +457,20 @@ pub struct Playlist {
#[serde(default)]
description: String,
updated_at: u64,
created_at: u64,
/// The owners of this playlist, can be empty.
#[serde(default)]
owners: Vec<String>,
/// The content of this playlist, can be empty. The order is important and there can be
/// The content of this playlist, can be empty
/// (and can be None when building this struct from playlistsSummary endpoint)
/// The order is important and there can be
/// repetitions of karas.
#[serde(default)]
karas: Vec<u64>,
karas: Option<Vec<u64>>,
}
#[cfg(test)]
......
......@@ -3,6 +3,8 @@
"id": 5,
"title": "Playlist 1",
"description": "This is an awesome playlist",
"created_at": 0,
"updated_at": 0,
"owners": [ "fooPseudo" ],
"karas": [ 6, 9544, 5 ]
},
......@@ -10,6 +12,8 @@
"id": 6,
"title": "Playlist 2",
"description": "This playlist is not yours",
"created_at": 100,
"updated_at": 200,
"owners": [ "fooPseudo<wow>" ],
"karas": [ 9544, 5 ]
},
......@@ -17,6 +21,8 @@
"id": 8,
"title": "Playlist with quite long name",
"description": "Short description",
"created_at": 100,
"updated_at": 100,
"owners": [],
"karas": [ 6 ]
},
......@@ -24,6 +30,8 @@
"id": 9,
"title": "Kinda The longest The longest The longest The longest The longest The longest The longest The longest The longest The longest",
"description": "aze",
"created_at": 400,
"updated_at": 100,
"owners": [ "fooPseudo", "fooPseudo<wow>" ],
"karas": []
},
......@@ -31,6 +39,8 @@
"id": 10,
"title": "aze",
"description": "aze",
"created_at": 1000,
"updated_at": 1000,
"owners": [ "fooPseudo" ],
"karas": []
}
......
......@@ -28,10 +28,10 @@ pub struct Playlist {
/// the [String] is not empty.
description: Option<String>,
/// Creation time of the playlist. This is a local time, Kurisu doesn't have this notion.
/// Creation time of the playlist
created_at: i64,
/// Last update time of the playlist. This is a local time, Kurisu doesn't have this notion.
/// Last update time of the playlist
updated_at: i64,
/// The content of the playlist.
......@@ -182,13 +182,12 @@ impl Playlist {
self.description.as_deref()
}
/// Get the [chrono::DateTime] at which the playlist was created for *this lektord instance*.
/// Get the [chrono::DateTime] at which the playlist was created
pub fn created_at(&self) -> chrono::DateTime<chrono::Utc> {
chrono::DateTime::from_timestamp(self.created_at, 0).unwrap_or_default()
}
/// Get the [chrono::DateTime] at which the playlist was updated for the last time for *this
/// lektord instance*.
/// Get the [chrono::DateTime] at which the playlist was updated for the last time
pub fn updated_at(&self) -> chrono::DateTime<chrono::Utc> {
chrono::DateTime::from_timestamp(self.updated_at, 0).unwrap_or_default()
}
......@@ -271,13 +270,12 @@ impl PlaylistInfo {
self.description.as_deref()
}
/// Get the [chrono::DateTime] at which the [Playlist] was created for *this lektord instance*.
/// Get the [chrono::DateTime] at which the [Playlist] was created
pub fn created_at(&self) -> chrono::DateTime<chrono::Utc> {
chrono::DateTime::from_timestamp(self.created_at, 0).unwrap_or_default()
}
/// Get the [chrono::DateTime] at which the [Playlist] was updated for the last time for *this
/// lektord instance*.
/// Get the [chrono::DateTime] at which the [Playlist] was updated for the last time
pub fn updated_at(&self) -> chrono::DateTime<chrono::Utc> {
chrono::DateTime::from_timestamp(self.updated_at, 0).unwrap_or_default()
}
......
......@@ -35,4 +35,19 @@ pub(crate) mod v2 {
let base = base.as_ref().trim_matches(TRIM_BASE_URL);
format!("{base}/get/dbinfo")
}
pub(crate) fn get_all_playlists(base: impl AsRef<str>) -> String {
let base = base.as_ref().trim_matches(TRIM_BASE_URL);
format!("{base}/get/playlists")
}
pub(crate) fn get_playlists_summary(base: impl AsRef<str>) -> String {
let base = base.as_ref().trim_matches(TRIM_BASE_URL);
format!("{base}/get/playlistsSummary")
}
pub(crate) fn get_playlist_info(base: impl AsRef<str>, id: u64) -> String {
let base = base.as_ref().trim_matches(TRIM_BASE_URL);
format!("{base}/get/playlist/{id}")
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter