mirror of
https://github.com/riwiwa/muzi.git
synced 2026-02-28 03:46:57 -08:00
add username to lastfm import logs
This commit is contained in:
@@ -97,10 +97,11 @@ func fetchPage(client *http.Client, page int, lfmUsername, apiKey string, userId
|
||||
}
|
||||
|
||||
func ImportLastFM(
|
||||
username string,
|
||||
lfmUsername string,
|
||||
apiKey string,
|
||||
userId int,
|
||||
progressChan chan<- ProgressUpdate,
|
||||
username string,
|
||||
) error {
|
||||
totalImported := 0
|
||||
|
||||
@@ -110,7 +111,7 @@ func ImportLastFM(
|
||||
|
||||
resp, err := client.Get(
|
||||
"https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=" +
|
||||
username + "&api_key=" + apiKey + "&format=json&limit=100",
|
||||
lfmUsername + "&api_key=" + apiKey + "&format=json&limit=100",
|
||||
)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error getting LastFM HTTP response: %v\n", err)
|
||||
@@ -135,7 +136,8 @@ func ImportLastFM(
|
||||
}
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Total pages: %d\n", totalPages)
|
||||
fmt.Printf("%s started a LastFM import job of %d total pages\n", username,
|
||||
totalPages)
|
||||
|
||||
// send initial progress update
|
||||
if progressChan != nil {
|
||||
@@ -215,7 +217,10 @@ func ImportLastFM(
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("%d tracks imported from LastFM for user %s\n", totalImported, username)
|
||||
fmt.Printf("User %s imported %d tracks from LastFM account %s\n",
|
||||
username,
|
||||
totalImported,
|
||||
lfmUsername)
|
||||
|
||||
// send completion update
|
||||
if progressChan != nil {
|
||||
|
||||
@@ -433,7 +433,8 @@ func importLastFMHandler(w http.ResponseWriter, r *http.Request) {
|
||||
jobsMu.Unlock()
|
||||
|
||||
go func() {
|
||||
migrate.ImportLastFM(lastfmUsername, lastfmAPIKey, userId, progressChan)
|
||||
migrate.ImportLastFM(lastfmUsername, lastfmAPIKey, userId, progressChan,
|
||||
username)
|
||||
|
||||
jobsMu.Lock()
|
||||
delete(importJobs, jobID)
|
||||
|
||||
Reference in New Issue
Block a user