From db9d6e2abff68d8db2694514865bbaded29cd3a8 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 16 Aug 2023 13:28:58 +0530 Subject: [PATCH] feat(backend): add enum variants for music --- apps/backend/src/migrator/m20230410_create_metadata.rs | 4 ++++ apps/backend/src/miscellaneous/resolver.rs | 5 +++++ libs/generated/src/graphql/backend/graphql.ts | 2 ++ 3 files changed, 11 insertions(+) diff --git a/apps/backend/src/migrator/m20230410_create_metadata.rs b/apps/backend/src/migrator/m20230410_create_metadata.rs index abd15b9f01..6589452daf 100644 --- a/apps/backend/src/migrator/m20230410_create_metadata.rs +++ b/apps/backend/src/migrator/m20230410_create_metadata.rs @@ -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")] @@ -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")] diff --git a/apps/backend/src/miscellaneous/resolver.rs b/apps/backend/src/miscellaneous/resolver.rs index 4afbce8b37..68b5f181d3 100644 --- a/apps/backend/src/miscellaneous/resolver.rs +++ b/apps/backend/src/miscellaneous/resolver.rs @@ -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}" )), @@ -2616,6 +2617,7 @@ impl MiscellaneousService { fn get_provider(&self, lot: MetadataLot, source: MetadataSource) -> Result { 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()), @@ -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()), @@ -4100,6 +4103,7 @@ impl MiscellaneousService { async fn media_sources_for_lot(&self, lot: MetadataLot) -> Vec { 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], @@ -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(), diff --git a/libs/generated/src/graphql/backend/graphql.ts b/libs/generated/src/graphql/backend/graphql.ts index 343fbc8dac..092899bfb4 100644 --- a/libs/generated/src/graphql/backend/graphql.ts +++ b/libs/generated/src/graphql/backend/graphql.ts @@ -592,6 +592,7 @@ export enum MetadataLot { Book = 'BOOK', Manga = 'MANGA', Movie = 'MOVIE', + Music = 'MUSIC', Podcast = 'PODCAST', Show = 'SHOW', VideoGame = 'VIDEO_GAME' @@ -605,6 +606,7 @@ export enum MetadataSource { Igdb = 'IGDB', Itunes = 'ITUNES', Listennotes = 'LISTENNOTES', + MusicBrainz = 'MUSIC_BRAINZ', Openlibrary = 'OPENLIBRARY', Tmdb = 'TMDB' }