| 505 | |
| 506 | #[tracing::instrument(level = "debug", skip(self))] |
| 507 | pub fn get_entity_by_options(&self, options: GetEntityOptions) -> Result<Value> { |
| 508 | let mut conn = self.pool.get().unwrap(); |
| 509 | let inclusive = options.inclusive.unwrap_or_default(); |
| 510 | |
| 511 | trace!("Getting entity by options"); |
| 512 | |
| 513 | if options.album.is_some() { |
| 514 | return Ok(serde_json::to_value(self.get_albums( |
| 515 | options.album.unwrap(), |
| 516 | inclusive, |
| 517 | &mut conn, |
| 518 | )?) |
| 519 | .unwrap()); |
| 520 | } |
| 521 | |
| 522 | if options.artist.is_some() { |
| 523 | return Ok(serde_json::to_value(self.get_artists( |
| 524 | options.artist.unwrap(), |
| 525 | inclusive, |
| 526 | &mut conn, |
| 527 | )?) |
| 528 | .unwrap()); |
| 529 | } |
| 530 | |
| 531 | if options.genre.is_some() { |
| 532 | return Ok(serde_json::to_value(self.get_genres( |
| 533 | options.genre.unwrap(), |
| 534 | inclusive, |
| 535 | &mut conn, |
| 536 | )?) |
| 537 | .unwrap()); |
| 538 | } |
| 539 | |
| 540 | if options.playlist.is_some() { |
| 541 | return Ok(serde_json::to_value(self.get_playlists( |
| 542 | options.playlist.unwrap(), |
| 543 | inclusive, |
| 544 | &mut conn, |
| 545 | )?) |
| 546 | .unwrap()); |
| 547 | } |
| 548 | |
| 549 | Ok(Value::Null) |
| 550 | } |
| 551 | |
| 552 | #[tracing::instrument(level = "debug", skip(self, conn))] |
| 553 | pub fn get_album_songs( |