* @param entry An entry
* @param element XML source element
*/
protected static void loadStandardInfo(MusicEntry entry, DomElement element) {
// playcount & listeners
DomElement statsChild = element.getChild("stats");
String playcountString;
String userPlaycountString;
String listenersString;
if (statsChild != null) {
playcountString = statsChild.getChildText("playcount");
userPlaycountString = statsChild.getChildText("userplaycount");
listenersString = statsChild.getChildText("listeners");
} else {
playcountString = element.getChildText("playcount");
userPlaycountString = element.getChildText("userplaycount");
listenersString = element.getChildText("listeners");
}
if (element.hasChild("id")) {
entry.id = element.getChildText("id");
}
// percentagechange in getHype() responses
if (element.hasChild("percentagechange")) {
entry.percentageChange = Integer.parseInt(element.getChildText("percentagechange"));
}
int playcount = playcountString == null || playcountString.length() == 0 ? -1 : Integer
.parseInt(playcountString);
int userPlaycount = userPlaycountString == null || userPlaycountString.length() == 0 ? -1 : Integer
.parseInt(userPlaycountString);
int listeners = listenersString == null || listenersString.length() == 0 ? -1 : Integer
.parseInt(listenersString);
// streamable
String s = element.getChildText("streamable");
boolean streamable = s != null && s.length() != 0 && Integer.parseInt(s) == 1;
// copy
entry.name = element.getChildText("name");
entry.url = element.getChildText("url");
entry.mbid = element.getChildText("mbid");
entry.playcount = playcount;
entry.userPlaycount = userPlaycount;
entry.listeners = listeners;
entry.streamable = streamable;
// tags
DomElement tags = element.getChild("tags");
if (tags == null)
tags = element.getChild("toptags");
if (tags != null) {
for (DomElement tage : tags.getChildren("tag")) {
entry.tags.add(tage.getChildText("name"));
}
}
// wiki
DomElement wiki = element.getChild("bio");
if (wiki == null)
wiki = element.getChild("wiki");
if (wiki != null) {
String publishedText = wiki.getChildText("published");
try {
entry.wikiLastChanged = DATE_FORMAT.parse(publishedText);
} catch (ParseException e) {
// try parsing it with current locale
try {
DateFormat clFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZZ", Locale.getDefault());
entry.wikiLastChanged = clFormat.parse(publishedText);
} catch (ParseException e2) {
// cannot parse date, wrong locale. wait for last.fm to fix.
}
}
entry.wikiSummary = wiki.getChildText("summary");
entry.wikiText = wiki.getChildText("content");
}
// images
ImageHolder.loadImages(entry, element);
}