TvGids gids = new TvGids(cacheFile);
for (int day=offset; day<offset+days; day++) {
- if (!quiet) System.out.println("Fetching information for day " + day);
+ if (!quiet) System.out.print("Fetching information for day " + day);
Set<Programme> programmes = new HashSet<Programme>();
for( Channel c: config.channels ) {
+ if (!quiet) System.out.print(".");
ArrayList<Channel> cs = new ArrayList<Channel>(2);
cs.add(c);
Set<Programme> p = gids.getProgrammes(cs, day, true);
writer.writePrograms(p);
writer.flush();
}
+ if (!quiet) System.out.println();
}
try {
writer.close();
if (!quiet) {
+ System.out.println("Number of programmes from cache: " + gids.cacheHits);
+ System.out.println("Number of programmes fetched: " + gids.cacheMisses);
System.out.println("Number of fetch errors: " + gids.fetchErrors);
}
}
ProgrammeCache cache;
static boolean initialised = false;
int fetchErrors = 0;
+ int cacheHits = 0;
+ int cacheMisses = 0;
public TvGids(File cacheFile) {
cache = new ProgrammeCache(cacheFile);
private void fillDetails(Programme p) throws Exception {
p.details = cache.getDetails(p.db_id);
if ( p.details == null ) {
+ cacheMisses++;
URL url = detailUrl(p.db_id);
JSONObject json = fetchJSON(url);
p.details = (ProgrammeDetails) JSONObject.toBean(json, ProgrammeDetails.class);
p.details.fixup(p);
cache.add(p.db_id, p.details);
+ } else {
+ cacheHits++;
}
}
}