|
|
@ -15,6 +15,7 @@ import ( |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
"net/url" |
|
|
|
"net/url" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
|
|
|
|
"os/exec" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
"regexp" |
|
|
|
"regexp" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
@ -1139,21 +1140,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
filename := fmt.Sprintf("%02d. %s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) |
|
|
|
filename := fmt.Sprintf("%02d. %s.m4a", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) |
|
|
|
lrcFilename := fmt.Sprintf("%02d. %s.lrc", trackNum, forbiddenNames.ReplaceAllString(track.Attributes.Name, "_")) |
|
|
|
|
|
|
|
trackPath := filepath.Join(sanAlbumFolder, filename) |
|
|
|
trackPath := filepath.Join(sanAlbumFolder, filename) |
|
|
|
|
|
|
|
var lrc string = "" |
|
|
|
if userToken != "" { |
|
|
|
if userToken != "" { |
|
|
|
ttml, err := getSongLyrics(track.ID, storefront, token, userToken) |
|
|
|
ttml, err := getSongLyrics(track.ID, storefront, token, userToken) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
fmt.Println("Failed to get lyrics") |
|
|
|
fmt.Println("Failed to get lyrics") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
lrc, err := conventTTMLToLRC(ttml) |
|
|
|
lrc, err = conventTTMLToLRC(ttml) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("Failed to parse lyrics: %s \n", err) |
|
|
|
fmt.Printf("Failed to parse lyrics: %s \n", err) |
|
|
|
} else { |
|
|
|
|
|
|
|
err := writeLyrics(sanAlbumFolder, lrcFilename, lrc) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
fmt.Printf("Failed to write lyrics") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1193,6 +1189,16 @@ func rip(albumId string, token string, storefront string, userToken string) erro |
|
|
|
fmt.Println("Failed to decrypt track.\n", err) |
|
|
|
fmt.Println("Failed to decrypt track.\n", err) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
tags := []string{ |
|
|
|
|
|
|
|
fmt.Sprintf("lyrics=%s", lrc), |
|
|
|
|
|
|
|
fmt.Sprintf("cover=%s/cover.jpg", sanAlbumFolder), |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tagsString := strings.Join(tags, ":") |
|
|
|
|
|
|
|
cmd := exec.Command("MP4Box","-itags", tagsString, trackPath) |
|
|
|
|
|
|
|
if err := cmd.Run(); err != nil { |
|
|
|
|
|
|
|
fmt.Printf("Embed failed: %v\n", err) |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return err |
|
|
|
return err |
|
|
|