Skip to content

Commit

Permalink
feat(backend): add enum variants for music
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Aug 16, 2023
1 parent b7a9510 commit 87ac37e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/backend/src/migrator/m20230410_create_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pub enum MetadataSource {
Itunes,
#[sea_orm(string_value = "LI")]
Listennotes,
#[sea_orm(string_value = "MU")]
MusicBrainz,
#[sea_orm(string_value = "OL")]
Openlibrary,
#[sea_orm(string_value = "TM")]
Expand Down Expand Up @@ -106,6 +108,8 @@ pub enum MetadataLot {
Manga,
#[sea_orm(string_value = "MO")]
Movie,
#[sea_orm(string_value = "MU")]
Music,
#[sea_orm(string_value = "SH")]
Show,
#[sea_orm(string_value = "VG")]
Expand Down
5 changes: 5 additions & 0 deletions apps/backend/src/miscellaneous/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,6 +1334,7 @@ impl MiscellaneousService {
let identifier = &model.identifier;
let source_url = match model.source {
MetadataSource::Custom => None,
MetadataSource::MusicBrainz => todo!(),
MetadataSource::Itunes => Some(format!(
"https://podcasts.apple.com/us/podcast/{slug}/id{identifier}"
)),
Expand Down Expand Up @@ -2616,6 +2617,7 @@ impl MiscellaneousService {
fn get_provider(&self, lot: MetadataLot, source: MetadataSource) -> Result<Provider> {
let err = || Err(Error::new("This source is not supported".to_owned()));
let service: Provider = match source {
MetadataSource::MusicBrainz => todo!(),
MetadataSource::Openlibrary => Box::new(self.openlibrary_service.clone()),
MetadataSource::Itunes => Box::new(self.itunes_service.clone()),
MetadataSource::GoogleBooks => Box::new(self.google_books_service.clone()),
Expand Down Expand Up @@ -3428,6 +3430,7 @@ impl MiscellaneousService {
}))
};
let specifics = match input.lot {
MetadataLot::Music => todo!(),
MetadataLot::AudioBook => match input.audio_book_specifics {
None => return err(),
Some(ref mut s) => MediaSpecifics::AudioBook(s.clone()),
Expand Down Expand Up @@ -4100,6 +4103,7 @@ impl MiscellaneousService {

async fn media_sources_for_lot(&self, lot: MetadataLot) -> Vec<MetadataSource> {
match lot {
MetadataLot::Music => vec![MetadataSource::MusicBrainz],
MetadataLot::AudioBook => vec![MetadataSource::Audible],
MetadataLot::Book => vec![MetadataSource::Openlibrary, MetadataSource::GoogleBooks],
MetadataLot::Podcast => vec![MetadataSource::Itunes, MetadataSource::Listennotes],
Expand All @@ -4113,6 +4117,7 @@ impl MiscellaneousService {
MetadataSource::iter()
.map(|source| {
let (supported, default) = match source {
MetadataSource::MusicBrainz => todo!(),
MetadataSource::Itunes => (
ITunesService::supported_languages(),
ITunesService::default_language(),
Expand Down

0 comments on commit 87ac37e

Please sign in to comment.