Disentangle conflicting proto versions
We diverged in working on the proto definition, which should now be resolved.
This commit is contained in:
parent
19f19cba2d
commit
b5f722f1cb
|
|
@ -1,5 +1,4 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tonic_build::compile_protos("crabidy/v1/crabidy.proto")?;
|
||||
tonic_build::compile_protos("crabidy/proto/crabidy.proto")?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,3 +57,95 @@ message GetTrackRequest {
|
|||
message GetTrackResponse {
|
||||
Track track = 1;
|
||||
}
|
||||
|
||||
service Queue {
|
||||
rpc QueueTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc QueueLibraryNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc ReplaceWithTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc ReplaceWithNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc AppendTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc AppendNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc RemoveTracks (RemoveTracksRequest) returns (EmptyResponse);
|
||||
rpc SetCurrentTrack (SetCurrentTrackRequest) returns (EmptyResponse);
|
||||
rpc GetQueueUpdates (QueueUpdatesRequest) returns (stream QueueUpdateResponse);
|
||||
rpc GetQueue(EmptyRequest) returns (CurrentQueue);
|
||||
rpc SaveQueue (QueueSaveRequest) returns (EmptyResponse);
|
||||
}
|
||||
|
||||
message CurrentQueue {
|
||||
uint64 timestamp =1;
|
||||
uint32 current = 2;
|
||||
repeated Track tracks = 3;
|
||||
}
|
||||
|
||||
message QueuePositionChange {
|
||||
uint64 timestamp = 1;
|
||||
uint32 new_position = 2;
|
||||
}
|
||||
|
||||
message QueueTrackRequest {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
message QueueNodeRequest {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
message RemoveTracksRequest {
|
||||
repeated uint32 positions = 1;
|
||||
}
|
||||
|
||||
message SetCurrentTrackRequest {
|
||||
uint32 position = 1;
|
||||
}
|
||||
|
||||
|
||||
message QueueUpdatesRequest {
|
||||
uint64 timestamp =2;
|
||||
}
|
||||
|
||||
message QueueUpdateResponse {
|
||||
oneof QueueUpdateResult{
|
||||
CurrentQueue full = 1;
|
||||
QueuePositionChange position_change = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message QueueSaveRequest {
|
||||
string name = 1;
|
||||
// inside the configured path of crabidy
|
||||
string path = 2;
|
||||
|
||||
}
|
||||
|
||||
service Playback {
|
||||
rpc TogglePlay (EmptyRequest) returns (EmptyResponse);
|
||||
rpc Stop (EmptyRequest) returns (EmptyResponse);
|
||||
rpc GetActiveTrack (EmptyRequest) returns (ActiveTrack);
|
||||
rpc GetTrackUpdates (ActiveTrackFilter) returns (stream ActiveTrack);
|
||||
}
|
||||
|
||||
|
||||
enum TrackPlayState {
|
||||
TRACK_PLAY_STATE_STOPPED = 0;
|
||||
TRACK_PLAY_STATE_LOADING = 1;
|
||||
TRACK_PLAY_STATE_PLAYING = 2;
|
||||
TRACK_PLAY_STATE_PAUSED = 3;
|
||||
}
|
||||
|
||||
message ActiveTrackFilter {
|
||||
// defines how many of the update messages should be skipped
|
||||
// before they are sent back via GetTrackUpdates
|
||||
uint32 updates_skipped = 1;
|
||||
repeated string type_whitelist = 2;
|
||||
repeated string type_blacklist = 3;
|
||||
}
|
||||
|
||||
message ActiveTrack {
|
||||
optional Track track = 1;
|
||||
TrackPlayState play_state = 2;
|
||||
uint32 completion = 3;
|
||||
}
|
||||
|
||||
message EmptyRequest { }
|
||||
message EmptyResponse { }
|
||||
|
|
|
|||
|
|
@ -1,128 +0,0 @@
|
|||
syntax = "proto3";
|
||||
package crabidy;
|
||||
|
||||
|
||||
service Library {
|
||||
rpc GetLibraryNode (LibraryNodeRequest) returns (LibraryNodeResponse);
|
||||
}
|
||||
|
||||
// To signal whether it's loading data (for frontend only probably)
|
||||
enum LibraryNodeState {
|
||||
LIBRARY_NODE_STATE_UNSPECIFIED = 0;
|
||||
LIBRARY_NODE_STATE_PENDING = 1;
|
||||
LIBRARY_NODE_STATE_DONE = 2;
|
||||
}
|
||||
|
||||
message Track {
|
||||
// Including provider
|
||||
string uuid = 1;
|
||||
string artist = 2;
|
||||
string title = 3;
|
||||
}
|
||||
|
||||
message LibraryNodeRequest {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
message LibraryNodeResponse {
|
||||
// Including provider
|
||||
string uuid = 1;
|
||||
string name = 2;
|
||||
repeated string children = 3;
|
||||
optional string parent = 4;
|
||||
LibraryNodeState state = 5;
|
||||
repeated Track tracks = 6;
|
||||
bool is_queable = 7;
|
||||
}
|
||||
|
||||
service Queue {
|
||||
rpc QueueTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc QueueLibraryNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc ReplaceWithTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc ReplaceWithNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc AppendTrack (QueueTrackRequest) returns (EmptyResponse);
|
||||
rpc AppendNode (QueueNodeRequest) returns (EmptyResponse);
|
||||
rpc RemoveTracks (RemoveTracksRequest) returns (EmptyResponse);
|
||||
rpc SetCurrentTrack (SetCurrentTrackRequest) returns (EmptyResponse);
|
||||
rpc GetQueueUpdates (QueueUpdatesRequest) returns (stream QueueUpdateResponse);
|
||||
rpc GetQueue(EmptyRequest) returns (CurrentQueue);
|
||||
rpc SaveQueue (QueueSaveRequest) returns (EmptyResponse);
|
||||
}
|
||||
|
||||
message CurrentQueue {
|
||||
uint64 timestamp =1;
|
||||
uint32 current = 2;
|
||||
repeated Track tracks = 3;
|
||||
}
|
||||
|
||||
message QueuePositionChange {
|
||||
uint64 timestamp = 1;
|
||||
uint32 new_position = 2;
|
||||
}
|
||||
|
||||
message QueueTrackRequest {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
message QueueNodeRequest {
|
||||
string uuid = 1;
|
||||
}
|
||||
|
||||
message RemoveTracksRequest {
|
||||
repeated uint32 positions = 1;
|
||||
}
|
||||
|
||||
message SetCurrentTrackRequest {
|
||||
uint32 position = 1;
|
||||
}
|
||||
|
||||
|
||||
message QueueUpdatesRequest {
|
||||
uint64 timestamp =2;
|
||||
}
|
||||
|
||||
message QueueUpdateResponse {
|
||||
oneof QueueUpdateResult{
|
||||
CurrentQueue full = 1;
|
||||
QueuePositionChange position_change = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message QueueSaveRequest {
|
||||
string name = 1;
|
||||
// inside the configured path of crabidy
|
||||
string path = 2;
|
||||
|
||||
}
|
||||
|
||||
service Playback {
|
||||
rpc TogglePlay (EmptyRequest) returns (EmptyResponse);
|
||||
rpc Stop (EmptyRequest) returns (EmptyResponse);
|
||||
rpc GetActiveTrack (EmptyRequest) returns (ActiveTrack);
|
||||
rpc GetTrackUpdates (ActiveTrackFilter) returns (stream ActiveTrack);
|
||||
}
|
||||
|
||||
|
||||
enum TrackPlayState {
|
||||
TRACK_PLAY_STATE_STOPPED = 0;
|
||||
TRACK_PLAY_STATE_LOADING = 1;
|
||||
TRACK_PLAY_STATE_PLAYING = 2;
|
||||
TRACK_PLAY_STATE_PAUSED = 3;
|
||||
}
|
||||
|
||||
message ActiveTrackFilter {
|
||||
// defines how many of the update messages should be skipped
|
||||
// before they are sent back via GetTrackUpdates
|
||||
uint32 updates_skipped = 1;
|
||||
repeated string type_whitelist = 2;
|
||||
repeated string type_blacklist = 3;
|
||||
}
|
||||
|
||||
message ActiveTrack {
|
||||
optional Track track = 1;
|
||||
TrackPlayState play_state = 2;
|
||||
uint32 completion = 3;
|
||||
}
|
||||
|
||||
message EmptyRequest { }
|
||||
message EmptyResponse { }
|
||||
|
|
@ -2,8 +2,6 @@ pub mod proto;
|
|||
|
||||
use async_trait::async_trait;
|
||||
|
||||
|
||||
|
||||
#[async_trait]
|
||||
pub trait ProviderClient: std::fmt::Debug + Send + Sync {
|
||||
async fn init(raw_toml_settings: &str) -> Result<Self, ProviderError>
|
||||
|
|
@ -11,11 +9,11 @@ pub trait ProviderClient: std::fmt::Debug + Send + Sync {
|
|||
Self: Sized;
|
||||
fn settings(&self) -> String;
|
||||
async fn get_urls_for_track(&self, track_uuid: &str) -> Result<Vec<String>, ProviderError>;
|
||||
fn get_library_root(&self) -> proto::crabidy::LibraryNodeResponse;
|
||||
fn get_library_root(&self) -> proto::crabidy::LibraryNode;
|
||||
async fn get_library_node(
|
||||
&self,
|
||||
list_uuid: &str,
|
||||
) -> Result<proto::crabidy::LibraryNodeResponse, ProviderError>;
|
||||
) -> Result<proto::crabidy::LibraryNode, ProviderError>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Hash)]
|
||||
|
|
@ -27,7 +25,7 @@ pub enum ProviderError {
|
|||
Other,
|
||||
}
|
||||
|
||||
impl proto::crabidy::LibraryNodeResponse {
|
||||
impl proto::crabidy::LibraryNode {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
uuid: "/".to_string(),
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ impl crabidy_core::ProviderClient for Client {
|
|||
Ok(manifest.urls)
|
||||
}
|
||||
|
||||
fn get_library_root(&self) -> crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNodeResponse::new();
|
||||
fn get_library_root(&self) -> crabidy_core::proto::crabidy::LibraryNode {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNode::new();
|
||||
let children = vec!["userplaylists".to_string()];
|
||||
crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
crabidy_core::proto::crabidy::LibraryNode {
|
||||
uuid: "tidal".to_string(),
|
||||
name: "tidal".to_string(),
|
||||
parent: Some(format!("{}", global_root.uuid)),
|
||||
|
|
@ -70,16 +70,15 @@ impl crabidy_core::ProviderClient for Client {
|
|||
async fn get_library_node(
|
||||
&self,
|
||||
uuid: &str,
|
||||
) -> Result<crabidy_core::proto::crabidy::LibraryNodeResponse, crabidy_core::ProviderError>
|
||||
{
|
||||
) -> Result<crabidy_core::proto::crabidy::LibraryNode, crabidy_core::ProviderError> {
|
||||
let Some(user_id) = self.settings.login.user_id.clone() else {
|
||||
return Err(crabidy_core::ProviderError::UnknownUser)
|
||||
};
|
||||
let (module, uuid) = split_uuid(uuid);
|
||||
let node = match module.as_str() {
|
||||
"userplaylists" => {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNodeResponse::new();
|
||||
let mut node = crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
let global_root = crabidy_core::proto::crabidy::LibraryNode::new();
|
||||
let mut node = crabidy_core::proto::crabidy::LibraryNode {
|
||||
uuid: "userplaylists".to_string(),
|
||||
name: "playlists".to_string(),
|
||||
parent: Some(format!("{}", global_root.uuid)),
|
||||
|
|
@ -97,7 +96,7 @@ impl crabidy_core::ProviderClient for Client {
|
|||
node
|
||||
}
|
||||
"playlist" => {
|
||||
let mut node: crabidy_core::proto::crabidy::LibraryNodeResponse =
|
||||
let mut node: crabidy_core::proto::crabidy::LibraryNode =
|
||||
self.get_playlist(&uuid).await?.into();
|
||||
let tracks: Vec<crabidy_core::proto::crabidy::Track> = self
|
||||
.get_playlist_tracks(&uuid)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ impl From<Track> for crabidy_core::proto::crabidy::Track {
|
|||
uuid: track.id.to_string(),
|
||||
title: track.title,
|
||||
artist: track.artist.name,
|
||||
duration: Some(track.duration as u32),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -198,6 +199,7 @@ impl From<&Track> for crabidy_core::proto::crabidy::Track {
|
|||
uuid: track.id.to_string(),
|
||||
title: track.title.clone(),
|
||||
artist: track.artist.name.clone(),
|
||||
duration: Some(track.duration as u32),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -298,7 +300,7 @@ pub struct PlaylistAndFavorite {
|
|||
pub playlist: Playlist,
|
||||
}
|
||||
|
||||
impl From<PlaylistAndFavorite> for crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
impl From<PlaylistAndFavorite> for crabidy_core::proto::crabidy::LibraryNode {
|
||||
fn from(a: PlaylistAndFavorite) -> Self {
|
||||
a.playlist.into()
|
||||
}
|
||||
|
|
@ -327,9 +329,9 @@ pub struct Playlist {
|
|||
pub last_item_added_at: Option<String>,
|
||||
}
|
||||
|
||||
impl From<Playlist> for crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
impl From<Playlist> for crabidy_core::proto::crabidy::LibraryNode {
|
||||
fn from(a: Playlist) -> Self {
|
||||
crabidy_core::proto::crabidy::LibraryNodeResponse {
|
||||
crabidy_core::proto::crabidy::LibraryNode {
|
||||
name: a.title,
|
||||
uuid: format!("playlist:{}", a.uuid),
|
||||
tracks: Vec::new(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue