package org.hsbp.burnstation3;

import java.net.URL;
import java.net.MalformedURLException;
import org.json.JSONObject;
import org.json.JSONException;

public class Track {
    protected String artist_name, name;
    protected URL audio;
    protected int duration;
    public final static String NAME = "name";
    public final static String ARTIST_NAME = "artist_name";
    public final static String AUDIO = "audio";
    public final static String DURATION = "duration";
    public final static String STR_FMT = "%s (%d:%02d)";

    protected Track() {}

    public static Track fromJSONObject(JSONObject obj) throws JSONException,
           MalformedURLException {
        final Track track = new Track();
        track.name = obj.getString(NAME);
        track.artist_name = obj.getString(ARTIST_NAME);
        track.duration = obj.getInt(DURATION);
        track.audio = new URL(obj.getString(AUDIO));
        return track;
    }

    public String toString() {
        return String.format(STR_FMT, name, duration / 60, duration % 60);
    }
}

@@ -204,16 +204,20 @@
 me, name
+, id
 ;%0A    pr
@@ -263,16 +263,58 @@
 ration;%0A
+    public final static String ID = %22id%22;%0A
     publ
@@ -750,16 +750,54 @@
 rack();%0A
+        track.id = obj.getString(ID);%0A
         

store ID