A decentralized music tracking and discovery platform built on AT Protocol 🎵

[scrobbler] correctly add album year

+10 -1
+10 -1
crates/scrobbler/src/scrobbler.rs
··· 145 145 let album = repo::album::get_album_by_track_id(pool, &track.xata_id).await?; 146 146 let artist = repo::artist::get_artist_by_track_id(pool, &track.xata_id).await?; 147 147 let mut track: Track = track.into(); 148 - track.year = album.year.map(|x| x as u32); 148 + track.year = match album.year { 149 + Some(year) => Some(year as u32), 150 + None => match album.release_date.clone() { 151 + Some(release_date) => { 152 + let year = release_date.split("-").next(); 153 + year.and_then(|x| x.parse::<u32>().ok()) 154 + } 155 + None => None, 156 + }, 157 + }; 149 158 track.release_date = album.release_date.map(|x| x.split("T").next().unwrap().to_string()); 150 159 track.artist_picture = artist.picture.clone(); 151 160