[WIP] music platform user data scraper
teal-fm atproto
31
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pre-set uploadHash for comparing uploaded track

+9 -3
+9 -3
service/applemusic/applemusic.go
··· 439 439 s.logger.Printf("failed to get last tracks for user %d: %v", user.ID, err) 440 440 } 441 441 442 - // Check if this is a new track (by PlayParams.id) 442 + // For uploaded tracks, the API returns an empty URL, but we store a generated hash. 443 + // Compute the hash here so the comparison uses the same value as what's in the DB. 444 + currentURL := currentAppleTrack.Attributes.URL 445 + if currentURL == "" { 446 + currentURL = generateUploadHash(currentAppleTrack) 447 + } 448 + 449 + // Check if this is a new track (by URL / upload hash) 443 450 if len(lastTracks) > 0 { 444 451 lastTrack := lastTracks[0] 445 - // If the URL matches, it's the same track 446 - if lastTrack.URL == currentAppleTrack.Attributes.URL { 452 + if lastTrack.URL == currentURL { 447 453 s.logger.Printf("track unchanged for user %d: %s by %s", user.ID, currentAppleTrack.Attributes.Name, currentAppleTrack.Attributes.ArtistName) 448 454 return nil 449 455 }