A decentralized music tracking and discovery platform built on AT Protocol ๐ŸŽต
listenbrainz spotify atproto lastfm musicbrainz scrobbling

feat: Enhance MusicBrainz integration and improve data handling #10

merged opened by tsiry-sandratraina.com targeting main from feat/musicbrainz
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:7vdlgi2bflelz7mmuxoqjfcr/sh.tangled.repo.pull/3lzvdu4sh5l22
+76 -63
Interdiff #0 โ†’ #1
Cargo.lock

This file has not been changed.

crates/scrobbler/Cargo.toml

This file has not been changed.

crates/scrobbler/src/handlers/mod.rs

This file has not been changed.

crates/scrobbler/src/handlers/scrobble.rs

This file has not been changed.

crates/scrobbler/src/handlers/v1/submission.rs

This file has not been changed.

crates/scrobbler/src/lib.rs

This file has not been changed.

crates/scrobbler/src/listenbrainz/core/submit.rs

This file has not been changed.

crates/scrobbler/src/listenbrainz/handlers.rs

This file has not been changed.

crates/scrobbler/src/musicbrainz/artist.rs

This file has not been changed.

crates/scrobbler/src/musicbrainz/client.rs

This file has not been changed.

crates/scrobbler/src/musicbrainz/mod.rs

This file has not been changed.

crates/scrobbler/src/musicbrainz/release.rs

This file has not been changed.

