Skip to content

Commit

Permalink
Added Provider field for earch item
Browse files Browse the repository at this point in the history
  • Loading branch information
Pacerino committed Mar 20, 2023
1 parent 88bca6d commit f68191d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 2 additions & 0 deletions acr.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type RecognizedMetadata struct {
Links MetadataLinks
// Respective IDs to known streaming platforms
IDs MetadataIDs
// Provider of the recognition (ACR, Audd.io, Shazam)
Provider string
}

type MetadataLinks struct {
Expand Down
29 changes: 16 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,13 @@ func (s *SauceSession) findSong(msg *pr0gramm.Message) (string, []string, *Items
logrus.WithFields(logrus.Fields{"item_id": msg.ItemID}).Debug("Metadata was found")
meta.Url = fmt.Sprintf("https://pr0sauce.info/%v", msg.ItemID) // Set URL with the ItemID, creates shorter links!
dbItem := Items{
ItemID: msg.ItemID,
Title: meta.Title,
Album: meta.Album,
Artist: meta.Artist,
Url: meta.Url,
AcrID: meta.AcrID,
ItemID: msg.ItemID,
Title: meta.Title,
Album: meta.Album,
Artist: meta.Artist,
Url: meta.Url,
AcrID: meta.AcrID,
Provider: meta.Provider,
Metadata: ItemMetadata{
SpotifyURL: meta.Links.Spotify,
SpotifyID: meta.IDs.Spotify,
Expand Down Expand Up @@ -421,9 +422,10 @@ func (s *SauceSession) detectMusic(url string) (*RecognizedMetadata, error) {
}
// Found with Shazam!
m := &RecognizedMetadata{
Title: shazamInfo.Track.Title,
Album: album,
Artist: shazamInfo.Track.Subtitle,
Title: shazamInfo.Track.Title,
Album: album,
Artist: shazamInfo.Track.Subtitle,
Provider: "shazam",
}
if links.LinksByPlatform.Spotify.URL != "" {
idslice := strings.Split(links.LinksByPlatform.Spotify.EntityUniqueID, "::")
Expand All @@ -448,10 +450,11 @@ func (s *SauceSession) detectMusic(url string) (*RecognizedMetadata, error) {
acrInfo := recognitionResult.Metadata.Music[0]
if len(acrInfo.Title) > 0 {
m := &RecognizedMetadata{
Title: acrInfo.Title,
Album: acrInfo.Album.Name,
Artist: acrInfo.Artists[0].Name,
AcrID: acrInfo.Acrid,
Title: acrInfo.Title,
Album: acrInfo.Album.Name,
Artist: acrInfo.Artists[0].Name,
AcrID: acrInfo.Acrid,
Provider: "acrcloud",
}

if acrInfo.ExternalMetadata.Spotify.Track.ID != "" {
Expand Down
1 change: 1 addition & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Items struct {
Artist string
Url string
AcrID string
Provider string
Metadata ItemMetadata `gorm:"embedded"`
}

Expand Down

0 comments on commit f68191d

Please sign in to comment.