0

format numbers

let api := "a7e22d237021e918cbaa602fe168f52b";
let artist := replace(Name, " ", " ");
let album := replace(Title, " ", " ");
let url := "https://ws.audioscrobbler.com/2.0/?method=album.getinfo" + "&artist=" + artist +
    "&album=" +
    album +
    "&api_key=" +
    api +
    "&format=json";
let response := http("GET", url, {}, {});
let allTracks := "";
let found := false;
for key, value in response.result do
    if key = "album" then
        found := true;
        let header := "Artista: " + value.artist +
            "
Álbum: " +
            value.name +
            "

";
        let i := 1;
        let tracksList := join(for t in value.tracks.track do
                let trackName := text(t.name);
                let durationSec := number(t.duration);
                let min := floor(durationSec / 60);
                let sec := durationSec - min * 60;
                let durationText := if durationSec > 0 then
                        "(" + text(min) + ":" + if sec < 10 then "0" else "" end + text(sec) + ")"
                    else
                        "(sin duración)"
                    end;
                let line := number(i) + ". " + trackName + " " + durationText;
                i := i + 1;
                line
            end, "
");
        let popularity := "

Popularidad:
Reproducciones: " +
            value.playcount +
            "
Oyentes: " +
            value.listeners;
        allTracks := header + tracksList + popularity
    end
end;
if not found or allTracks = "" then
    allTracks := "No tracks found for this album."
end;
allTracks

There are any way to format the value.playcount and value.listeners  ?

7 replies

null
    • Fred
    • yesterday
    • Reported - view

    If the data from the api is JSON, then data is (any). Looks like you are in Ninox so can't you use the format() command?

      • Rafael Sanchis
      • Rafael_Sanchis
      • yesterday
      • Reported - view

       

      Hi Fred

      Yes I tried it but it doesn't work.

      playcount → total number of times the album has been played (scrobbled) on Last.fm.

      listeners → total number of unique users who have listened to that album.
       

      • Fred
      • yesterday
      • Reported - view

      can you post where you put the format() command?

      • Rafael Sanchis
      • Rafael_Sanchis
      • yesterday
      • Reported - view

       

      format(value.playcount, "0.000#,#")

      format(value.listeners, "0.000#,#")

      • Fred
      • yesterday
      • Reported - view

      hmm, I don't know why it wouldn't work. Maybe someone else has an idea.

      Can you post a sample of the data?

    • Ninox partner
    • RoSoft_Steven.1
    • yesterday
    • Reported - view

    Maybe the returned values are text? what If you try: format(number(value.playcount), "0.000#,#")

      • Rafael Sanchis
      • Rafael_Sanchis
      • 20 hrs ago
      • Reported - view

       

      Thanks Steven