+58 -44
crates/scrobbler/src/scrobbler.rs
··· 375 376 377 378 379 380 381 - 382 - 383 - 384 - 385 - 386 - 387 - 388 - 389 - 390 - 391 - 392 - 393 - 394 - 395 - 396 - 397 - 398 - 399 } 400 401 let query = format!( ··· 613 614 615 616 - 617 - 618 - 619 - 620 - 621 - 622 - 623 624 // check if artists don't contain the scrobble artist (to avoid wrong matches) 625 if !artists.contains(&scrobble.artist.to_lowercase()) { 626 tracing::warn!(artist = %artist, track = ?track, "Artist mismatch, skipping"); 627 return Ok(()); 628 - } 629 - 630 - 631 - 632 - 633 - 634 - 635 - 636 637 - 638 - 639 - 640 - 641 - 642 - 643 - 644 - 645 - 646 - 647 - return Ok(()); 648 } 649 650 let query = format!(
··· 375 376 377 378 + .await?; 379 380 + if let Some(track) = result.tracks.items.first() { 381 + let artists = track 382 + .artists 383 + .iter() 384 + .map(|a| a.name.to_lowercase().clone()) 385 + .collect::<Vec<_>>() 386 + .join(", ") 387 + .to_lowercase(); 388 389 + // check if artists don't contain the scrobble artist (to avoid wrong matches) 390 + if !artists.contains(&scrobble.artist.to_lowercase()) { 391 + tracing::warn!(artist = %artist, track = ?track, "Artist mismatch, skipping"); 392 + return Ok(()); 393 + } else { 394 + tracing::info!(artist = %scrobble.artist, track = %scrobble.track, "Spotify (track)"); 395 + scrobble.album = Some(track.album.name.clone()); 396 + let mut track = track.clone(); 397 + 398 + if let Some(album) = spotify_client.get_album(&track.album.id).await? { 399 + track.album = album; 400 + } 401 + 402 + if let Some(artist) = spotify_client 403 + .get_artist(&track.album.artists[0].id) 404 + .await? 405 + { 406 + track.album.artists[0] = artist; 407 + } 408 409 + rocksky::scrobble(cache, &did, track.into(), scrobble.timestamp).await?; 410 + tokio::time::sleep(std::time::Duration::from_secs(1)).await; 411 + return Ok(()); 412 + } 413 } 414 415 let query = format!( ··· 627 628 629 630 + let artists = track 631 + .artists 632 + .iter() 633 + .map(|a| a.name.to_lowercase().clone()) 634 + .collect::<Vec<_>>() 635 + .join(", ") 636 + .to_lowercase(); 637 638 // check if artists don't contain the scrobble artist (to avoid wrong matches) 639 if !artists.contains(&scrobble.artist.to_lowercase()) { 640 tracing::warn!(artist = %artist, track = ?track, "Artist mismatch, skipping"); 641 return Ok(()); 642 + } else { 643 + tracing::info!("Spotify (track)"); 644 + scrobble.album = Some(track.album.name.clone()); 645 + let mut track = track.clone(); 646 + 647 + if let Some(album) = spotify_client.get_album(&track.album.id).await? { 648 + track.album = album; 649 + } 650 + 651 + if let Some(artist) = spotify_client 652 + .get_artist(&track.album.artists[0].id) 653 + .await? 654 + { 655 + track.album.artists[0] = artist; 656 + } 657 658 + rocksky::scrobble(cache, &did, track.into(), scrobble.timestamp).await?; 659 + tokio::time::sleep(std::time::Duration::from_secs(1)).await; 660 + return Ok(()); 661 + } 662 } 663 664 let query = format!(
crates/scrobbler/src/types.rs

This file has not been changed.

crates/webscrobbler/Cargo.toml

This file has not been changed.

crates/webscrobbler/src/handlers.rs

This file has not been changed.

crates/webscrobbler/src/lib.rs

This file has not been changed.

crates/webscrobbler/src/musicbrainz/artist.rs

This file has not been changed.

crates/webscrobbler/src/musicbrainz/client.rs

This file has not been changed.

crates/webscrobbler/src/musicbrainz/mod.rs

This file has not been changed.

crates/webscrobbler/src/musicbrainz/release.rs

This file has not been changed.

+18 -19
crates/webscrobbler/src/scrobbler.rs
··· 131 let artists = track 132 .artists 133 .iter() 134 - .map(|a| a.name.clone()) 135 .collect::<Vec<_>>() 136 .join(", ") 137 .to_lowercase(); ··· 139 // check if artists don't contain the scrobble artist (to avoid wrong matches) 140 if !artists.contains(&scrobble.data.song.parsed.artist.trim().to_lowercase()) { 141 tracing::warn!(artist = %artist, track = ?track, "Artist mismatch, skipping"); 142 return Ok(()); 143 } 144 - 145 - tracing::info!("Spotify (track)"); 146 - let mut track = track.clone(); 147 - 148 - 149 - 150 - 151 - 152 - 153 - 154 - 155 - 156 - 157 - 158 - 159 - 160 - 161 - 162 } 163 164 let query = format!(
··· 131 let artists = track 132 .artists 133 .iter() 134 + .map(|a| a.name.to_lowercase().clone()) 135 .collect::<Vec<_>>() 136 .join(", ") 137 .to_lowercase(); ··· 139 // check if artists don't contain the scrobble artist (to avoid wrong matches) 140 if !artists.contains(&scrobble.data.song.parsed.artist.trim().to_lowercase()) { 141 tracing::warn!(artist = %artist, track = ?track, "Artist mismatch, skipping"); 142 + } else { 143 + tracing::info!("Spotify (track)"); 144 + let mut track = track.clone(); 145 + 146 + if let Some(album) = spotify_client.get_album(&track.album.id).await? { 147 + track.album = album; 148 + } 149 + 150 + if let Some(artist) = spotify_client 151 + .get_artist(&track.album.artists[0].id) 152 + .await? 153 + { 154 + track.album.artists[0] = artist; 155 + } 156 + 157 + rocksky::scrobble(cache, &did, track.into(), scrobble.time).await?; 158 + tokio::time::sleep(std::time::Duration::from_secs(1)).await; 159 return Ok(()); 160 } 161 } 162 163 let query = format!(
crates/webscrobbler/src/types.rs

This file has not been changed.

Submissions

sign up or login to add to the discussion
tsiry-sandratraina.com submitted #1
3 commits
expand
feat: Enhance MusicBrainz integration and improve data handling
fix: update MusicBrainz recording handling to include release information
fix: improve artist matching logic in scrobble functions to prevent mismatches
pull request successfully merged
tsiry-sandratraina.com submitted #0
2 commits
expand
feat: Enhance MusicBrainz integration and improve data handling
fix: update MusicBrainz recording handling to include release information