artifacts: bandcamp: implement synchronization for artists
This commit is contained in:
@@ -2,7 +2,7 @@ use bandcamp::SearchResultItem;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::artifacts::{Album, Artifact, ArtifactBuilder, Artist, SourceID, Track, tools::{DataSource, ToolDescription}};
|
||||
use crate::artifacts::{Album, Artifact, ArtifactBuilder, Artist, Contents, SourceID, Track, tools::{DataSource, ToolDescription}};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
|
||||
pub struct BandcampQueryArgs {
|
||||
@@ -34,8 +34,12 @@ impl DataSource for BandcampSource {
|
||||
type Args = BandcampQueryArgs;
|
||||
type Error = bandcamp::Error;
|
||||
|
||||
async fn synchronize(&self, _artifact: &mut Artifact) -> Result<Vec<Artifact>, Self::Error> {
|
||||
todo!()
|
||||
async fn synchronize(&self, artifact: &mut Artifact) -> Result<Vec<Artifact>, Self::Error> {
|
||||
if let Contents::Artist(artist) = &artifact.contents {
|
||||
Ok(self.query(&BandcampQueryArgs { query: artist.name.clone() }).await.unwrap_or_default())
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
async fn query(&self, args: &Self::Args) -> Result<Vec<Artifact>, Self::Error> {
|
||||
|
||||
Reference in New Issue
Block a user