write this URL to save in album_link.txt in the album folder
Assistant
To save the URL into an album_link.txt file within the album folder, you'll need to adjust the rip function or potentially add a simple function specifically for writing the URL to the file. Given your existing code structure, here's an approach that involves modifying slightly where your album folder is being determined and then saving the URL to a file within that folder:
Assuming you have the album folder creation logic within your rip function, as indicated by the line:
After this line, you can add the following snippet to write the album URL (url variable obtained as function arguments in rip) into an album_link.txt file:
go
func writeAlbumURL(sanAlbumFolder string, url string) error {
albumLinkFile := filepath.Join(sanAlbumFolder, "album_link.txt")
err := ioutil.WriteFile(albumLinkFile, []byte(url), 0644)
if err != nil {
fmt.Println("Failed to write album URL to file")
return err
}
fmt.Printf("Album URL saved to %s\n", albumLinkFile)
return nil
}
And then, inside the rip function, right after creating the album folder, call this new function and pass the sanAlbumFolder and the album url to it:
go
// Right after creating sanAlbumFolder...
if err := writeAlbumURL(sanAlbumFolder, albumURL); err != nil {
// handle error, maybe continue to next album URL or log the error
fmt.Println("Error saving album URL:", err)
}
Please replace albumURL with the actual variable name that holds the URL string if it's different in your code context.
This way, each time you process an album, its URL will be saved in a album_link.txt file within the respective album's directory, providing easy reference to the source URL.
User
where should i add these lines?
give details and show
Assistant
Given your script structure, you'll integrate the functionality to write the URL into an album_link.txt file right within the rip function. This function already handles album-related operations such as fetching metadata, downloading tracks, and organizing them into an album folder. Thus, adding the URL write operation into this workflow will ensure that the source URL is saved alongside the downloaded album content.
Here are the steps detailed with code snippets to guide you where exactly to place the new functionality:
1. Define the writeAlbumURL Function
First, define the writeAlbumURL function preferably towards the bottom of your script or at least before the rip function for better organization. This function is responsible for writing the album URL into a text file:
Then, within the rip function, immediately after you've successfully created or verified the existence of the album folder (sanAlbumFolder), add a call to writeAlbumURL, passing it the folder path and the album URL:
go
func rip(albumId string, token string, storefront string, albumURL string) error { // albumURL parameter added
meta, err := getMeta(albumId, token, storefront)
if err != nil {
fmt.Println("Failed to get album metadata.\n")
return err
}
albumFolder := fmt.Sprintf("%s - %s", meta.Data[0].Attributes.ArtistName, meta.Data[0].Attributes.Name)
sanAlbumFolder := filepath.Join("AM-DL downloads", forbiddenNames.ReplaceAllString(albumFolder, "_"))
err = os.MkdirAll(sanAlbumFolder, os.ModePerm)
if err != nil {
fmt.Println("Failed to create album folder:", err)
return err // Ensure the folder was created before proceeding
}
// New functionality: write the album URL to album_link.txt
if err := writeAlbumURL(sanAlbumFolder, albumURL); err != nil {
fmt.Println("Error saving album URL:", err)
// Decide if you want to return the error and halt or just log it and continue
}
fmt.Println(albumFolder)
// The rest of your rip function continues below...
}
User
command-line-arguments
.\main.go:991:45: undefined: albumURL
.\main.go:1086:42: too many arguments in call to rip
have (string, string, string, string)
want (string, string, string)
func rip(albumId string, token string, storefront string) error {
meta, err := getMeta(albumId, token, storefront)
if err != nil {
fmt.Println("Failed to get album metadata.\n")
return err
}
albumFolder := fmt.Sprintf("%s - %s", meta.Data[0].Attributes.ArtistName, meta.Data[0].Attributes.Name)
sanAlbumFolder := filepath.Join("AM-DL downloads", forbiddenNames.ReplaceAllString(albumFolder, "_"))
os.MkdirAll(sanAlbumFolder, os.ModePerm)
err = os.MkdirAll(sanAlbumFolder, os.ModePerm)
if err != nil {
fmt.Println("Failed to create album folder:", err)
return err // Ensure the folder was created before proceeding
}
code
// New functionality: write the album URL to album_link.txt
if err := writeAlbumURL(sanAlbumFolder, albumURL); err != nil {
fmt.Println("Error saving album URL:", err)
// Decide if you want to return the error and halt or just log it and continue
}
fmt.Println(albumFolder)
err = writeCover(sanAlbumFolder, meta.Data[0].Attributes.Artwork.URL)
if err != nil {
fmt.Println("Failed to write cover.")
}
trackTotal := len(meta.Data[0].Relationships.Tracks.Data)
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
trackNum++
fmt.Printf("Track %d of %d:\n", trackNum, trackTotal)
manifest, err := getInfoFromAdam(track.ID, token, storefront)
if err != nil {
fmt.Println("Failed to get manifest.\n", err)
continue
}
if manifest.Attributes.ExtendedAssetUrls.EnhancedHls == "" {
fmt.Println("Unavailable in ALAC.")
continue
}
explicitTag := ""
if track.Attributes.IsExplicit {
explicitTag = " [E]"
}
fmt.Println("IsExplicit:", track.Attributes.IsExplicit)
fmt.Printf("Track: %s, IsExplicit: %v\n", track.Attributes.Name, track.Attributes.IsExplicit)
filename := fmt.Sprintf("%02d. %s%s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_"), explicitTag)
trackPath := filepath.Join(sanAlbumFolder, filename)
exists, err := fileExists(trackPath)
if err != nil {
fmt.Println("Failed to check if track exists.")
}
if exists {
fmt.Println("Track already exists locally.")
continue
}
trackUrl, keys, err := extractMedia(manifest.Attributes.ExtendedAssetUrls.EnhancedHls)
if err != nil {
fmt.Println("Failed to extract info from manifest.\n", err)
continue
}
info, err := extractSong(trackUrl)
if err != nil {
fmt.Println("Failed to extract track.", err)
continue
}
samplesOk := true
for samplesOk {
for _, i := range info.samples {
if int(i.descIndex) >= len(keys) {
fmt.Println("Decryption size mismatch.")
samplesOk = false
}
}
break
}
if !samplesOk {
continue
}
err = decryptSong(info, keys, meta, trackPath, trackNum, trackTotal)
if err != nil {
fmt.Println("Failed to decrypt track.\n", err)
continue
}
}
return err
Assistant
The errors you've encountered are due to not adjusting the rip function signature to accept the new albumURL parameter and subsequently attempting to pass it from main. To correct these errors, follow these steps:
Adjusting the rip Function Signature
Update the rip function signature to include the albumURL parameter:
go
func rip(albumId string, token string, storefront string, albumURL string) error {
// function body remains the same
}
This change directly addresses the error:
code
.\main.go:1086:42: too many arguments in call to rip
have (string, string, string, string)
want (string, string, string)
Using the albumURL Within the rip Function
Given that you've now passed the albumURL into the rip function correctly, ensure it's available in the scope where you're calling writeAlbumURL. This change should fix the error:
code
.\main.go:991:45: undefined: albumURL
With the updated function signature, albumURL is now defined and can be used within the rip function as intended.
Summary of Changes
Post these fixes, your rip function (with its call to writeAlbumURL) and the main function call to rip are now correctly aligned in terms of expected arguments, and there should not be any compilation errors related to these aspects.
Ensure all parts of your program that call the rip function are updated to pass the correct number of arguments following this change. If there are other parts of the program (not shown in your snippet) that call rip, you'll need to update those as well to include the new albumURL parameter.
These modifications ensure that the album URL is passed through various function calls eventually to be written to a text file, aligning with your intention to save the source URL of each album alongside its downloaded content.
User
check if this contains explicit in response or not?
Assistant
To check if the response contains an explicit tag or not, particularly when managing album or song metadata, you typically look into a specific field that indicates explicit content. Based on the structure of the data classes or structures you've shown (namely SongAttributes, AlbumAttributes, SongResult, etc.), the field that indicates whether a song or album is marked as explicit is likely named IsExplicit.
This explicit flag property appears in the SongAttributes and AlbumAttributes which suggests that both songs and albums can independently be flagged as containing explicit content.
Here's an example of how you might check for an explicit tag in a response for both a song and an album:
1. Checking a Song for Explicit Content
After retrieving a SongData object (for example, from a JSON response decoded into your Go struct), you'd check the IsExplicit field in its Attributes:
This function takes a SongData object and returns true if the song is marked as explicit.
2. Checking an Album for Explicit Content
Similarly, after retrieving an album (formatted as your predefined structures), you could check if any song within the album is explicit or if the album itself is explicitly tagged:
go
func isAlbumExplicit(album AutoGenerated) bool {
// First, check if the album explicitly marked as explicit
if album.Data[0].Attributes.IsExplicit {
return true
}
// Optionally, check if any track in the album is explicitly marked
for _, track := range album.Data[0].Relationships.Tracks.Data {
if track.Attributes.IsExplicit {
return true
}
}
return false
}
This function checks the explicit markers at both the album and track levels within a given album’s data structure. It first looks at the album's explicit flag; if not found, it iterates through each track in the album to check for explicit content.
Usage
To use these functions, ensure you've obtained the album or song data and appropriately decoded the JSON into your Go structs. Then, call these functions with your data to check for explicit content:
User
// Assuming song is a SongData object and album is an AutoGenerated object
songExplicit := isSongExplicit(song)
albumExplicit := isAlbumExplicit(album)
fmt.Printf(“Is the song explicit? %v\n”, songExplicit)
fmt.Printf(“Is the album or any of its tracks explicit? %v\n”, albumExplicit)
where to call this?
Assistant
Where to call these functions to check if songs or albums are explicit depends on the flow of your application and at which point you need to determine the explicitness of the content. Considering your prior context where you're processing albums and tracks, here are common scenarios where these checks might be useful:
1. When Processing Each Track of an Album
After retrieving the track details and before proceeding with operations like downloading or logging track information, you can check for explicit content.
Assuming you have a loop that iterates over tracks in an album within your rip function (or similar), insert the check right within that loop:
go
// Inside your loop that processes each track:
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
songExplicit := isSongExplicit(track) // Assuming you adjust isSongExplicit to accept the track directly
fmt.Printf("Track: %s, IsExplicit: %v\n", track.Attributes.Name, songExplicit)
// Continue with processing based on explicit check
// ...
}
2. When Processing the Album as a Whole
Right after you fetch the album metadata and before you start processing individual tracks or performing other album-wide operations such as creating folders, downloading covers, etc., you can check if the album or any of its tracks are marked as explicit:
go
// After retrieving album metadata
albumExplicit := isAlbumExplicit(album) // Assuming 'album' is your AutoGenerated object filled with metadata
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
// Perform operations based on the album's explicit content flag
// ...
Common Use Cases:
Filtering Explicit Content: You might want to skip downloading or processing tracks marked as explicit based on user preferences or application settings.
Logging and Notification: Inform the user or log whether the currently processing content is explicit, which can be crucial for parental controls or content management systems.
func isAlbumExplicit(album AutoGenerated) bool {
// First, check if the album explicitly marked as explicit
if album.Data[0].Attributes.IsExplicit {
return true
}
code
// Optionally, check if any track in the album is explicitly marked
for _, track := range album.Data[0].Relationships.Tracks.Data {
if track.Attributes.IsExplicit {
return true
}
}
return false
}
func rip(albumId string, token string, storefront string, albumURL string) error {
meta, err := getMeta(albumId, token, storefront)
if err != nil {
fmt.Println("Failed to get album metadata.\n")
return err
}
albumFolder := fmt.Sprintf("%s - %s", meta.Data[0].Attributes.ArtistName, meta.Data[0].Attributes.Name)
sanAlbumFolder := filepath.Join("AM-DL downloads", forbiddenNames.ReplaceAllString(albumFolder, "_"))
os.MkdirAll(sanAlbumFolder, os.ModePerm)
err = os.MkdirAll(sanAlbumFolder, os.ModePerm)
if err != nil {
fmt.Println("Failed to create album folder:", err)
return err // Ensure the folder was created before proceeding
}
code
Assistant
The error messages you're receiving:
code
.\main.go:1036:37: undefined: song
.\main.go:1037:36: undefined: album
suggest that within your rip function, you're attempting to call isSongExplicit(song) and isAlbumExplicit(album) without appropriate song and album variables defined or in scope. Given the structure of your code and how you handle album and song data, we need to appropriately fetch or reference these objects before we can perform the explicit content checks.
Considering your loop is iterating over tracks within an album, you likely wish to check the explicit status for each track inside this loop. You might not have a single SongData object named song, but instead, you have each track as represented by the track variable within the loop. Similarly, you have the entire album data available as meta based on your given structure, so album should be replaced with meta when calling isAlbumExplicit.
Here's how you can adjust and call these explicit checks correctly:
Adjusting Explicit Content Checks
Album Check - You already have the album's metadata in the variable meta, which is a type of AutoGenerated, so you can directly call isAlbumExplicit(meta).
Song Check - Instead of a non-existent song variable, you should pass the current track in the loop to a function designed to work with a track instead of the whole SongData structure. You'll need to adjust the definition of isSongExplicit to accept the type that matches your tracks, or just inline the check given you already have track.Attributes.IsExplicit.
Correcting the Code
Assuming the correction for the isSongExplicit function, here's how to inline the check for the song's explicit status:
Within your loop where you process each track:
go
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
// For each track, check if it's explicit, no need to call isSongExplicit
songExplicit := track.Attributes.IsExplicit
fmt.Printf("Is the song explicit? %v\n", songExplicit)
}
User
command-line-arguments
.\main.go:1019:35: cannot use meta (variable of type *AutoGenerated) as AutoGenerated value in argument to isAlbumExplicit
.\main.go:1023:34: undefined: song
func isAlbumExplicit(album AutoGenerated) bool {
// First, check if the album explicitly marked as explicit
if album.Data[0].Attributes.IsExplicit {
return true
}
code
// Optionally, check if any track in the album is explicitly marked
for _, track := range album.Data[0].Relationships.Tracks.Data {
if track.Attributes.IsExplicit {
return true
}
}
return false
}
func rip(albumId string, token string, storefront string, albumURL string) error {
meta, err := getMeta(albumId, token, storefront)
if err != nil {
fmt.Println("Failed to get album metadata.\n")
return err
}
albumFolder := fmt.Sprintf("%s - %s", meta.Data[0].Attributes.ArtistName, meta.Data[0].Attributes.Name)
sanAlbumFolder := filepath.Join("AM-DL downloads", forbiddenNames.ReplaceAllString(albumFolder, "_"))
os.MkdirAll(sanAlbumFolder, os.ModePerm)
err = os.MkdirAll(sanAlbumFolder, os.ModePerm)
if err != nil {
fmt.Println("Failed to create album folder:", err)
return err // Ensure the folder was created before proceeding
}
code
Assistant
To address the errors in your code and improve its correctness, let’s focus on the issues and how to fix each one:
Issue 1: cannot use meta (variable of type *AutoGenerated) as AutoGenerated value in argument to isAlbumExplicit
This is a type mismatch issue. The getMeta function likely returns a pointer to an AutoGenerated type (*AutoGenerated), but isAlbumExplicit expects an AutoGenerated value. You can either change the isAlbumExplicit function to accept a pointer or dereference meta when passing it to the function.
Solution:
Option 1: Change the function parameter to accept a pointer:
go
func isAlbumExplicit(album *AutoGenerated) bool {
// Adjust the function body to use album as a pointer.
}
Option 2: Dereference meta when calling isAlbumExplicit (if it doesn't affect other uses of meta):
go
albumExplicit := isAlbumExplicit(*meta) // Dereferencing meta
Issue 2: undefined: song
This error arises because there is no defined variable song when you call isSongExplicit(song). The song data is likely represented by each track within the loop iterating over meta.Data[0].Relationships.Tracks.Data, so you should use information from track instead.
Solution:
Replace the call to isSongExplicit(song) with a direct check using the current track:
go
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
songExplicit := track.Attributes.IsExplicit
fmt.Printf("Is the song explicit? %v\n", songExplicit)
...
// Rest of your code
}
Remember, songExplicit here is obtained directly from the track.Attributes.IsExplicit within your loop, removing the need for the undefined song variable.
Given these issues, here is the corrected segment of your function regarding explicit content determination:
Lastly, ensure the main function passes the album URL to rip. Since rip has a new parameter (albumURL), you'll need to adjust where rip is called within main to include the URL argument:
go
func main() {
token, err := getToken()
if err != nil {
fmt.Println("Failed to get token.")
return
}
albumTotal := len(os.Args[1:])
for albumNum, url := range os.Args[1:] {
fmt.Printf("Album %d of %d:\n", albumNum+1, albumTotal)
storefront, albumId := checkUrl(url)
if albumId == "" {
fmt.Printf("Invalid URL: %s\n", url)
continue
}
// Now pass the URL to rip
err := rip(albumId, token, storefront, url) // url is the new argument
if err != nil {
fmt.Println("Album failed.")
fmt.Println(err)
}
}
}
By incorporating these adjustments, your program will not only download and organize the albums but also save a reference to the source URL in album_link.txt within each album's directory.
}
func writeAlbumURL(sanAlbumFolder string, url string) error {
albumLinkFile := filepath.Join(sanAlbumFolder, "album_link.txt")
err := ioutil.WriteFile(albumLinkFile, []byte(url), 0644)
if err != nil {
fmt.Println("Failed to write album URL to file")
return err
}
fmt.Printf("Album URL saved to %s\n", albumLinkFile)
return nil
}
func main() {
token, err := getToken()
if err != nil {
fmt.Println("Failed to get token.")
return
}
albumTotal := len(os.Args[1:])
for albumNum, url := range os.Args[1:] {
fmt.Printf("Album %d of %d:\n", albumNum+1, albumTotal)
storefront, albumId := checkUrl(url)
if albumId == "" {
fmt.Printf("Invalid URL: %s\n", url)
continue
}
err := rip(albumId, token, storefront, url)
if err != nil {
fmt.Println("Album failed.")
fmt.Println(err)
}
}
}
go
// Assuming `song` is a SongData object and `album` is an AutoGenerated object
songExplicit := isSongExplicit(song)
albumExplicit := isAlbumExplicit(album)
fmt.Printf("Is the song explicit? %v\n", songExplicit)
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
This approach relies on having populated SongData and AutoGenerated objects with whatever response data you're handling, typically through unmarshalling JSON responses from an API call into these Go data structures.
Conditional Processing: You might handle explicit and non-explicit content differently, such as tagging files or organizing them into separate folders.
Insertion Point in the main Function:
If you're determining explicitness as part of a broader process starting from the main function, incorporate these checks right after obtaining the details necessary for making the decision, i.e., immediately after fetching the song or album metadata.
Always ensure these checks are done after successfully ensuring you have the song or album data object (SongData or AutoGenerated) properly populated from your data source (API response, file, etc.). It ensures the rest of your operation (downloading, organizing, or logging) is aware of the content's explicit status.
// New functionality: write the album URL to album_link.txt
if err := writeAlbumURL(sanAlbumFolder, albumURL); err != nil {
fmt.Println("Error saving album URL:", err)
// Decide if you want to return the error and halt or just log it and continue
}
fmt.Println(albumFolder)
err = writeCover(sanAlbumFolder, meta.Data[0].Attributes.Artwork.URL)
if err != nil {
fmt.Println("Failed to write cover.")
}
trackTotal := len(meta.Data[0].Relationships.Tracks.Data)
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
trackNum++
fmt.Printf("Track %d of %d:\n", trackNum, trackTotal)
manifest, err := getInfoFromAdam(track.ID, token, storefront)
if err != nil {
fmt.Println("Failed to get manifest.\n", err)
continue
}
if manifest.Attributes.ExtendedAssetUrls.EnhancedHls == "" {
fmt.Println("Unavailable in ALAC.")
continue
}
explicitTag := ""
if track.Attributes.IsExplicit {
explicitTag = " [E]"
}
songExplicit := isSongExplicit(song)
albumExplicit := isAlbumExplicit(album)
fmt.Printf("Is the song explicit? %v\n", songExplicit)
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
fmt.Println("IsExplicit:", track.Attributes.IsExplicit)
fmt.Printf("Track: %s, IsExplicit: %v\n", track.Attributes.Name, track.Attributes.IsExplicit)
filename := fmt.Sprintf("%02d. %s%s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_"), explicitTag)
trackPath := filepath.Join(sanAlbumFolder, filename)
exists, err := fileExists(trackPath)
if err != nil {
fmt.Println("Failed to check if track exists.")
}
And right before the loop, you can check if the album is explicit:
go
albumExplicit := isAlbumExplicit(meta) // Using `meta`, not `album`
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
Summary
You don't have a song or album variable ready for use as required by your initial call. Replace usage of album with the actual variable meta that contains your album data, and adjust or inline the song explicitness check as per your specific case.
Directly use the track variable within your loop for song explicitness checks, given that each track in the loop represents a song.
These adjustments align the code with the data you have available and should resolve the undefined variable issues you're encountering.
// New functionality: write the album URL to album_link.txt
if err := writeAlbumURL(sanAlbumFolder, albumURL); err != nil {
fmt.Println("Error saving album URL:", err)
// Decide if you want to return the error and halt or just log it and continue
}
fmt.Println(albumFolder)
err = writeCover(sanAlbumFolder, meta.Data[0].Attributes.Artwork.URL)
if err != nil {
fmt.Println("Failed to write cover.")
}
albumExplicit := isAlbumExplicit(meta) // Using meta, not album
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
trackTotal := len(meta.Data[0].Relationships.Tracks.Data)
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
songExplicit := isSongExplicit(song)
fmt.Printf("Is the song explicit? %v\n", songExplicit)
explicitTag := ""
if track.Attributes.IsExplicit {
explicitTag = " [E]"
}
fmt.Println("IsExplicit:", track.Attributes.IsExplicit)
trackNum++
fmt.Printf("Track %d of %d:\n", trackNum, trackTotal)
manifest, err := getInfoFromAdam(track.ID, token, storefront)
if err != nil {
fmt.Println("Failed to get manifest.\n", err)
continue
}
if manifest.Attributes.ExtendedAssetUrls.EnhancedHls == "" {
fmt.Println("Unavailable in ALAC.")
continue
}
// albumExplicit := isAlbumExplicit(album)
// fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
fmt.Printf("Track: %s, IsExplicit: %v\n", track.Attributes.Name, track.Attributes.IsExplicit)
filename := fmt.Sprintf("%02d. %s%s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_"), explicitTag)
trackPath := filepath.Join(sanAlbumFolder, filename)
exists, err := fileExists(trackPath)
if err != nil {
fmt.Println("Failed to check if track exists.")
}
if exists {
fmt.Println("Track already exists locally.")
continue
}
trackUrl, keys, err := extractMedia(manifest.Attributes.ExtendedAssetUrls.EnhancedHls)
if err != nil {
fmt.Println("Failed to extract info from manifest.\n", err)
continue
}
info, err := extractSong(trackUrl)
if err != nil {
fmt.Println("Failed to extract track.", err)
continue
}
samplesOk := true
for samplesOk {
for _, i := range info.samples {
if int(i.descIndex) >= len(keys) {
fmt.Println("Decryption size mismatch.")
samplesOk = false
}
}
break
}
if !samplesOk {
continue
}
err = decryptSong(info, keys, meta, trackPath, trackNum, trackTotal)
if err != nil {
fmt.Println("Failed to decrypt track.\n", err)
continue
}
}
return err
}
is it correct? and correct me if you need to
rip
go
// Assuming meta has been properly fetched already
albumExplicit := isAlbumExplicit(meta) // Solving Issue 1
fmt.Printf("Is the album or any of its tracks explicit? %v\n", albumExplicit)
trackTotal := len(meta.Data[0].Relationships.Tracks.Data)
for trackNum, track := range meta.Data[0].Relationships.Tracks.Data {
// Directly using track attributes to check explicitness (Solving Issue 2)
songExplicit := track.Attributes.IsExplicit
fmt.Printf("Track %d of %d: %s, IsExplicit: %v\n", trackNum+1, trackTotal, track.Attributes.Name, songExplicit)
...
// Rest of your processing code
}
General Tips
Always ensure that function parameters and the arguments passed to them match in both type and usage context.
When dealing with pointers, remember that they reference a location in memory. This can impact how you access the data depending on whether a function expects a value or a pointer.
For readability and maintainability, prioritize direct attributes/properties access (track.Attributes.IsExplicit) in simple cases like checking a boolean flag.