What I tried to do was use the last.fm API and track.getSimiliar to find 100 similiar songs to cher - believe. then find 10 similar songs to each of those 100 songs.
when I try to find the 10 similar songs I am using the function call inside a while loop and iterating through the collection returned. this works till the 7th call and then it errors out.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Collection;
import de.umass.lastfm.*;
public class question {
public static void main(String args[]) throws FileNotFoundException {
Caller.getInstance().setUserAgent("tst");
String key = "6d1b1a7cbcc442e70b3bffcfb163c9a0"; // this is the key used
// in the Last.fm
// API examples
String user = "dgupta33";
PrintStream outFile = new PrintStream(new File("output_trackNames.txt"));
PrintStream outFile2 = new PrintStream(new File("output_Artist.txt"));
Collection<Track> tracks = Track.getSimilar("Cher", "Believe", key);
int num = 1;
for (Track track : tracks) {
if (track.getMbid() != "" && num <= 100) {
outFile.println(track.getName());
outFile2.println(track.getArtist());
num++;
} else if (num > 100)
break;
}
outFile.close();
outFile2.close();
}
}
the error that I am getting:
[Fatal Error] :2025:48: XML document structures must start and end within the same entity.
Exception in thread "main" de.umass.lastfm.CallException: org.xml.sax.SAXParseException; lineNumber: 2025; columnNumber: 48; XML document structures must start and end within the same entity.
at de.umass.lastfm.Caller.call(Caller.java:268)
at de.umass.lastfm.Caller.call(Caller.java:189)
at de.umass.lastfm.Track.getSimilar(Track.java:369)
at initiate.Main.main(Main.java:29)
Caused by: org.xml.sax.SAXParseException; lineNumber: 2025; columnNumber: 48; XML document structures must start and end within the same entity.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at de.umass.lastfm.Caller.createResultFromInputStream(Caller.java:324)
at de.umass.lastfm.Caller.call(Caller.java:256)
... 3 more
No comments:
Post a Comment