Compare commits
2 Commits
d358b79a6b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b39dd6cc8e | ||
|
|
cbd0243516 |
@@ -7,6 +7,7 @@ description = "Online music search for Shanty"
|
|||||||
repository = "ssh://connor@git.rcjohnstone.com:2222/Shanty/search.git"
|
repository = "ssh://connor@git.rcjohnstone.com:2222/Shanty/search.git"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
shanty-data = { path = "../shanty-data" }
|
||||||
shanty-db = { path = "../shanty-db" }
|
shanty-db = { path = "../shanty-db" }
|
||||||
shanty-tag = { path = "../shanty-tag" }
|
shanty-tag = { path = "../shanty-tag" }
|
||||||
sea-orm = { version = "1", features = ["sqlx-sqlite", "runtime-tokio-native-tls"] }
|
sea-orm = { version = "1", features = ["sqlx-sqlite", "runtime-tokio-native-tls"] }
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ pub enum SearchError {
|
|||||||
Other(String),
|
Other(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<shanty_data::DataError> for SearchError {
|
||||||
|
fn from(e: shanty_data::DataError) -> Self {
|
||||||
|
SearchError::Provider(e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<shanty_tag::TagError> for SearchError {
|
impl From<shanty_tag::TagError> for SearchError {
|
||||||
fn from(e: shanty_tag::TagError) -> Self {
|
fn from(e: shanty_tag::TagError) -> Self {
|
||||||
SearchError::Provider(e.to_string())
|
SearchError::Provider(e.to_string())
|
||||||
|
|||||||
@@ -1,19 +1,27 @@
|
|||||||
use shanty_tag::MusicBrainzClient;
|
use shanty_data::MetadataFetcher;
|
||||||
use shanty_tag::provider::MetadataProvider;
|
use shanty_data::MusicBrainzFetcher;
|
||||||
|
use shanty_data::http::RateLimiter;
|
||||||
|
|
||||||
use crate::error::SearchResult;
|
use crate::error::SearchResult;
|
||||||
use crate::provider::{
|
use crate::provider::{
|
||||||
AlbumResult, ArtistResult, Discography, DiscographyEntry, SearchProvider, TrackResult,
|
AlbumResult, ArtistResult, Discography, DiscographyEntry, SearchProvider, TrackResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// MusicBrainz implementation of `SearchProvider`, wrapping shanty-tag's client.
|
/// MusicBrainz implementation of `SearchProvider`, wrapping shanty-data's fetcher.
|
||||||
pub struct MusicBrainzSearch {
|
pub struct MusicBrainzSearch {
|
||||||
client: MusicBrainzClient,
|
client: MusicBrainzFetcher,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MusicBrainzSearch {
|
impl MusicBrainzSearch {
|
||||||
pub fn new() -> SearchResult<Self> {
|
pub fn new() -> SearchResult<Self> {
|
||||||
let client = MusicBrainzClient::new()
|
let client = MusicBrainzFetcher::new()
|
||||||
|
.map_err(|e| crate::error::SearchError::Provider(e.to_string()))?;
|
||||||
|
Ok(Self { client })
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create with a shared rate limiter (to coordinate with other MB clients).
|
||||||
|
pub fn with_limiter(limiter: RateLimiter) -> SearchResult<Self> {
|
||||||
|
let client = MusicBrainzFetcher::with_limiter(limiter)
|
||||||
.map_err(|e| crate::error::SearchError::Provider(e.to_string()))?;
|
.map_err(|e| crate::error::SearchError::Provider(e.to_string()))?;
|
||||||
Ok(Self { client })
|
Ok(Self { client })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user