use of delta.downloads.Downloader in project lotro-tools by dmorcellet.
the class RecipesIndexJSONParser method parseRecipesIndex.
/**
* Get recipes index from web.
* @return A recipes index or <code>null</code> if a problem occurs.
*/
public RecipesIndex parseRecipesIndex() {
RecipesIndex ret;
try {
_index = new RecipesIndex();
Downloader d = new Downloader();
while ((_total == 0) || (_currentItemIndex < _total)) {
load(d, _currentItemIndex);
}
ret = _index;
_index = null;
} catch (Exception e) {
ret = null;
}
return ret;
}
use of delta.downloads.Downloader in project lotro-tools by dmorcellet.
the class MainLoadStats method doItForOneMonthMax.
private Results doItForOneMonthMax(Date start, Date end, String file) {
Results results = new Results();
String url = buildURL("lotrocompanion", file, start, end);
// System.out.println("URL: "+url);
Downloader d = new Downloader();
String s = null;
try {
s = d.downloadString(url);
JSONObject o = new JSONObject(s);
// OSes
{
JSONArray oses = o.getJSONArray("oses");
int nbOses = oses.length();
for (int i = 0; i < nbOses; i++) {
JSONArray oneOS = (JSONArray) oses.get(i);
String osName = (String) oneOS.get(0);
Integer osNumber = (Integer) oneOS.get(1);
results.addForOS(osName, osNumber.intValue());
}
}
// Countries
{
JSONArray countries = o.getJSONArray("countries");
int nbCountries = countries.length();
for (int i = 0; i < nbCountries; i++) {
JSONArray oneOS = (JSONArray) countries.get(i);
String countryName = (String) oneOS.get(0);
Integer number = (Integer) oneOS.get(1);
results.addForCountry(countryName, number.intValue());
}
}
} catch (Exception e) {
System.out.println("Got exception. JSON was [" + s + "]");
e.printStackTrace();
}
// System.out.println("Results: "+results);
return results;
}
use of delta.downloads.Downloader in project lotro-tools by dmorcellet.
the class QuestsIndexJSONParser method parseQuestsIndex.
/**
* Get quests index from web.
* @return A quests index or <code>null</code> if a problem occurs.
*/
public QuestsIndex parseQuestsIndex() {
QuestsIndex ret;
try {
_index = new QuestsIndex();
Downloader d = new Downloader();
while ((_total == 0) || (_currentItemIndex < _total)) {
load(d, _currentItemIndex);
}
ret = _index;
_index = null;
} catch (Exception e) {
ret = null;
}
return ret;
}
use of delta.downloads.Downloader in project lotro-tools by dmorcellet.
the class MainTestDownloadQuestPage method main.
/**
* Main method.
* @param args Not used.
*/
public static void main(String[] args) {
String url = "http://lorebook.lotro.com/wiki/Special:LotroResource?id=1879210718";
Downloader d = new Downloader();
File tmpDir = FileSystem.getTmpDir();
File tmp = new File(tmpDir, "tmp.html");
try {
d.downloadToFile(url, tmp);
} catch (DownloadException de) {
_logger.error("Cannot download quest page!", de);
}
}
Aggregations